[Bio] / RecoElemSBW / SBMLtoRecoElem.cc Repository:
ViewVC logotype

Diff of /RecoElemSBW/SBMLtoRecoElem.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Thu May 8 18:12:11 2003 UTC revision 1.4, Thu May 22 19:25:22 2003 UTC
# Line 1  Line 1 
1  #include <stdio.h>  #include <stdio.h>
2  #include <string>  #include <string>
 #include <vector>  
 #include <set>  
 #include <iterator>  
 #include <fstream>  
 #include <iostream>  
 #include <sys/timeb.h>  
3    
4  #include "RecoReadout/RecoElem.hh"  #include "RecoReadout/RecoElem.hh"
5  #include "RecoReadout/Reaction.hh"  #include "RecoReadout/Reaction.hh"
6  #include "MExplorer/xduGen.hh"  #include "MExplorer/xduGen.hh"
7    
8  #include "sbml/SBMLReader.h"  #include "RecoElemSBW/SbmlFactory.hh"
9  #include "sbml/SBMLTypes.h"  
10    
11    
12  using namespace std;  using namespace std;
13    
14  //************************************************************************  //************************************************************************
   
   
 RecoElem* SBMLtoRecoElem(Model_t* m);  
 void inreaction(Reaction_t* r, vector<Reaction>& rxns);  
15  void printList (RecoElem& elem);  void printList (RecoElem& elem);
16  //************************************************************************  //************************************************************************
17    
# Line 34  Line 24 
24  //************************************************************************  //************************************************************************
25    
26    
27    SBMLDocument_t *d;    if (argc != 2) {
   Model_t *m;  
   
   if (argc != 2)  
   {  
28      printf("usage: readSBML <filename>\n");      printf("usage: readSBML <filename>\n");
29      return 1;      return 1;
30    }    }
31    
32    
33    d     = readSBML(argv[1]);    RecoElem* elem = SbmlFactory( argv[1] );
   
   m = d->model;  
   if (0==m) {  
     cout << "Did not read model " << argv[1] << endl;  
     exit( 1 );  
   }  
   
   RecoElem* elem = SBMLtoRecoElem (m);  
34    
35    cout << "************************" << endl;    cout << "************************" << endl;
36    printList(*elem);    printList(*elem);
# Line 98  Line 76 
76    
77    return;    return;
78  }  }
   
   
   
   
   
 //**********************************************************************  
 RecoElem*  
 SBMLtoRecoElem(Model_t* m) {  
 //************************************************************************  
   
   string name;  
   int id, numreactant, numproduct;  
   
   Reaction_t* r;  
   Species_t* s;  
   List_t* rlist = m->reaction;  
   
   
   //not sure what to put as an id, 0 for now  
   name=m->name;  
   id=0;  
   
   RecoElem* elem= new RecoElem( name, id);  
   
   vector<Reaction>& rxns      = elem->getReactions();  
   
   
   //put in reactions  
   int reactionsize= List_size(rlist);  
   //cout << "number of reactions " << reactionsize << endl;  
   
   
   
   for (int j=0; j< reactionsize ; j++)  
     {  
   
       //  cout << "Reaction : " << j <<endl;  
       r=Model_getReaction(m,j);  
       //cout << r->name << endl;  
       inreaction(r,rxns);  
   
       // cout << endl;  
     }  
   
   
   return elem;  
   
   
 }  
 //************************************************************************  
 void  
 inreaction(Reaction_t* r, vector<Reaction>& rxns) {  
 //************************************************************************  
   
   int id;  
   int dir;  
   
   int numreactant=Reaction_getNumReactants(r);  
   int numproduct=Reaction_getNumProducts(r);  
   SpeciesReference_t* sr, *pr;  
   
   //id not sure what to put here  
   //direction is reversible  or not. false, true  
   
   Reaction::Direction reDir;  
   id=0;  
   dir=r->reversible;  
   Reaction rxn( id, Reaction::forward );  
   if ( dir ) {  
     rxn.setDirection( Reaction::both );  
   }  
   
   vector<string>& reactant = rxn.getInputMetaboliteNames();  
   vector<string>& product  = rxn.getOutputMetaboliteNames();  
   
   vector<int>& inMetabN = rxn.getInputStoich();  
   vector<int>& outMetabN = rxn.getOutputStoich();  
   
   //add reactants  
   //add products  
   
   
   
   //figuring out the common denominator  
   int rdem = 1;  
   int pdem = 1;  
   int demstoich;  
   
   for (int j=0; j< numreactant ; j++ )  
     {  
       sr=Reaction_getReactant(r,j);  
       rdem= rdem * sr->denominator;  
   
     }  
   
   
   for (int m=0; m<numproduct; m++)  
     {  
       pr=Reaction_getProduct(r,m);  
       pdem= pdem * pr->denominator;  
   
     }  
   
   
   demstoich = rdem * pdem;  
   //  cout << "common denominator: " << demstoich;  
   
    for (int k=0; k < numreactant ; k++ )  
          {  
            sr=Reaction_getReactant(r,k);  
            // cout << "test reactant: " << sr->species << endl;  
   
   
            reactant.push_back (sr->species);  
            inMetabN.push_back( demstoich * sr->stoichiometry/sr->denominator);  
          }  
   
    //cout << rxn.asString()[0];  
   
    for (int l=0; l<numproduct; l++)  
          {  
   
            pr=Reaction_getProduct(r,l);  
            //  cout << "product: " << pr->species  << endl;  
   
            product.push_back(pr->species);  
            outMetabN.push_back(demstoich * pr->stoichiometry/ pr->denominator );  
          }  
   
    rxns.push_back(rxn);  
   
   return;  
 }  

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3