本文整理汇总了C++中SBML_formulaToString函数的典型用法代码示例。如果您正苦于以下问题:C++ SBML_formulaToString函数的具体用法?C++ SBML_formulaToString怎么用?C++ SBML_formulaToString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SBML_formulaToString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: START_TEST
END_TEST
START_TEST (test_FormulaFormatter_multiAnd)
{
char *s;
ASTNode_t *n = ASTNode_create();
ASTNode_t *c = ASTNode_create();
ASTNode_setType(n, AST_LOGICAL_AND);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "and()"), NULL );
safe_free(s);
ASTNode_setName(c, "x");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "and(x)"), NULL );
safe_free(s);
c = ASTNode_create();
ASTNode_setName(c, "y");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "and(x, y)"), NULL );
safe_free(s);
c = ASTNode_create();
ASTNode_setName(c, "z");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "and(x, y, z)"), NULL );
safe_free(s);
ASTNode_free(n);
}
示例2: printEventMath
void
printEventMath (unsigned int n, Event_t *e)
{
char *formula;
unsigned int i;
if ( Event_isSetDelay(e) )
{
const Delay_t *delay = Event_getDelay(e);
formula = SBML_formulaToString( Delay_getMath(delay) );
printf("Event %d delay: %s\n", n, formula);
free(formula);
}
if ( Event_isSetTrigger(e) )
{
const Trigger_t *trigger = Event_getTrigger(e);
formula = SBML_formulaToString( Trigger_getMath(trigger) );
printf("Event %d trigger: %s\n", n, formula);
free(formula);
}
for (i = 0; i < Event_getNumEventAssignments(e); ++i)
{
printEventAssignmentMath(i + 1, Event_getEventAssignment(e, i));
}
printf("\n");
}
示例3: START_TEST
END_TEST
START_TEST (test_FormulaFormatter_multiPlusTimes)
{
StringBuffer_t *sb = StringBuffer_create(42);
char *s = StringBuffer_getBuffer(sb);
ASTNode_t *n = ASTNode_create();
ASTNode_t *c = ASTNode_create();
ASTNode_setType(n, AST_PLUS);
ASTNode_setName(c, "x");
ASTNode_addChild(n, c);
c = ASTNode_create();
ASTNode_setName(c, "y");
ASTNode_addChild(n, c);
c = ASTNode_create();
ASTNode_setName(c, "z");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "x + y + z"), NULL );
ASTNode_setType(n, AST_TIMES);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "x * y * z"), NULL );
safe_free(s);
ASTNode_free(n);
}
示例4: main
int main(void)
{
int i;
char *formula;
variableIndex_t *vi = NULL;
odeModel_t *model =
ODEModel_createFromFile("basic-model1-forward-l2.xml");
/* Get some information from constructed odeModel */
printf("\n\n");
printf("ODE Model Statistics:\n");
printf("Number of ODEs: %d\n",
ODEModel_getNeq(model));
printf("Number of Assignments: %d\n",
ODEModel_getNumAssignments(model));
printf("Number of Constants: %d\n",
ODEModel_getNumConstants(model));
printf(" ____\n");
printf("Total number of values: %d\n",
ODEModel_getNumValues(model));
printf("\n");
printf("ODEs:\n");
for ( i=0; i<ODEModel_getNeq(model); i++ ){
vi = ODEModel_getOdeVariableIndex(model, i);
formula = SBML_formulaToString(ODEModel_getOde(model, vi));
printf("d[%s]/dt = %s \n", ODEModel_getVariableName(model, vi), formula);
free(formula);
VariableIndex_free(vi);
}
printf("Assigned Variables:\n");
for ( i=0; i<ODEModel_getNumAssignments(model); i++ ){
vi = ODEModel_getAssignedVariableIndex(model, i);
formula = SBML_formulaToString(ODEModel_getOde(model, vi));
printf("%s = %s \n", ODEModel_getVariableName(model, vi), formula);
free(formula);
VariableIndex_free(vi);
}
printf("Constants:\n");
for ( i=0; i<ODEModel_getNumConstants(model); i++ ){
vi = ODEModel_getConstantIndex(model, i);
printf("%s\n", ODEModel_getVariableName(model, vi));
VariableIndex_free(vi);
}
printf("\n\n");
ODEModel_free(model);
return 1;
}
示例5: printJacobian
void printJacobian(odeModel_t *om, FILE *f)
{
int i, j;
if ( om == NULL ) {
fprintf(stderr, "No odeModel available.\n");
return;
}
if ( om->jacob == NULL ) {
fprintf(stderr, "Jacobian Matrix has not been constructed.\n");
return;
}
fprintf(f, "\n");
fprintf(f, "# Jacobian Matrix:\n");
for ( i=0; i<om->neq; i++ ) {
fprintf(f, "# %s: \n", om->names[i]);
for ( j=0; j<om->neq; j++ ) {
fprintf(f, " (d[%s]/dt)/d[%s] = %s;\n",
om->names[i], om->names[j],
SBML_formulaToString(om->jacob[i][j]));
}
}
fprintf(f, "\n");
fprintf(stderr, "Use option -j to avoid printing the"
" jacobian matrix expressions.\n");
return;
}
示例6: START_TEST
END_TEST
/**
* setMathFromFormula() is no longer necessary. LibSBML now keeps formula
* strings and math ASTs synchronized automatically. This (now modified)
* test is kept around to demonstrate the behavioral change.
*/
START_TEST (test_KineticLaw_setMathFromFormula)
{
const char *initial_formula = "k3 / k2";
char* formula;
fail_unless( !KineticLaw_isSetMath (kl) );
fail_unless( !KineticLaw_isSetFormula(kl) );
KineticLaw_setFormula(kl, initial_formula);
fail_unless( KineticLaw_isSetMath (kl) );
fail_unless( KineticLaw_isSetFormula(kl) );
formula = SBML_formulaToString( KineticLaw_getMath(kl) );
fail_unless( !strcmp(formula, initial_formula) );
safe_free(formula);
}
示例7: START_TEST
END_TEST
START_TEST (test_AssignmentRule_createWithFormula)
{
const ASTNode_t *math;
char *formula;
Rule_t *ar = Rule_createAssignment(2, 4);
Rule_setVariable(ar, "s");
Rule_setFormula(ar, "1 + 1");
fail_unless( SBase_getTypeCode ((SBase_t *) ar) == SBML_ASSIGNMENT_RULE );
fail_unless( SBase_getMetaId ((SBase_t *) ar) == NULL );
fail_unless( !strcmp(Rule_getVariable(ar), "s") );
math = Rule_getMath((Rule_t *) ar);
fail_unless(math != NULL);
formula = SBML_formulaToString(math);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "1 + 1") );
fail_unless( !strcmp(Rule_getFormula((Rule_t *) ar), formula) );
Rule_free(ar);
safe_free(formula);
}
示例8: START_TEST
END_TEST
START_TEST (test_Rule_setMath1)
{
ASTNode_t *math = ASTNode_createWithType(AST_TIMES);
ASTNode_t *a = ASTNode_create();
ASTNode_t *b = ASTNode_create();
ASTNode_setName(a, "a");
ASTNode_setName(b, "b");
ASTNode_addChild(math, a);
ASTNode_addChild(math, b);
char *formula;
const ASTNode_t *math1;
int i = Rule_setMath(R, math);
fail_unless( i == LIBSBML_OPERATION_SUCCESS);
fail_unless( Rule_isSetMath(R) );
math1 = Rule_getMath(R);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "a * b") );
ASTNode_free(math);
}
示例9: START_TEST
END_TEST
START_TEST (test_SpeciesReference_setStoichiometryMath)
{
const ASTNode_t *math = SBML_parseFormula("k3 / k2");
StoichiometryMath_t *stoich = StoichiometryMath_create(2, 4);
StoichiometryMath_setMath(stoich, math);
const StoichiometryMath_t * math1;
char * formula;
SpeciesReference_setStoichiometryMath(SR, stoich);
math1 = SpeciesReference_getStoichiometryMath(SR);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(StoichiometryMath_getMath(math1));
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "k3 / k2") );
fail_unless( SpeciesReference_isSetStoichiometryMath(SR) );
safe_free(formula);
}
示例10: START_TEST
END_TEST
START_TEST (test_AlgebraicRule_createWithFormula)
{
const ASTNode_t *math;
char *formula;
AlgebraicRule_t *ar = AlgebraicRule_create(2, 4);
AlgebraicRule_setFormula(ar, "1 + 1");
fail_unless( SBase_getTypeCode ((SBase_t *) ar) == SBML_ALGEBRAIC_RULE );
fail_unless( SBase_getMetaId ((SBase_t *) ar) == NULL );
math = AlgebraicRule_getMath(ar);
fail_unless(math != NULL);
formula = SBML_formulaToString(math);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "1 + 1") );
fail_unless( !strcmp(AlgebraicRule_getFormula(ar), formula) );
AlgebraicRule_free(ar);
safe_free(formula);
}
示例11: main
int
main (int argc, char *argv[]){
int i, j;
char *model;
double time;
double printstep;
/* libSBML types */
SBMLDocument_t *d;
SBMLReader_t *sr;
Model_t *m;
Reaction_t *r;
KineticLaw_t *kl;
ASTNode_t *nary;
ASTNode_t *diff;
/* SOSlib types */
SBMLResults_t *results;
timeCourse_t *tc;
cvodeSettings_t *set;
/* parsing command-line arguments */
if (argc < 4 ) {
fprintf(stderr,
"usage %s sbml-model-file simulation-time time-steps\n",
argv[0]);
exit(EXIT_FAILURE);
}
model = argv[1];
time = atof(argv[2]);
printstep = atoi(argv[3]);
/* parsing the SBML model with libSBML */
sr = SBMLReader_create();
d = SBMLReader_readSBML(sr, model);
SBMLReader_free(sr);
m = SBMLDocument_getModel(d);
r = Model_getReaction(m,0);
kl = Reaction_getKineticLaw(r);
nary = KineticLaw_getMath(kl);
printf("N-ary formula: %s\n", SBML_formulaToString(nary));
diff = differentiateAST(nary, "Product");
printf("N-ary diff: %s\n", SBML_formulaToString(diff));
ASTNode_free(diff);
return (EXIT_SUCCESS);
}
示例12: START_TEST
END_TEST
START_TEST (test_FunctionDefinition_setMath)
{
ASTNode_t *math = SBML_parseFormula("lambda(x, x^3)");
const ASTNode_t * math1;
char * formula;
FunctionDefinition_setMath(FD, math);
math1 = FunctionDefinition_getMath(FD);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "lambda(x, x^3)") );
fail_unless( FunctionDefinition_getMath(FD) != math );
fail_unless( FunctionDefinition_isSetMath(FD) );
fail_unless( FunctionDefinition_isSetBody(FD) );
/* Reflexive case (pathological) */
FunctionDefinition_setMath(FD, (ASTNode_t *) FunctionDefinition_getMath(FD));
math1 = FunctionDefinition_getMath(FD);
fail_unless( math1 != NULL );
safe_free(formula);
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "lambda(x, x^3)") );
fail_unless( FunctionDefinition_getMath(FD) != math );
FunctionDefinition_setMath(FD, NULL);
fail_unless( !FunctionDefinition_isSetMath(FD) );
fail_unless( !FunctionDefinition_isSetBody(FD) );
if (FunctionDefinition_getMath(FD) != NULL)
{
fail("FunctionDefinition_setMath(FD, NULL) did not clear ASTNode.");
}
ASTNode_free(math);
safe_free(formula);
}
示例13: START_TEST
END_TEST
START_TEST (test_EventAssignment_setMath)
{
ASTNode_t *math = SBML_parseFormula("2 * k");
char *formula;
const ASTNode_t *math1;
EventAssignment_setMath(EA, math);
math1 = EventAssignment_getMath(EA);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "2 * k") );
safe_free(formula);
fail_unless( EventAssignment_getMath(EA) != math);
fail_unless( EventAssignment_isSetMath(EA) );
/* Reflexive case (pathological) */
EventAssignment_setMath(EA, (ASTNode_t *) EventAssignment_getMath(EA));
math1 = EventAssignment_getMath(EA);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "2 * k") );
fail_unless( EventAssignment_getMath(EA) != math );
safe_free(formula);
EventAssignment_setMath(EA, NULL);
fail_unless( !EventAssignment_isSetMath(EA) );
if (EventAssignment_getMath(EA) != NULL)
{
fail("EventAssignment_setMath(EA, NULL) did not clear ASTNode.");
}
ASTNode_free(math);
}
示例14: START_TEST
END_TEST
START_TEST (test_Priority_setMath)
{
ASTNode_t *math = SBML_parseFormula("lambda(x, x^3)");
const ASTNode_t * math1;
char * formula;
Priority_setMath(P, math);
math1 = Priority_getMath(P);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "lambda(x, x^3)") );
fail_unless( Priority_getMath(P) != math );
fail_unless( Priority_isSetMath(P) );
safe_free(formula);
/* Reflexive case (pathological) */
Priority_setMath(P, (ASTNode_t *) Priority_getMath(P));
math1 = Priority_getMath(P);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "lambda(x, x^3)") );
safe_free(formula);
Priority_setMath(P, NULL);
fail_unless( !Priority_isSetMath(P) );
if (Priority_getMath(P) != NULL)
{
fail("Priority_setMath(P, NULL) did not clear ASTNode.");
}
ASTNode_free(math);
}
示例15: START_TEST
END_TEST
START_TEST (test_StoichiometryMath_setMath)
{
ASTNode_t *math = SBML_parseFormula("lambda(x, x^3)");
const ASTNode_t * math1;
char * formula;
StoichiometryMath_setMath(D, math);
math1 = StoichiometryMath_getMath(D);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "lambda(x, x^3)") );
fail_unless( StoichiometryMath_getMath(D) != math );
fail_unless( StoichiometryMath_isSetMath(D) );
safe_free(formula);
/* Reflexive case (pathological) */
StoichiometryMath_setMath(D, (ASTNode_t *) StoichiometryMath_getMath(D));
math1 = StoichiometryMath_getMath(D);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "lambda(x, x^3)") );
safe_free(formula);
StoichiometryMath_setMath(D, NULL);
fail_unless( !StoichiometryMath_isSetMath(D) );
if (StoichiometryMath_getMath(D) != NULL)
{
fail("StoichiometryMath_setMath(D, NULL) did not clear ASTNode.");
}
ASTNode_free(math);
}