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
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/.
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>
The following features are supported:
e
for exponentiale).a=b+c
and definitions, as a:=b+c
diff(q,t):=1+sin(t)
. The initial condition is a parameter named q_init
.f(x,y):=x+y
.ln
for the natural logarithm. The logx
function is always two-argument (argument, base).factorial()
or with the usual exclamation mark.delay(X,delta)
operator (PharmML 0.3.2 and up?).Stand-alone mode generates full models which should be ready to run. The following rules apply:
par a=2, b=1+1
.These constants and aliases are defined:
PharmML | Aliases |
---|---|
exponentiale | e |
pi | |
infinity | inf |
notanumber | nan, NaN |
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.
See how infix2pharmml has been used to encode a relatively complex model at Chen_BiophysJ_2009/conversion-pharmml.
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.