forked from MacPython/terryfy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_prog.py
42 lines (33 loc) · 1 KB
/
test_prog.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
#!/usr/bin/env python
import sys
import os.path
import libsbml
def main (args):
"""usage: echoSBML.py input-filename output-filename
"""
if len(args) != 3:
print(main.__doc__)
sys.exit(1)
infile = args[1]
outfile = args[2]
if not os.path.exists(infile):
print("[Error] %s : No such file." % (infile))
sys.exit(1)
reader = libsbml.SBMLReader()
writer = libsbml.SBMLWriter()
sbmldoc = reader.readSBML(infile)
if sbmldoc.getNumErrors() > 0:
if sbmldoc.getError(0).getErrorId() == libsbml.XMLFileUnreadable:
# Handle case of unreadable file here.
sbmldoc.printErrors()
elif sbmldoc.getError(0).getErrorId() == libsbml.XMLFileOperationError:
# Handle case of other file error here.
sbmldoc.printErrors()
else:
# Handle other error cases here.
sbmldoc.printErrors()
sys.exit(1)
writer.writeSBML(sbmldoc, outfile)
print("[OK] Echoed %s to %s" % (infile, outfile))
if __name__ == '__main__':
main(sys.argv)