[Bio] / MExplorer / MExplorer.cc Repository:
ViewVC logotype

Annotation of /MExplorer/MExplorer.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download) (as text)

1 : efrank 1.1 //************************************************************************
2 :     // Play with exploring the e. coli reco in biosimscratch.
3 :     //
4 :     //************************************************************************
5 :    
6 :     #include <string>
7 :     #include <vector>
8 :     #include <iterator>
9 :    
10 :     #include "RecoReadout/RecoElem.hh"
11 :     #include "RecoReadout/Reaction.hh"
12 :    
13 :     #include "RecoReadoutOracle/OracleMgr.hh"
14 : efrank 1.3 #include "RecoReadoutOracle/BssFactory.hh"
15 : efrank 1.1
16 :     void printKids( RecoElem& r );
17 :    
18 :     int
19 :     main(int argc, char* arg[] ) {
20 :     cout << "A creepy feeling comes over you..." << endl;
21 :     cout << "It wakes." << endl;
22 :    
23 :     // Normally, we'd consult a Reco dictionary to find a reco we cared
24 :     // about. But that's not built yet. So, I'm going to cook up
25 :     // the top of a reconstruction I know is in the database. In real
26 :     // life, you'd peruse the dictionary and just be handed a RecoElem
27 :     // to mess with.
28 :    
29 :     OracleMgr::mgr().startJob();
30 : efrank 1.3 BssFactory bssFactory;
31 :     RecoElem* recoTop = bssFactory.getRecoElemById( 10000 );
32 : efrank 1.1
33 :     // OK. Mess with it. Get its kids and print them out.
34 :    
35 : efrank 1.3 printKids( *recoTop );
36 : efrank 1.1
37 :     // Now go into loop letting person choose a kid to be the new
38 :     // location in the tree.
39 :    
40 :     unsigned int selected = 1;
41 : efrank 1.3 RecoElem* loc = recoTop;
42 : efrank 1.1
43 :     while ( -1 != selected ) {
44 :     cout << endl << "Choose number of child to expand (-1 to exit)." << endl;
45 :     cin >> selected;
46 :    
47 :     if ( (selected >= 0) && (selected < loc->getSubElements().size()) ) {
48 :     loc=&(loc->getSubElements()[selected]);
49 :     printKids( *loc );
50 :     } else if (-1 == selected) {
51 :     break;
52 :     } else {
53 :     cout << "Invalid child number." << endl;
54 :     }
55 :    
56 :     }
57 :    
58 :    
59 :     OracleMgr::mgr().endJob();
60 : efrank 1.3 delete recoTop;
61 : efrank 1.1 return 0;
62 :     }
63 :    
64 :     void
65 :     printKids( RecoElem& r ) {
66 :    
67 :     vector<RecoElem>& kids = r.getSubElements();
68 :    
69 :     vector<RecoElem>::iterator aKid = kids.begin();
70 :     vector<RecoElem>::iterator kEnd = kids.end();
71 :    
72 :     for(int i=0 ; aKid != kEnd; aKid++, i++) {
73 :    
74 : efrank 1.2 vector<Reaction> rx = aKid->getReactions();
75 : efrank 1.1 cout << i << ". " << aKid->getName() << " with " << rx.size()
76 :     << " reactions." << endl;
77 :    
78 :     for( int j=0; j<rx.size(); j++) {
79 :     vector<string>& ins =rx[j].getInputMetaboliteNames();
80 :     vector<int>& instoich =rx[j].getInputStoich();
81 :     cout << " Rx # " << rx[j].getId();
82 :     for( int k=0; k<ins.size(); k++) {
83 :     cout << " " << instoich[k] << " " << ins[k];
84 :     }
85 :    
86 :     cout << " " << rx[j].dirAsString() << " ";
87 :    
88 :     vector<string>& outs =rx[j].getOutputMetaboliteNames();
89 :     vector<int>& outstoich =rx[j].getOutputStoich();
90 :     for( int k=0; k<outs.size(); k++) {
91 :     cout << " " << outstoich[k] << " " << outs[k];
92 :     }
93 :     cout << endl;
94 :     }
95 :    
96 :     }
97 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3