libSBML Python API  5.18.0
readSBML.py

A simple command-line program that reads an SBML file and prints some statistics about it.

1 #!/usr/bin/env python
2 ##
3 ## @file readSBML.py
4 ## @brief Similar to validateSBML, but without the validation
5 ## @author Sarah Keating
6 ## @author Ben Bornstein
7 ##
8 ## <!--------------------------------------------------------------------------
9 ## This sample program is distributed under a different license than the rest
10 ## of libSBML. This program uses the open-source MIT license, as follows:
11 ##
12 ## Copyright (c) 2013-2018 by the California Institute of Technology
13 ## (California, USA), the European Bioinformatics Institute (EMBL-EBI, UK)
14 ## and the University of Heidelberg (Germany), with support from the National
15 ## Institutes of Health (USA) under grant R01GM070923. All rights reserved.
16 ##
17 ## Permission is hereby granted, free of charge, to any person obtaining a
18 ## copy of this software and associated documentation files (the "Software"),
19 ## to deal in the Software without restriction, including without limitation
20 ## the rights to use, copy, modify, merge, publish, distribute, sublicense,
21 ## and/or sell copies of the Software, and to permit persons to whom the
22 ## Software is furnished to do so, subject to the following conditions:
23 ##
24 ## The above copyright notice and this permission notice shall be included in
25 ## all copies or substantial portions of the Software.
26 ##
27 ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28 ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29 ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30 ## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31 ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32 ## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33 ## DEALINGS IN THE SOFTWARE.
34 ##
35 ## Neither the name of the California Institute of Technology (Caltech), nor
36 ## of the European Bioinformatics Institute (EMBL-EBI), nor of the University
37 ## of Heidelberg, nor the names of any contributors, may be used to endorse
38 ## or promote products derived from this software without specific prior
39 ## written permission.
40 ## ------------------------------------------------------------------------ -->
41 
42 import sys
43 import time
44 import os
45 import os.path
46 from libsbml import *
47 
48 def main (args):
49  """Usage: readSBML filename
50  """
51 
52  if len(args) != 2:
53  print("Usage: readSBML filename")
54  return 1
55 
56  filename = args[1]
57  current = time.clock()
58  document = readSBML(filename)
59 
60  errors = document.getNumErrors()
61 
62  print()
63  print(" filename: " + filename)
64  print(" file size: " + str(os.stat(filename).st_size))
65  print(" read time (ms): " + str(time.clock() - current))
66  print(" validation error(s): " + str(errors))
67  print()
68  document.printErrors()
69 
70  return errors
71 
72 
73 if __name__ == '__main__':
74  main(sys.argv)