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

Annotation of /MExplorer/MExplorer.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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/EFRecoElemImpl.hh"
14 :     #include "RecoReadoutOracle/OracleMgr.hh"
15 :    
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 :     RecoElem recoTop( new EFRecoElemImpl( "E. coli top", 10000) );
31 :    
32 :     // OK. Mess with it. Get its kids and print them out.
33 :    
34 :     printKids( recoTop );
35 :    
36 :     // Now go into loop letting person choose a kid to be the new
37 :     // location in the tree.
38 :    
39 :     unsigned int selected = 1;
40 :     RecoElem* loc = &recoTop;
41 :    
42 :     while ( -1 != selected ) {
43 :     cout << endl << "Choose number of child to expand (-1 to exit)." << endl;
44 :     cin >> selected;
45 :    
46 :     if ( (selected >= 0) && (selected < loc->getSubElements().size()) ) {
47 :     loc=&(loc->getSubElements()[selected]);
48 :     printKids( *loc );
49 :     } else if (-1 == selected) {
50 :     break;
51 :     } else {
52 :     cout << "Invalid child number." << endl;
53 :     }
54 :    
55 :     }
56 :    
57 :    
58 :     OracleMgr::mgr().endJob();
59 :     return 0;
60 :     }
61 :    
62 :     void
63 :     printKids( RecoElem& r ) {
64 :    
65 :     vector<RecoElem>& kids = r.getSubElements();
66 :    
67 :     vector<RecoElem>::iterator aKid = kids.begin();
68 :     vector<RecoElem>::iterator kEnd = kids.end();
69 :    
70 :     for(int i=0 ; aKid != kEnd; aKid++, i++) {
71 :    
72 : efrank 1.2 vector<Reaction> rx = aKid->getReactions();
73 : efrank 1.1 cout << i << ". " << aKid->getName() << " with " << rx.size()
74 :     << " reactions." << endl;
75 :    
76 :     for( int j=0; j<rx.size(); j++) {
77 :     vector<string>& ins =rx[j].getInputMetaboliteNames();
78 :     vector<int>& instoich =rx[j].getInputStoich();
79 :     cout << " Rx # " << rx[j].getId();
80 :     for( int k=0; k<ins.size(); k++) {
81 :     cout << " " << instoich[k] << " " << ins[k];
82 :     }
83 :    
84 :     cout << " " << rx[j].dirAsString() << " ";
85 :    
86 :     vector<string>& outs =rx[j].getOutputMetaboliteNames();
87 :     vector<int>& outstoich =rx[j].getOutputStoich();
88 :     for( int k=0; k<outs.size(); k++) {
89 :     cout << " " << outstoich[k] << " " << outs[k];
90 :     }
91 :     cout << endl;
92 :     }
93 :    
94 :     }
95 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3