libSBML C API  libSBML 5.20.2 C API
Loading...
Searching...
No Matches
printUnits.c

A command-line program that prints information about the units of measurement used in a given SBML file.

A command-line program that prints information about the units of measurement used in a given SBML file.

/**
* @file printUnits.cpp
* @brief Prints some unit information about the model
* @author Sarah Keating
* @author Michael Hucka
*
* <!--------------------------------------------------------------------------
* This sample program is distributed under a different license than the rest
* of libSBML. This program uses the open-source MIT license, as follows:
*
* Copyright (c) 2013-2018 by the California Institute of Technology
* (California, USA), the European Bioinformatics Institute (EMBL-EBI, UK)
* and the University of Heidelberg (Germany), with support from the National
* Institutes of Health (USA) under grant R01GM070923. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Neither the name of the California Institute of Technology (Caltech), nor
* of the European Bioinformatics Institute (EMBL-EBI), nor of the University
* of Heidelberg, nor the names of any contributors, may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* ------------------------------------------------------------------------ -->
*/
#include <stdio.h>
#include <sbml/SBMLTypes.h>
#include <sbml/units/UnitFormulaFormatter.h>
#include <sbml/units/FormulaUnitsData.h>
int
main (int argc, char *argv[])
{
unsigned int i,j;
char* filename;
SBMLDocument_t* document;
Model_t* model;
if (argc != 2)
{
printf("\nUsage: printUnits filename\n");
return 1;
}
filename = argv[1];
document = readSBML(filename);
if (SBMLDocument_getNumErrors(document) > 0)
{
fprintf(stderr, "Encountered the following SBML errors:\n");
SBMLDocument_printErrors(document, stdout);
return 1;
}
model = SBMLDocument_getModel(document);
if (model == NULL)
{
printf("No model present.\n");
return 1;
}
for (i = 0; i < Model_getNumSpecies(model); i++)
{
Species_t* s = Model_getSpecies(model, i);
printf("Species %d: %s\n", i, u);
free(u);
}
for (i = 0; i < Model_getNumCompartments(model); i++)
{
printf("Compartment %d: %s\n", i, u);
free(u);
}
for (i = 0; i < Model_getNumParameters(model); i++)
{
printf("Parameter %d: %s\n", i, u);
free(u);
}
for (i = 0; i < Model_getNumInitialAssignments(model); i++)
{
printf("InitialAssignment %d: %s", i, u);
free(u);
printf(" undeclared units: %s",
(InitialAssignment_containsUndeclaredUnits(ia) ? "yes\n" : "no\n"));
}
for (i = 0; i < Model_getNumEvents(model); i++)
{
Event_t *e = Model_getEvent(model, i);
printf("Event %d: \n", i);
{
printf( "Delay: %s\n", u);
printf( " undeclared units: %s",
(Delay_containsUndeclaredUnits(Event_getDelay(e)) ? "yes\n" : "no\n"));
free(u);
}
for (j = 0; j < Event_getNumEventAssignments(e); j++)
{
printf( "Delay: %s\n", u);
printf( " undeclared units: %s",
(EventAssignment_containsUndeclaredUnits(ea) ? "yes\n" : "no\n"));
free(u);
}
}
for (i = 0; i < Model_getNumReactions(model); i++)
{
Reaction_t *r = Model_getReaction(model, i);
printf("Reaction %d: \n", i);
{
printf( "Kinetic Law: %s\n", u);
printf( " undeclared units: %s",
(KineticLaw_containsUndeclaredUnits(kl) ? "yes\n" : "no\n"));
free(u);
}
for (j = 0; j < Reaction_getNumReactants(r); j++)
{
{
printf( "Reactant stoichiometryMath %d: %s\n", j, u);
printf( " undeclared units: %s",
(StoichiometryMath_containsUndeclaredUnits(sm) ? "yes\n" : "no\n"));
free(u);
}
}
for (j = 0; j < Reaction_getNumProducts(r); j++)
{
{
printf( "Product stoichiometryMath %d: %s\n", j, u);
printf( " undeclared units: %s",
(StoichiometryMath_containsUndeclaredUnits(sm) ? "yes\n" : "no\n"));
free(u);
}
}
}
for (i = 0; i < Model_getNumRules(model); i++)
{
Rule_t *r = Model_getRule(model, i);
printf( "Rule %d: %s\n", i, u);
printf( " undeclared units: %s",
(Rule_containsUndeclaredUnits(r) ? "yes\n" : "no\n"));
free(u);
}
SBMLDocument_free(document);
return 0;
}
UnitDefinition_t * Compartment_getDerivedUnitDefinition(Compartment_t *c)
_tConstructs_t _tand_t _treturns_t _ta_t _tUnitDefinition_t _tthat_t _tcorresponds_t _tto_t _tthe_t _...
Definition Compartment.cpp:2457
UnitDefinition_t * Delay_getDerivedUnitDefinition(Delay_t *d)
_tCalculates_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tthat_t _texpresses_t _tthe_t _tunits_...
Definition Delay.cpp:935
int Delay_containsUndeclaredUnits(Delay_t *d)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition Delay.cpp:943
Delay_t * Event_getDelay(Event_t *e)
_tTakes_t _tan_t _tEvent_t_t _tstructure_t _tand_t _treturns_t _tits_t _tDelay_t_t _tstructure_t.
Definition Event.cpp:2401
unsigned int Event_getNumEventAssignments(const Event_t *e)
_tReturns_t _tthe_t _tnumber_t _tof_t _tEventAssignment_t_t _tstructures_t _tattached_t _tto_t _tthe_...
Definition Event.cpp:2719
EventAssignment_t * Event_getEventAssignment(Event_t *e, unsigned int n)
_tReturn_t _ta_t _tspecific_t _tEventAssignment_t_t _tstructure_t _tof_t _tthe_t _tgiven_t _tEvent_t_...
Definition Event.cpp:2702
int Event_isSetDelay(const Event_t *e)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition Event.cpp:2457
int EventAssignment_containsUndeclaredUnits(EventAssignment_t *ea)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition EventAssignment.cpp:1368
UnitDefinition_t * EventAssignment_getDerivedUnitDefinition(EventAssignment_t *ea)
_tCalculates_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tthat_t _texpresses_t _tthe_t _tunits_...
Definition EventAssignment.cpp:1360
UnitDefinition_t * InitialAssignment_getDerivedUnitDefinition(InitialAssignment_t *ia)
_tCalculates_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tthat_t _texpresses_t _tthe_t _tunits_...
Definition InitialAssignment.cpp:1342
int InitialAssignment_containsUndeclaredUnits(InitialAssignment_t *ia)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition InitialAssignment.cpp:1350
UnitDefinition_t * KineticLaw_getDerivedUnitDefinition(KineticLaw_t *kl)
_tCalculates_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tthat_t _texpresses_t _tthe_t _tunits_...
Definition KineticLaw.cpp:2293
int KineticLaw_containsUndeclaredUnits(KineticLaw_t *kl)
_tPredicate_t _treturning_t @_tc_t _ttrue_t _tor_t @_tc_t _tfalse_t _tdepending_t _ton_t _twhether_t ...
Definition KineticLaw.cpp:2301
unsigned int Model_getNumEvents(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tEvent_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t_t _ts...
Definition Model.cpp:8213
Event_t * Model_getEvent(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tEvent_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tModel_t_t ...
Definition Model.cpp:8102
unsigned int Model_getNumReactions(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tReaction_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t_t ...
Definition Model.cpp:8205
unsigned int Model_getNumParameters(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tParameter_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t_t...
Definition Model.cpp:8174
Compartment_t * Model_getCompartment(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tCompartment_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tMode...
Definition Model.cpp:7990
unsigned int Model_getNumRules(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tRule_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t_t _tst...
Definition Model.cpp:8190
unsigned int Model_getNumCompartments(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tCompartment_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t...
Definition Model.cpp:8150
unsigned int Model_getNumSpecies(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tSpecies_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t_t _...
Definition Model.cpp:8158
Reaction_t * Model_getReaction(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tReaction_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tModel_t...
Definition Model.cpp:8078
Rule_t * Model_getRule(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tRule_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tModel_t_t _...
Definition Model.cpp:8054
Parameter_t * Model_getParameter(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tParameter_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tModel_...
Definition Model.cpp:8022
InitialAssignment_t * Model_getInitialAssignment(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tInitialAssignment_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t ...
Definition Model.cpp:8038
unsigned int Model_getNumInitialAssignments(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tInitialAssignment_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tM...
Definition Model.cpp:8182
Species_t * Model_getSpecies(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tSpecies_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tModel_t_...
Definition Model.cpp:8006
UnitDefinition_t * Parameter_getDerivedUnitDefinition(Parameter_t *p)
_tConstructs_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tstructure_t _tthat_t _texpresses_t _t...
Definition Parameter.cpp:2187
SpeciesReference_t * Reaction_getReactant(Reaction_t *r, unsigned int n)
@_treturn_t _tthe_t _tnth_t _treactant_t (_tSpeciesReference_t_t) _tof_t _tthis_t _tReaction_t_t.
Definition Reaction.cpp:3054
SpeciesReference_t * Reaction_getProduct(Reaction_t *r, unsigned int n)
@_treturn_t _tthe_t _tnth_t _tproduct_t (_tSpeciesReference_t_t) _tof_t _tthis_t _tReaction_t_t.
Definition Reaction.cpp:3070
int Reaction_isSetKineticLaw(const Reaction_t *r)
@_treturn_t @_tc_t _t1_t (_ttrue_t) _tif_t _tthe_t _tKineticLaw_t_t _tof_t _tthis_t _tReaction_t_t _t...
Definition Reaction.cpp:2754
unsigned int Reaction_getNumReactants(const Reaction_t *r)
@_treturn_t _tthe_t _tnumber_t _tof_t _treactants_t (_tSpeciesReference_t_t'_ts_t) _tin_t _tthis_t _t...
Definition Reaction.cpp:3101
KineticLaw_t * Reaction_getKineticLaw(Reaction_t *r)
@_treturn_t _tthe_t _tKineticLaw_t_t _tof_t _tthis_t _tReaction_t_t.
Definition Reaction.cpp:2705
unsigned int Reaction_getNumProducts(const Reaction_t *r)
@_treturn_t _tthe_t _tnumber_t _tof_t _tproducts_t (_tSpeciesReference_t_t'_ts_t) _tin_t _tthis_t _tR...
Definition Reaction.cpp:3109
int Rule_containsUndeclaredUnits(Rule_t *r)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition Rule.cpp:2209
UnitDefinition_t * Rule_getDerivedUnitDefinition(Rule_t *r)
_tCalculates_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tthat_t _texpresses_t _tthe_t _tunits_...
Definition Rule.cpp:2201
void SBMLDocument_printErrors(SBMLDocument_t *d, FILE *stream)
_tPrints_t _tto_t _tthe_t _tgiven_t _toutput_t _tstream_t _tall_t _tthe_t _terrors_t _tor_t _twarning...
Definition SBMLDocument.cpp:2525
unsigned int SBMLDocument_getNumErrors(const SBMLDocument_t *d)
_tReturns_t _tthe_t _tnumber_t _tof_t _terrors_t _tor_t _twarnings_t _tencountered_t _tduring_t _tpar...
Definition SBMLDocument.cpp:2510
void SBMLDocument_free(SBMLDocument_t *d)
_tFrees_t _tthe_t _tgiven_t _tSBMLDocument_t_t _tstructure_t.
Definition SBMLDocument.cpp:2248
Model_t * SBMLDocument_getModel(SBMLDocument_t *d)
_tReturns_t _tthe_t _tModel_t_t _tstructure_t _tstored_t _tin_t _tthis_t _tSBMLDocument_t_t _tstructu...
Definition SBMLDocument.cpp:2290
SBMLDocument_t * readSBML(const char *filename)
@_tcopydoc_t _tdoc_readsbmlfromfile_t
Definition SBMLReader.cpp:446
Include all SBML types in a single header file.
UnitDefinition_t * Species_getDerivedUnitDefinition(Species_t *s)
_tConstructs_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tstructure_t _tthat_t _texpresses_t _t...
Definition Species.cpp:3177
StoichiometryMath_t * SpeciesReference_getStoichiometryMath(SpeciesReference_t *sr)
_tGet_t _tthe_t _tcontent_t _tof_t _tthe_t "_tstoichiometryMath_t" _tsubelement_t _tof_t _tthe_t _tgi...
Definition SpeciesReference.cpp:1960
int SpeciesReference_isSetStoichiometryMath(const SpeciesReference_t *sr)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition SpeciesReference.cpp:2026
int StoichiometryMath_containsUndeclaredUnits(StoichiometryMath_t *stoichMath)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition StoichiometryMath.cpp:732
UnitDefinition_t * StoichiometryMath_getDerivedUnitDefinition(StoichiometryMath_t *stoichMath)
_tCalculates_t _tand_t _treturns_t _ta_t _tUnitDefinition_t_t _tthat_t _texpresses_t _tthe_t _tunits_...
Definition StoichiometryMath.cpp:722
char * UnitDefinition_printUnits(UnitDefinition_t *ud, int compact)
_tExpresses_t _tthe_t _tgiven_t _tdefinition_t _tin_t _ta_t _tplain_t-_ttext_t _tform_t.
Definition UnitDefinition.cpp:2626
Definitions of UnitDefinition_t and ListOfUnitDefinitions_t.