-
Notifications
You must be signed in to change notification settings - Fork 2
/
pycellerator.py
103 lines (93 loc) · 3.15 KB
/
pycellerator.py
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
#
#****************************************************************************
# pycellerator converts reactions, expressed in a text-formatted arrow-based
# notation into differential equations and performs numerical simulations.
#
#****************************************************************************
#
# Copyright (C) 2012-15 Bruce E Shapiro
# 8/30/15 Set version number to 1.0 from alpha sequence for release
# on github
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
#****************************************************************************
#
import cellerator.converter
import cellerator.expander
import cellerator.interpreter
import cellerator.reader
import cellerator.solver
import cellerator.parser
import cellerator.sbml
import cellerator.flux
import sys
import subprocess
versionNumber = 1.0
#
#****************************************************************************
#
def solve():
f = cellerator.solver.makesolver()
if "-norun" in sys.argv: return
subprocess.call("python "+f, shell=True)
return
def version():
print "This is py[cellerator] version "+str(versionNumber)
return
#
#****************************************************************************
#
handlers={"EXPAND": cellerator.expander.expander,
"INTERPRET": cellerator.interpreter.interpreter,
"CONVERT": cellerator.converter.converter,
"PARSE": cellerator.parser.runpyx,
"SOLVE": solve,
"VERSION": version,
"SBML": cellerator.sbml.runsbml,
"FLUX": cellerator.flux.fat
}
#
#****************************************************************************
#
def runpycellerator(args):
if type(args)==type(""):
arguments = filter((lambda x:len(x)>0), args.split(" "))
sys.argv=[]
for arg in arguments:
sys.argv.append(arg)
else:
arguments = args
n=1
ARGS = map(lambda x:x.upper(), arguments)
# print "ARGS = ", ARGS
for option in handlers:
# print " checking ",option
if option in ARGS:
# print "option is ", option
f = handlers[option]
f()
break
n+=1
if n> len(handlers):
print "Unknown or missing py[cellerator] option reqested.\n"+\
"Valid options are:",
for opt in handlers: print opt+",",
return
#
#****************************************************************************
#
if __name__ == "__main__":
args = sys.argv
runpycellerator(args)