1 /**
2  * @file    printSBML.c
3  * @brief   Prints some information about the top-level model
4  * @author  Ben Bornstein
5  *
6  * <!--------------------------------------------------------------------------
7  * This sample program is distributed under a different license than the rest
8  * of libSBML.  This program uses the open-source MIT license, as follows:
9  *
10  * Copyright (c) 2013-2018 by the California Institute of Technology
11  * (California, USA), the European Bioinformatics Institute (EMBL-EBI, UK)
12  * and the University of Heidelberg (Germany), with support from the National
13  * Institutes of Health (USA) under grant R01GM070923.  All rights reserved.
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining a
16  * copy of this software and associated documentation files (the "Software"),
17  * to deal in the Software without restriction, including without limitation
18  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19  * and/or sell copies of the Software, and to permit persons to whom the
20  * Software is furnished to do so, subject to the following conditions:
21  *
22  * The above copyright notice and this permission notice shall be included in
23  * all copies or substantial portions of the Software.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31  * DEALINGS IN THE SOFTWARE.
32  *
33  * Neither the name of the California Institute of Technology (Caltech), nor
34  * of the European Bioinformatics Institute (EMBL-EBI), nor of the University
35  * of Heidelberg, nor the names of any contributors, may be used to endorse
36  * or promote products derived from this software without specific prior
37  * written permission.
38  * ------------------------------------------------------------------------ -->
39  */
40 
41 #include <stdio.h>
42 #include <sbml/SBMLTypes.h>
43 
44 
45 int
main(int argc,char * argv[])46 main (int argc, char *argv[])
47 {
48   const char *filename;
49 
50   SBMLDocument_t *d;
51   Model_t        *m;
52 
53   unsigned int level, version;
54 
55 
56   if (argc != 2)
57   {
58     printf("Usage: printSBML filename\n");
59     return 2;
60   }
61 
62 
63   filename = argv[1];
64   d        = readSBML(filename);
65 
66   SBMLDocument_printErrors(d, stdout);
67 
68   m = SBMLDocument_getModel(d);
69 
70   level   = SBMLDocument_getLevel  (d);
71   version = SBMLDocument_getVersion(d);
72 
73   printf("\n");
74   printf("File: %s (Level %u, version %u)\n", filename, level, version);
75 
76   if (m == NULL)
77   {
78     printf("No model present.");
79     return 1;
80   }
81 
82   printf("         ");
83   printf("  model id: %s\n",  Model_isSetId(m) ? Model_getId(m) : "(empty)");
84 
85   printf( "functionDefinitions: %d\n",  Model_getNumFunctionDefinitions(m) );
86   printf( "    unitDefinitions: %d\n",  Model_getNumUnitDefinitions    (m) );
87   printf( "   compartmentTypes: %d\n",  Model_getNumCompartmentTypes   (m) );
88   printf( "        specieTypes: %d\n",  Model_getNumSpeciesTypes       (m) );
89   printf( "       compartments: %d\n",  Model_getNumCompartments       (m) );
90   printf( "            species: %d\n",  Model_getNumSpecies            (m) );
91   printf( "         parameters: %d\n",  Model_getNumParameters         (m) );
92   printf( " initialAssignments: %d\n",  Model_getNumInitialAssignments (m) );
93   printf( "              rules: %d\n",  Model_getNumRules              (m) );
94   printf( "        constraints: %d\n",  Model_getNumConstraints        (m) );
95   printf( "          reactions: %d\n",  Model_getNumReactions          (m) );
96   printf( "             events: %d\n",  Model_getNumEvents             (m) );
97   printf( "\n" );
98 
99   SBMLDocument_free(d);
100   return 0;
101 }
102 
103