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

View of /MExplorer/xduGen.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Fri Mar 7 23:10:00 2003 UTC (16 years, 9 months ago) by efrank
Branch: MAIN
CVS Tags: ldrd-2003-01, HEAD
Changes since 1.2: +0 -43 lines
rats.  forgot to add file xduGenMain.cc to the commit...

split old xduGen, which was main() plus xduGen() into two files so that
xduGen() can be used by other progs.

//************************************************************************
// 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"

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


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