sbmlutils.converters.xpp
¶
XPP ode to SBML file converter.
XPP file format is described here http://www.math.pitt.edu/~bard/bardware/tut/newstyle.html
Every ODE file consists of a series of lines that start with a keyword followed by numbers, names, and formulas or declare a named formula such as a differential equation or auxiliary quantity. Only the first letter of the keyword is important; e.g. the parser treats “parameter” and “punxatawney” exactly the same. The parser can understand lines up to 256 characters. You can use line continuation by adding a backslash character. The first line of the file cannot be a number (as this tells XPP that the file is in the old-style) but can be any other charcter or declaration. It is standard form to make the first line a comment which has the name of the file, but this is optional.
! Variables have to be case sensitive !. These issues can easily be fixed based on validator output.
Only supports subset of features. Not supported: - table - sum, - shift - set - boundary - ran - arrays
shift(var,expr) This operator evaluates the expression expr converts it to an integer and then uses this to indirectly address a variable whose address is that of var plus the integer value of the expression. This is a way to imitate arrays in XPP. For example if you defined the sequence of 5 variables, u0,u1,u2,u3,u4 one right after another, then shift(u0,2) would return the value of u2.
sum(ex1,ex2)of(ex3) is a way of summing up things. The expressions ex1>, are evaluated and their integer parts are used as the lower and upper limits of the sum. The index of the sum is i’ so that you cannot have double sums since there is only one index. ex3 is the expression to be summed and will generally involve i’ For example sum(1,10)of(i’) will be evaluated to 55. Another example combines the sum with the shift operator. sum(0,4)of(shift(u0,i’)) will sum up u0 and the next four variables that were defined after it.
Module Contents¶
Functions¶
|
Escape string. |
|
Parse the keyword and returns the xpp keyword type. |
|
Return the parts of given expression. |
|
Get sid, value tuple from given part of expression. |
|
Read given xpp_file and converts to SBML file. |
Attributes¶
- sbmlutils.converters.xpp.NOTES = Multiline-String[source]¶
Show Value
1 <body xmlns='http://www.w3.org/1999/xhtml'> 2 <h1>XPP model</h1> 3 <p>This model was converted from XPP ode format to SBML using <code>sbmlutils</code>.</p> 4 <pre>{}</pre> 5 <div class="dc:publisher">This file has been produced by 6 <a href="https://github.com/matthiaskoenig/sbmlutils/" title="sbmlutils" target="_blank">sbmlutils</a>. 7 </div> 8 9 <h2>Terms of use</h2> 10 <div class="dc:rightsHolder">Copyright © 2017 Matthias Koenig</div> 11 <div class="dc:license"> 12 <p>Redistribution and use of any part of this model, with or without modification, are permitted provided that 13 the following conditions are met: 14 <ol> 15 <li>Redistributions of this SBML file must retain the above copyright notice, this list of conditions 16 and the following disclaimer.</li> 17 <li>Redistributions in a different form must reproduce the above copyright notice, this list of 18 conditions and the following disclaimer in the documentation and/or other materials provided 19 with the distribution.</li> 20 </ol> 21 This model is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 22 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p> 23 </div> 24 </body>
- sbmlutils.converters.xpp.escape_string(info)[source]¶
Escape string.
- Parameters
info (str) –
- Return type
str
- sbmlutils.converters.xpp.parse_keyword(xpp_id)[source]¶
Parse the keyword and returns the xpp keyword type.
- Parameters
xpp_id (str) –
- Returns
- Return type
Optional[str]
- sbmlutils.converters.xpp.parts_from_expression(expression)[source]¶
Return the parts of given expression.
The parts can be whitespace or comma separated.
V1=-0.75 R1=0.26 CA1=0.1 H1=0.1 V1=-0.75, R1=0.26, CA1=0.1, H1=0.1
but there can also be commas in function definitions vex=vex(t,freq,vext)
- Returns
list of cleaned parts
- Parameters
expression (str) –
- Return type
List[str]
- sbmlutils.converters.xpp.sid_value_from_part(part)[source]¶
Get sid, value tuple from given part of expression.
- Parameters
part (str) –
- Returns
- Return type
Tuple[str, str]
- sbmlutils.converters.xpp.xpp2sbml(xpp_file, sbml_file, force_lower=False, validate=True, debug=False)[source]¶
Read given xpp_file and converts to SBML file.
- Parameters
debug (bool) –
xpp_file (pathlib.Path) – xpp input ode file
sbml_file (pathlib.Path) – sbml output file
force_lower (bool) – force lower case for all lines
validate (bool) – perform validation on the generated SBML file
- Returns
- Return type
libsbml.SBMLDocument