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

View of /MExplorer/xduGen.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Mon Jan 6 23:32:23 2003 UTC (16 years, 10 months ago) by efrank
Branch: MAIN
CVS Tags: V00-00-00
Changes since 1.1: +33 -10 lines

xduGen.cc:
	modify to take an arg (mandatory) that says what process node to start with when dumping

lsCatDb.pcc
	guts of lsCat.  lists the reco catalog.  separated from lsCat itself to simplify
	the makefile.

xduViz
	script to call xduGen followed by invocation of xdu.  takes xdu from ~efrank
	since it is not installed. all hardwired.  gasp.

lsCatdb.pcc
	removed in favor of lsCatDb.pcc so that filename matches function name.

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

#include <stdio.h>
#include <string>
#include <vector>
#include <iterator>

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

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

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

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

  if ( 2 != argc ) {
    usage();
    return 1;
  }

  unsigned int topNodeId = atoi( argv[1] );
  cout << "going for node " << topNodeId << endl;


  OracleMgr::mgr().startJob();
  RecoElem recoTop( new EFRecoElemImpl(  "FoobieBletch", topNodeId ));

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

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

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

//************************************************************************
void
usage( void ) {
//************************************************************************
  cout << endl;
  cout << "usage: xduGen TopNodeId" << endl;
  cout << "   TopNodeId is the ProcessId of the top of the reconstruction." << endl;
  cout << "   You can find the top node of a reconstruction with lsCat," << endl;
  cout << "   which lists the Catalog." << endl;
  cout << endl;

  return;
}

int
xduGen( RecoElem& r, std::string path ) {
//************************************************************************
  int         result  = 0;
  std::string s;
  enum        {MaxDigits = 32};
  char        idAsStr[32];

  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 << "[" << r.getId() << "]" << endl;
    return 1;
  } else {
    for (int i=0; i<nKid; i++ ) {
      snprintf(idAsStr, MaxDigits, "%d", r.getId() );
      result += xduGen( kids[i], path + "/" + s + "[" + idAsStr + "]" );
    }
    cout << result << " " << path << "/" << s << "[" <<  r.getId() << "]" 
	 << 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