-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreadFluxMLModel.cpp
141 lines (121 loc) · 4.65 KB
/
readFluxMLModel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <iostream>
#include <fluxml/FluxML.h>
#include <fluxml/MGroup.h>
#include <fluxml/MMDocument.h>
#include <fluxml/XMLFramework.h>
using namespace std;
using namespace flux;
std::string make_section_head(const std::string& section_name)
{
std::string line(80, '=');
std::string fill((line.length() - section_name.length()) / 2, ' ');
std::string header = line + "\n" + fill + section_name + "\n" + line;
return header;
}
int main(int argc, char* argv[])
{
/** check number of specified arguments **/
if (argc != 2)
{
cout << endl << "Usage: readFluxML filename" << endl << endl;
return 1;
}
/** make sure error Messages go somewhere **/
PUBLISHLOG(stderr_log);
const char* filename = argv[1];
xml::FluxMLDocument * fml = 0;
try
{
fml = new xml::FluxMLDocument(filename);
}
catch (xml::XMLException& e)
{
cerr << "Problem with opening File " << filename << ":" << endl << e.toString() << endl;
exit(1);
}
cout << make_section_head("metabolites") << endl;
/** print network metabolites **/
charptr_map<data::Pool*> * poolMap = fml->getPoolMap();
charptr_map<data::Pool*>::const_iterator pi;
for (pi = poolMap->begin(); pi != poolMap->end(); ++pi)
{
data::Pool* pool = pi->value;
cout << "pool: " << pool->getName() << "\t atoms: "
<< pool->getNumAtoms() << endl;
}
/** print network reactions **/
cout << endl << make_section_head("reactions") << endl;
const std::list<data::IsoReaction*>* reactionList = fml->getReactions();
std::list<data::IsoReaction*>::const_iterator ri;
for (ri = reactionList->begin(); ri != reactionList->end(); ++ri)
{
data::IsoReaction* reaction = *ri;
cout << "reaction: " << reaction->getName() << "\t atoms: "
<< reaction->getNumAtoms() << endl;
/** print reaction educts **/
const std::list<data::IsoReaction::Isotopomer*> educts =
reaction->getEducts();
std::list<data::IsoReaction::Isotopomer*>::const_iterator ei;
for (ei = educts.begin(); ei != educts.end(); ++ei)
cout << "educt-name: " << (*ei)->name << "\t educt-cfg: "
<< (*ei)->atom_cfg << endl;
/** print reaction products **/
const std::list<data::IsoReaction::Isotopomer*> products =
reaction->getProducts();
for (ei = products.begin(); ei != products.end(); ++ei)
cout << "educt-name: " << (*ei)->name << "\t educt-cfg: "
<< (*ei)->atom_cfg << endl;
}
cout << endl << make_section_head("configuration default") << endl;
/** select "default" configuration**/
data::Configuration * cfg = fml->getConfiguration("default");
if (cfg == 0)
{
fWARNING("aborting: \"default\" configuration not found.");
delete fml;
xml::framework::terminate();
return EXIT_FAILURE;
}
cout << endl << make_section_head("constraints") << endl;
/** print model constraints **/
charptr_array cons;
charptr_array::const_iterator consi;
/** netflux constraints **/
cons = cfg->getConstraintFluxesNet();
for (consi = cons.begin(); consi != cons.end(); ++consi)
cout << "net: " << *consi << endl;
/** xchflux constraints **/
cons = cfg->getConstraintFluxesXch();
for (consi = cons.begin(); consi != cons.end(); ++consi)
cout << "xch: " << *consi << endl;
/** poolsize constraints **/
cons = cfg->getConstraintPools();
for (consi = cons.begin(); consi != cons.end(); ++consi)
cout << "pool: " << *consi << endl;
cout << endl << make_section_head("input tracers") << endl;
/** print tracer specification **/
list<data::InputPool*> const & IPL = cfg->getInputPools();
list<data::InputPool*>::const_iterator ip;
cout << "tracers: " << endl;
for (ip = IPL.begin(); ip != IPL.end(); ++ip)
{
data::InputPool & I = *(*ip);
cout << "pool: " << I.getName() << "\t cost: " << I.getCost() << endl;
}
cout << endl << make_section_head("measurement data") << endl;
/** print experimental data **/
xml::MMDocument * mmdoc = 0;
mmdoc = cfg->getMMDocument();
charptr_array mgroup_names = mmdoc->getGroupNames();
charptr_array::const_iterator mgi;
for (mgi = mgroup_names.begin(); mgi != mgroup_names.end(); mgi++)
{
xml::MGroup * mgroups = mmdoc->getGroupByName(*mgi);
cout << "group-id: " << mgroups->getGroupId() << "\t group-spec: "
<< mgroups->getSpec() << endl;
}
/** free allocated memory **/
delete fml;
xml::framework::terminate();
return EXIT_SUCCESS;
}