libSBML C API  libSBML 5.20.4 C API
Loading...
Searching...
No Matches
printAnnotation.c

Prints the annotation strings for each element in a given model.

Prints the annotation strings for each element in a given model.

/**
* @file printAnnotation.cpp
* @brief Prints annotation strings for each element
* @author Akiya Jouraku
*
* <!--------------------------------------------------------------------------
* 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 "util.h"
void printAnnotation(SBase_t *sb, const char* id )
{
if (!SBase_isSetAnnotation(sb)) return;
printf("----- %s (%s) annotation -----\n%s\n\n"
, id
);
}
int
main (int argc, char* argv[])
{
unsigned int i,j,errors;
const char* filename;
SBMLDocument_t* document;
Model_t* m;
if (argc != 2)
{
printf("\nUsage: printAnnotation filename\n\n");
return 1;
}
filename = argv[1];
document = readSBML(filename);
errors = SBMLDocument_getNumErrors( document);
printf("\n%s\n\n", filename);
if(errors > 0)
{
SBMLDocument_printErrors(document, stderr);
SBMLDocument_free(document);
return errors;
}
/* Model */
m = SBMLDocument_getModel(document);
printAnnotation((SBase_t*)m, Model_getId(m));
for(i=0; i < Model_getNumReactions(m); i++)
{
printAnnotation((SBase_t*)re, Reaction_getId(re));
/* SpeciesReference (Reactant) */
for(j=0; j < Reaction_getNumReactants( re); j++)
{
if (SBase_isSetAnnotation((SBase_t*) rt)) printf(" ");
printAnnotation((SBase_t*)rt, SpeciesReference_getSpecies( rt ) );
}
/* SpeciesReference (Product) */
for(j=0; j < Reaction_getNumProducts( re ); j++)
{
if (SBase_isSetAnnotation((SBase_t*) rt)) printf(" ");
printAnnotation((SBase_t*)rt, SpeciesReference_getSpecies( rt ) );
}
/* ModifierSpeciesReference (Modifiers) */
for(j=0; j < Reaction_getNumModifiers( re ); j++)
{
if (SBase_isSetAnnotation((SBase_t*) md)) printf(" ");
printAnnotation((SBase_t*)md, SpeciesReference_getSpecies( md ) );
}
/* KineticLaw */
{
if (SBase_isSetAnnotation((SBase_t*) kl)) printf(" ");
printAnnotation((SBase_t*)kl, "");
/* Parameter */
for(j=0; j < KineticLaw_getNumParameters( kl ); j++)
{
if (SBase_isSetAnnotation((SBase_t*) pa)) printf(" ");
printAnnotation((SBase_t*)pa, Parameter_getId(pa));
}
}
}
/* Species */
for(i=0; i < Model_getNumSpecies(m); i++)
{
printAnnotation((SBase_t*)sp, Species_getId(sp));
}
/* Compartments */
for(i=0; i < Model_getNumCompartments( m ); i++)
{
printAnnotation((SBase_t*)sp, Compartment_getId(sp));
}
/* FunctionDefinition */
for(i=0; i < Model_getNumFunctionDefinitions(m); i++)
{
printAnnotation((SBase_t*)sp, FunctionDefinition_getId(sp));
}
/* UnitDefinition */
for(i=0; i < Model_getNumUnitDefinitions(m); i++)
{
printAnnotation((SBase_t*)sp, UnitDefinition_getId(sp));
}
/* Parameter */
for(i=0; i < Model_getNumParameters( m ); i++)
{
printAnnotation((SBase_t*)sp, Parameter_getId(sp));
}
/* Rule */
for(i=0; i < Model_getNumReactions( m ); i++)
{
Rule_t* sp = Model_getRule(m, i);
printAnnotation((SBase_t*)sp, "");
}
/* InitialAssignment */
for(i=0; i < Model_getNumInitialAssignments(m); i++)
{
printAnnotation((SBase_t*)sp, "");
}
/* Event */
for(i=0; i < Model_getNumEvents(m); i++)
{
Event_t* sp = Model_getEvent(m, i);
printAnnotation((SBase_t*)sp, Event_getId(sp));
/* Trigger */
{
if (SBase_isSetAnnotation( (SBase_t*) tg)) printf( " " );
printAnnotation((SBase_t*)tg, "");
}
/* Delay */
{
if (SBase_isSetAnnotation( (SBase_t*) dl)) printf( " " );
printAnnotation((SBase_t*) dl, "");
}
/* EventAssignment */
for(j=0; j < Event_getNumEventAssignments(sp); j++)
{
if (SBase_isSetAnnotation( (SBase_t*) ea)) printf( " " );
printAnnotation((SBase_t*)ea, "");
}
}
/* SpeciesType */
for(i=0; i < Model_getNumSpeciesTypes(m); i++)
{
printAnnotation((SBase_t*)sp, SpeciesType_getId(sp));
}
/* Constraints */
for(i=0; i < Model_getNumConstraints(m); i++)
{
printAnnotation((SBase_t*)sp, "");
}
SBMLDocument_free( document );
return errors;
}
const char * Compartment_getId(const Compartment_t *c)
_tReturns_t _tthe_t _tvalue_t _tof_t _tthe_t "_tid_t" _tattribute_t _tof_t _tthe_t _tgiven_t _tCompar...
Definition Compartment.cpp:2104
int Event_isSetTrigger(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:2449
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
const char * Event_getId(const Event_t *e)
_tTakes_t _tan_t _tEvent_t_t _tstructure_t _tand_t _treturns_t _tits_t _tidentifier_t.
Definition Event.cpp:2377
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
Trigger_t * Event_getTrigger(Event_t *e)
_tTakes_t _tan_t _tEvent_t_t _tstructure_t _tand_t _treturns_t _tits_t _tTrigger_t_t _tstructure_t.
Definition Event.cpp:2393
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
const char * FunctionDefinition_getId(const FunctionDefinition_t *fd)
_tGet_t _tthe_t _tidentifier_t _tof_t _tthe_t _tgiven_t _tFunctionDefinition_t_t _tstructure_t.
Definition FunctionDefinition.cpp:1375
Parameter_t * KineticLaw_getParameter(KineticLaw_t *kl, unsigned int n)
_tGet_t _tthe_t _tnth_t _tparameter_t _tin_t _tthe_t _tlist_t _tof_t _tparameters_t _tin_t _tthe_t _t...
Definition KineticLaw.cpp:2246
unsigned int KineticLaw_getNumParameters(const KineticLaw_t *kl)
_tGet_t _tthe_t _tnumber_t _tof_t _tparameters_t _tdefined_t _tin_t _tthe_t _tgiven_t _tKineticLaw_t_...
Definition KineticLaw.cpp:2278
const char * Model_getId(const Model_t *m)
_tGet_t _tthe_t _tidentifier_t _tof_t _tthe_t _tgiven_t _tModel_t_t _tstructure_t.
Definition Model.cpp:7157
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
UnitDefinition_t * Model_getUnitDefinition(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tUnitDefinition_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tM...
Definition Model.cpp:7942
unsigned int Model_getNumFunctionDefinitions(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tFunctionDefinition_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _t...
Definition Model.cpp:8118
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
FunctionDefinition_t * Model_getFunctionDefinition(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tFunctionDefinition_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t...
Definition Model.cpp:7926
unsigned int Model_getNumSpeciesTypes(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tSpeciesType_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t...
Definition Model.cpp:8142
SpeciesType_t * Model_getSpeciesType(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tSpeciesType_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tMode...
Definition Model.cpp:7974
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
unsigned int Model_getNumUnitDefinitions(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tUnitDefinition_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tMode...
Definition Model.cpp:8126
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
Constraint_t * Model_getConstraint(Model_t *m, unsigned int n)
_tGet_t _tthe_t _tnth_t _tConstraint_t_t _tstructure_t _tcontained_t _tin_t _tthe_t _tgiven_t _tModel...
Definition Model.cpp:8070
unsigned int Model_getNumConstraints(const Model_t *m)
_tGet_t _tthe_t _tnumber_t _tof_t _tConstraint_t_t _tstructures_t _tin_t _tthe_t _tgiven_t _tModel_t_...
Definition Model.cpp:8198
const char * Parameter_getId(const Parameter_t *p)
_tTakes_t _ta_t _tParameter_t_t _tstructure_t _tand_t _treturns_t _tits_t _tidentifier_t.
Definition Parameter.cpp:2008
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_getModifier(Reaction_t *r, unsigned int n)
@_treturn_t _tthe_t _tnth_t _tmodifier_t (_tmodifier_t _tSpeciesReference_t_t) _tof_t _tthis_t _tReac...
Definition Reaction.cpp:3086
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
unsigned int Reaction_getNumModifiers(const Reaction_t *r)
@_treturn_t _tthe_t _tnumber_t _tof_t _tmodifiers_t (_tmodifier_t _tSpeciesReference_t_t'_ts_t) _tin_...
Definition Reaction.cpp:3117
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
const char * Reaction_getId(const Reaction_t *r)
@_treturn_t _tthe_t _tid_t _tof_t _tthis_t _tReaction_t_t.
Definition Reaction.cpp:2689
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.
int SBase_isSetAnnotation(const SBase_t *sb)
_tPredicate_t _treturning_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t) _tdepending_t _to...
Definition SBase.cpp:7629
char * SBase_getAnnotationString(SBase_t *sb)
_tReturns_t _tthe_t _tannotation_t _tstring_t _tfrom_t _tgiven_t _tSBML_t _tstructure_t.
Definition SBase.cpp:7588
const char * SBase_getElementName(const SBase_t *sb)
_tReturns_t _tthe_t _tXML_t _telement_t _tname_t _tof_t _tthe_t _tgiven_t _tstructure_t.
Definition SBase.cpp:7992
const char * Species_getId(const Species_t *s)
_tTakes_t _ta_t _tSpecies_t_t _tstructure_t _tand_t _treturns_t _tits_t _tidentifier_t.
Definition Species.cpp:2636
const char * SpeciesReference_getSpecies(const SpeciesReference_t *sr)
_tGet_t _tthe_t _tvalue_t _tof_t _tthe_t "_tspecies_t" _tattribute_t _tof_t _tthe_t _tgiven_t _tSpeci...
Definition SpeciesReference.cpp:1938
const char * SpeciesType_getId(const SpeciesType_t *st)
_tTakes_t _ta_t _tSpeciesType_t_t _tstructure_t _tand_t _treturns_t _tits_t _tidentifier_t.
Definition SpeciesType.cpp:889
const char * UnitDefinition_getId(const UnitDefinition_t *ud)
_tReturns_t _tthe_t _tidentifier_t _tof_t _tthis_t _tUnitDefinition_t_t _tstructure_t.
Definition UnitDefinition.cpp:2386
Utility functions.