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

View of /MExplorer/xduGen.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri Dec 20 20:12:20 2002 UTC (16 years, 11 months ago) by efrank
Branch: MAIN
Branch point for: local
Initial revision

//************************************************************************
// 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/EFRecoElemImpl.hh"
#include "RecoReadoutOracle/OracleMgr.hh"

int  xduGen( RecoElem& r, std::string path );
void editName( std::string& s );

//************************************************************************
int
main(int argc, char* arg[] ) {
//************************************************************************

  // 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();
  RecoElem recoTop( new EFRecoElemImpl(  "Top of Everything", 20000 ));

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

  std::string path="";
  xduGen( recoTop, path );

  return 0;
}

//************************************************************************
int
xduGen( RecoElem& r, std::string path ) {
//************************************************************************
  int         result  = 0;
  std::string s;

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

  s=r.getName();		// copy so we don't mod the orig
  editName( s );		// xdu has bugs.  must mod the name a little
  if ( 0 == nKid ) {
    cout << "1 " << path << "/" << s << endl;
    return 1;
  } else {
    for (int i=0; i<nKid; i++ ) {
      result += xduGen( kids[i], path+"/"+s );
    }
    cout << result << " " << path+"/"+s << endl;
    return result;
  }  
}

//************************************************************************
void
editName( std::string& s ) {
//************************************************************************
  // xdu chokes on name with spaces in them.  Replace them with
  // underscores.  hack hack hack

  int l=s.size();
  for( int i=0; i<l; i++) {
    if ( s[i] == ' ' ) s[i] = '_';
  }
  
  return;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3