Menu

Tree [c294a8] master /
 History

HTTPS access


File Date Author Commit
 chen 2015-08-25 Toni G Toni G [5c29ad] allow validation vs other dirs
 prism 2014-11-11 Toni Toni [37bdb6] updated prism
 t 2015-03-13 Toni G Toni G [9087a0] cleanups
 validate 2015-08-25 Toni G Toni G [5c29ad] allow validation vs other dirs
 .gitignore 2014-01-10 Toni G Toni G [25bc79] Initial commit
 CNR_logo_100.png 2014-01-22 Toni Toni [018a8b] Added logos
 ChangeLog 2015-09-11 Toni G Toni G [6c436f] changelog
 FUNCTIONS.md 2014-05-14 Toni G Toni G [bb6645] doc
 LICENSE 2014-01-12 Toni G Toni G [e722a8] changed to Affero
 Makefile 2015-03-13 Toni G Toni G [38c360] use start symbol option, remove sed
 README.md 2016-04-11 Toni G Toni G [25ebbf] docs
 build.sh 2015-09-08 Toni G Toni G [d994f1] cleanup
 convert.pl 2015-03-13 Toni G Toni G [38c360] use start symbol option, remove sed
 emptyModel.xml 2015-08-24 Toni G Toni G [0ed9b7] converting for 0.7
 index.head 2015-08-24 Toni G Toni G [e43b1e] html
 index.html 2015-10-22 Toni G Toni G [20e815] wider variety
 index.md 2019-09-12 Toni Toni [c294a8] nn
 infix2pharmml.cgi 2014-11-18 Toni Toni [5266d4] host logging
 infix2pharmml.pm 2015-08-25 Toni G Toni G [5c29ad] allow validation vs other dirs
 infix2pharmml_base.eyp 2015-08-24 Toni G Toni G [ffc0e0] fixed function call
 infix2pharmml_model.pm 2015-08-24 Toni G Toni G [ffc0e0] fixed function call
 infix2pharmml_statement.pm 2015-08-24 Toni G Toni G [ffc0e0] fixed function call

Read Me

infix2pharmml

The infix2pharmml converter translates expressions from the usual mathematical infix notation into the corresponding PharmML markup. PharmML is a markup for pharmacometrics models developed by the DDMoRe consortium.

Author: Toni G at ISIB-IN-CNR

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Usage

Online: see http://infix2pharmml.sourceforge.net .

Offline: use convert.pl. The infix expression to convert is expected either interactively, or as the first command-line argument. The -s switch activates the stand-alone model output.

E.g: open a shell, then

shell>   perl -w convert.pl

Enter the expression to convert:
sin(-2*t)
About to parse: sin(-2*t)
XML:

<Equation xmlns="http://www.pharmml.org/2013/03/Maths">
  <Uniop op="sin">
    <Binop op="times">
      <Uniop op="minus">
        <ct:Real>2</ct:Real>
      </Uniop>
      <ct:SymbRef symbIdRef="t"/>
    </Binop>
  </Uniop>
</Equation>

Modeling syntax

The following features are supported:

  • All operators defined by PharmML 0.6 should be supported
  • Constants (with user-friendly aliases, such as e for exponentiale).
  • Variable assignments, as in a=b+c and definitions, as a:=b+c
  • Derivative variable (ODE) definitions, as diff(q,t):=1+sin(t). The initial condition is a parameter named q_init.
  • Function definitions, such as f(x,y):=x+y.
  • Use ln for the natural logarithm. The logx function is always two-argument (argument, base).
  • Calls to user-defined functions use an R-like named-argument syntax (see examples below).
  • Factorial can be expressed as factorial() or with the usual exclamation mark.
  • The delay(X,delta) operator (PharmML 0.3.2 and up?).
  • Description tags for variables and derivative variables, in curly brackets.

Stand-alone mode

Stand-alone mode generates full models which should be ready to run. The following rules apply:

  • Multiple statements can be provided, separated by semicolons.
  • Parameter assignments are supported, as e.g. par a=2, b=1+1.
  • The only allowed statement types are assignments of parameters, variables, and derivative variables.

Constants

These constants and aliases are defined:

PharmML Aliases
exponentiale e
pi
infinity inf
notanumber nan, NaN

Custom function calls

Calling user-defined function (with named arguments) is achieved as follows:

   combinedErrorModel(a=a,b=b,f=Cc)

which should yield

<math:Equation xmlns="http://www.pharmml.org/2013/03/Maths">
  <math:FunctionCall>
    <!-- Translating: combinedErrorModel(a=a b=b f=Cc) -->
    <ct:SymbRef symbIdRef="combinedErrorModel"/>
    <math:FunctionArgument symbId="a">
      <math:Equation xmlns="http://www.pharmml.org/2013/03/Maths">
        <ct:SymbRef symbIdRef="a"/>
      </math:Equation>
    </math:FunctionArgument>
    <math:FunctionArgument symbId="b">
      <math:Equation xmlns="http://www.pharmml.org/2013/03/Maths">
        <ct:SymbRef symbIdRef="b"/>
      </math:Equation>
    </math:FunctionArgument>
    <math:FunctionArgument symbId="f">
      <math:Equation xmlns="http://www.pharmml.org/2013/03/Maths">
        <ct:SymbRef symbIdRef="Cc"/>
      </math:Equation>
    </math:FunctionArgument>
  </math:FunctionCall>
</math:Equation>

Note that arguments will be wrapped into Equation elements, even when they could be omitted.

A full-fledged example

See how infix2pharmml has been used to encode a relatively complex model at Chen_BiophysJ_2009/conversion-pharmml.

Limitations

  • In single-statement mode, all symbols are assumed to reference variables in the current block (in other words, the blkIdRef attribute is never generated).
  • All symbols are assumed to be of type real.
  • Undefined symbols are assumed to be population parameters and put into a block named p.
  • Logical operators, piecewise functions, matrix and vector operators are not supported.
  • Support for initial conditions in differential equations is crude.
  • Code generation does not rely on the official libpharmml API.

Acknowledgments

This software is based on the excellent eyapp parser and several other Perl modules.

Online syntax highlighting is provided by prism.

Partial funding from the DDMoRe IMI project is gratefully acknowledged.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.