1 /**
2  * @file    promoteParameters.c
3  * @brief   promotes all local to global paramters
4  * @author  Frank T. Bergmann
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 
42 #include <stdio.h>
43 #include <sbml/SBMLTypes.h>
44 #include <sbml/conversion/ConversionProperties.h>
45 
46 
47 int
main(int argc,char * argv[])48   main (int argc, char *argv[])
49 {
50   SBMLDocument_t *doc;
51 
52   if (argc != 3)
53   {
54     printf("Usage: promoteParameters input-filename output-filename\n");
55     return 2;
56   }
57 
58   doc = readSBML(argv[1]);
59 
60   if (SBMLDocument_getNumErrorsWithSeverity(doc, LIBSBML_SEV_ERROR) > 0)
61   {
62     SBMLDocument_printErrors(doc, stderr);
63   }
64   else
65   {
66     /* need new variables ... */
67     ConversionProperties_t* props;
68     ConversionOption_t* option1;
69 
70     /* create a new conversion properties structure */
71     props = ConversionProperties_create();
72 
73     /* add an option that we want to convert parameters */
74     option1 = ConversionOption_create("promoteLocalParameters");
75     ConversionOption_setType(option1, CNV_TYPE_BOOL);
76     ConversionOption_setValue(option1, "true");
77     ConversionOption_setDescription(option1, "Promotes all Local Parameters to Global ones");
78     ConversionProperties_addOption(props, option1);
79     ConversionOption_free(option1);
80 
81     /* perform the conversion */
82     if (SBMLDocument_convert(doc, props) != LIBSBML_OPERATION_SUCCESS)
83     {
84       printf ("conversion failed ... ");
85       return 3;
86     }
87 
88     /* successfully completed, write the resulting file */
89     writeSBML(doc, argv[2]);
90     ConversionProperties_free(props);
91   }
92 
93   SBMLDocument_free(doc);
94   return 0;
95 }
96 
97