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

View of /MExplorer/MExplorer.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Thu May 8 18:11:53 2003 UTC (16 years, 5 months ago) by efrank
Branch: MAIN
CVS Tags: ldrd-2003-01, HEAD
Changes since 1.2: +6 -4 lines
Migrate RecoElem to not use RecoElemImpl

//************************************************************************
// Play with exploring the e. coli reco in biosimscratch.
//
//************************************************************************

#include <string>
#include <vector>
#include <iterator>

#include "RecoReadout/RecoElem.hh"
#include "RecoReadout/Reaction.hh"

#include "RecoReadoutOracle/OracleMgr.hh"
#include "RecoReadoutOracle/BssFactory.hh"

void printKids( RecoElem& r );

int
main(int argc, char* arg[] ) {
  cout << "A creepy feeling comes over you..." << endl;
  cout << "It wakes." << endl;

  // Normally, we'd consult a Reco dictionary to find a reco we cared
  // about.  But that's not built yet.  So, I'm going to cook up
  // the top of a reconstruction I know is in the database.  In real
  // life, you'd peruse the dictionary and just be handed a RecoElem
  // to mess with.

  OracleMgr::mgr().startJob();
  BssFactory  bssFactory;
  RecoElem* recoTop = bssFactory.getRecoElemById( 10000 );

  // OK.  Mess with it.  Get its kids and print them out.

  printKids( *recoTop );

  // Now go into loop letting person choose a kid to be the new
  // location in the tree.

  unsigned int selected = 1;
  RecoElem* loc = recoTop;

  while ( -1 != selected ) {
    cout << endl << "Choose number of child to expand (-1 to exit)." << endl;
    cin >> selected;

    if ( (selected >= 0) && (selected < loc->getSubElements().size()) ) {
      loc=&(loc->getSubElements()[selected]);
      printKids( *loc );
    } else if (-1 == selected) {
      break;
    } else {
      cout << "Invalid child number." << endl;
    }

  }


  OracleMgr::mgr().endJob();
  delete recoTop;
  return 0;
}

void
printKids( RecoElem& r ) {

  vector<RecoElem>& kids = r.getSubElements();

  vector<RecoElem>::iterator aKid = kids.begin();
  vector<RecoElem>::iterator kEnd   = kids.end();

  for(int i=0 ;  aKid != kEnd; aKid++, i++) {

    vector<Reaction> rx = aKid->getReactions();
    cout << i << ". " << aKid->getName() << " with " << rx.size()
	 << " reactions." << endl;

    for( int j=0; j<rx.size(); j++) {
      vector<string>& ins =rx[j].getInputMetaboliteNames();
      vector<int>&  instoich =rx[j].getInputStoich();
      cout << "   Rx # " << rx[j].getId();
      for( int k=0; k<ins.size(); k++) {
	cout << "  " << instoich[k] << " " << ins[k];
      }

      cout << " " << rx[j].dirAsString()  << " ";

      vector<string>& outs =rx[j].getOutputMetaboliteNames();
      vector<int>&  outstoich =rx[j].getOutputStoich();
      for( int k=0; k<outs.size(); k++) {
	cout << "  " << outstoich[k] << " " <<  outs[k];
      }
      cout << endl;
    }

  }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3