Modules¶
libvcell¶
MathRegeneration
¶
Bases: BaseModel
Which applications of a document had their math regenerated, and why the others failed.
Attributes:
| Name | Type | Description |
|---|---|---|
regenerated |
list[str]
|
names of the applications whose math was regenerated, in document order. |
failed |
dict[str, str]
|
application name -> reason, for each application whose math generation failed; such an application keeps the math it was stored with. |
Source code in libvcell/model_utils.py
127 128 129 130 131 132 133 134 135 136 137 | |
VCellExpressionError
¶
Bases: Exception
Raised when a VCell expression cannot be evaluated.
Attributes:
| Name | Type | Description |
|---|---|---|
error_type |
the originating Java exception's simple class name (e.g. |
|
message |
the error message, or |
Source code in libvcell/model_utils.py
8 9 10 11 12 13 14 15 16 17 18 19 20 | |
evaluate_expression(expression_infix, symbol_table)
¶
Evaluate a native-syntax VCell infix expression against a table of symbol values.
Any symbol referenced by the expression must be present in symbol_table; extra
(unreferenced) symbols are permitted and ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression_infix
|
str
|
native VCell infix expression string (e.g. |
required |
symbol_table
|
dict[str, float]
|
mapping of symbol name to 64-bit float value |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
the evaluated value |
Raises:
| Type | Description |
|---|---|
VCellExpressionError
|
if the expression fails to parse, references an unsupplied symbol, fails to evaluate (e.g. division by zero, math domain error), or evaluates to a non-finite value. |
Source code in libvcell/model_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
sbml_to_finite_volume_input(sbml_content, output_dir_path)
¶
Convert SBML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_content
|
str
|
SBML content |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
sbml_to_ode_input(sbml_content, output_dir_path, duration, output_time_step)
¶
Convert a non-spatial SBML model to Sundials ODE solver input (a CVODE or IDA input file)
The model's first application is simulated from 0 to duration, saving every output_time_step,
on the Combined IDA/CVODE solver. Solve the input with the pyvcell-odesolver package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_content
|
str
|
SBML content |
required |
output_dir_path
|
Path
|
output directory path |
required |
duration
|
float
|
end time of the simulation (positive) |
required |
output_time_step
|
float
|
interval between saved time points (positive) |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: the success status, and the input file's name on success or the error message |
Source code in libvcell/solver_utils.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
sbml_to_vcml(sbml_content, vcml_file_path)
¶
Convert SBML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_content
|
str
|
SBML content |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
vcell_infix_to_num_expr_infix(vcell_infix)
¶
Converts an infix string version of a VCell Native Expression, and converts it to a NumExpr compatible version
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcell_infix
|
str
|
the infix to convert |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str, str]
|
tuple[bool, str, str]: A tuple containing the success status, a message, and the converted infix |
Source code in libvcell/model_utils.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
vcell_infix_to_python_infix(vcell_infix)
¶
Converts an infix string version of a VCell Native Expression, and converts it to a Python compatible version
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcell_infix
|
str
|
the infix to convert |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str, str]
|
tuple[bool, str, str]: A tuple containing the success status, a message, and the converted infix |
Source code in libvcell/model_utils.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
vcml_convert_units(vcml_content, unit_system, vcml_file_path)
¶
Rewrite a VCML document in another model unit system, converting every quantity (geometry included)
For an SBML model, import it with :func:sbml_to_vcml first; VCell imports SBML in the SBML's own units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
unit_system
|
str
|
"vcell" (µm, µM, s; what VCell's spatial and stochastic math assumes) or "sbml" (the units VCell writes SBML in) |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
vcml_regenerate_math(vcml_content, vcml_file_path)
¶
Regenerate the math of every application of a VCML document, as VCell does when it upgrades an old document, and write the result.
Unlike vcml_to_vcml, this forces VCell's upgrade (SimulationContext.updateAll(true)): a non-spatial
application that gives no absolute structure size gets the sizes VCell's StructureSizeSolver computes from
its surface-to-volume ratios and volume fractions (the model's first structure anchored at 1), written into its
structure mappings. Each application is regenerated on its own, so one whose math generation fails does not stop
the others.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str, MathRegeneration | None]
|
tuple[bool, str, MathRegeneration | None]: the success status (the document was read and written), a message ("Success", or the error), and on success which applications were regenerated and which failed |
Source code in libvcell/model_utils.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
vcml_to_finite_volume_input(vcml_content, simulation_name, output_dir_path)
¶
Convert VCML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
simulation_name
|
str
|
simulation name |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
vcml_to_moving_boundary_input(vcml_content, simulation_name, output_dir_path)
¶
Convert VCML content to Moving Boundary solver input (a MovingBoundarySetup XML file)
The named simulation must be configured for the Moving Boundary solver. The generated
MovingBoundarySetup XML can be consumed by the vcell-mbsolver package (MovingBoundarySolver.from_xml).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
simulation_name
|
str
|
simulation name (must use the Moving Boundary solver) |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
vcml_to_ode_input(vcml_content, simulation_name, output_dir_path)
¶
Convert a non-spatial VCML simulation to Sundials ODE solver input (a CVODE or IDA input file)
The named simulation must be configured for CVODE, IDA or the Combined IDA/CVODE solver (Combined
resolves to IDA when the math has fast systems, CVODE otherwise). The input file, with its
.functions file, is written into output_dir_path and can be solved by the pyvcell-odesolver
package (pyvcell_odesolver.solve(input_file, output_file)), which writes VCell's .ida results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
simulation_name
|
str
|
simulation name (must use CVODE, IDA or Combined IDA/CVODE) |
required |
output_dir_path
|
Path
|
output directory path |
required |
A rule-based application (reaction rules, whose network VCell generates with BioNetGen, which libvcell does not include) is converted from the math stored in the document: the network VCell generated when the model was saved. The message then says so.
Returns:
| Type | Description |
|---|---|
bool
|
tuple[bool, str]: the success status, and on success the input file's name ( |
str
|
|
tuple[bool, str]
|
no |
Source code in libvcell/solver_utils.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
vcml_to_sbml(vcml_content, application_name, sbml_file_path, round_trip_validation)
¶
Convert VCML content to SBML file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
application_name
|
str
|
VCell Biomodel application name |
required |
sbml_file_path
|
Path
|
path to resulting SBML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
vcml_to_vcml(vcml_content, vcml_file_path)
¶
Process VCML content to regenerated VCML file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
Modules¶
libvcell¶
MathRegeneration
¶
Bases: BaseModel
Which applications of a document had their math regenerated, and why the others failed.
Attributes:
| Name | Type | Description |
|---|---|---|
regenerated |
list[str]
|
names of the applications whose math was regenerated, in document order. |
failed |
dict[str, str]
|
application name -> reason, for each application whose math generation failed; such an application keeps the math it was stored with. |
Source code in libvcell/model_utils.py
127 128 129 130 131 132 133 134 135 136 137 | |
VCellExpressionError
¶
Bases: Exception
Raised when a VCell expression cannot be evaluated.
Attributes:
| Name | Type | Description |
|---|---|---|
error_type |
the originating Java exception's simple class name (e.g. |
|
message |
the error message, or |
Source code in libvcell/model_utils.py
8 9 10 11 12 13 14 15 16 17 18 19 20 | |
evaluate_expression(expression_infix, symbol_table)
¶
Evaluate a native-syntax VCell infix expression against a table of symbol values.
Any symbol referenced by the expression must be present in symbol_table; extra
(unreferenced) symbols are permitted and ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression_infix
|
str
|
native VCell infix expression string (e.g. |
required |
symbol_table
|
dict[str, float]
|
mapping of symbol name to 64-bit float value |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
the evaluated value |
Raises:
| Type | Description |
|---|---|
VCellExpressionError
|
if the expression fails to parse, references an unsupplied symbol, fails to evaluate (e.g. division by zero, math domain error), or evaluates to a non-finite value. |
Source code in libvcell/model_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
sbml_to_finite_volume_input(sbml_content, output_dir_path)
¶
Convert SBML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_content
|
str
|
SBML content |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
sbml_to_ode_input(sbml_content, output_dir_path, duration, output_time_step)
¶
Convert a non-spatial SBML model to Sundials ODE solver input (a CVODE or IDA input file)
The model's first application is simulated from 0 to duration, saving every output_time_step,
on the Combined IDA/CVODE solver. Solve the input with the pyvcell-odesolver package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_content
|
str
|
SBML content |
required |
output_dir_path
|
Path
|
output directory path |
required |
duration
|
float
|
end time of the simulation (positive) |
required |
output_time_step
|
float
|
interval between saved time points (positive) |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: the success status, and the input file's name on success or the error message |
Source code in libvcell/solver_utils.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
sbml_to_vcml(sbml_content, vcml_file_path)
¶
Convert SBML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_content
|
str
|
SBML content |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
vcell_infix_to_num_expr_infix(vcell_infix)
¶
Converts an infix string version of a VCell Native Expression, and converts it to a NumExpr compatible version
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcell_infix
|
str
|
the infix to convert |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str, str]
|
tuple[bool, str, str]: A tuple containing the success status, a message, and the converted infix |
Source code in libvcell/model_utils.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
vcell_infix_to_python_infix(vcell_infix)
¶
Converts an infix string version of a VCell Native Expression, and converts it to a Python compatible version
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcell_infix
|
str
|
the infix to convert |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str, str]
|
tuple[bool, str, str]: A tuple containing the success status, a message, and the converted infix |
Source code in libvcell/model_utils.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
vcml_convert_units(vcml_content, unit_system, vcml_file_path)
¶
Rewrite a VCML document in another model unit system, converting every quantity (geometry included)
For an SBML model, import it with :func:sbml_to_vcml first; VCell imports SBML in the SBML's own units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
unit_system
|
str
|
"vcell" (µm, µM, s; what VCell's spatial and stochastic math assumes) or "sbml" (the units VCell writes SBML in) |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
vcml_regenerate_math(vcml_content, vcml_file_path)
¶
Regenerate the math of every application of a VCML document, as VCell does when it upgrades an old document, and write the result.
Unlike vcml_to_vcml, this forces VCell's upgrade (SimulationContext.updateAll(true)): a non-spatial
application that gives no absolute structure size gets the sizes VCell's StructureSizeSolver computes from
its surface-to-volume ratios and volume fractions (the model's first structure anchored at 1), written into its
structure mappings. Each application is regenerated on its own, so one whose math generation fails does not stop
the others.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str, MathRegeneration | None]
|
tuple[bool, str, MathRegeneration | None]: the success status (the document was read and written), a message ("Success", or the error), and on success which applications were regenerated and which failed |
Source code in libvcell/model_utils.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
vcml_to_finite_volume_input(vcml_content, simulation_name, output_dir_path)
¶
Convert VCML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
simulation_name
|
str
|
simulation name |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
vcml_to_moving_boundary_input(vcml_content, simulation_name, output_dir_path)
¶
Convert VCML content to Moving Boundary solver input (a MovingBoundarySetup XML file)
The named simulation must be configured for the Moving Boundary solver. The generated
MovingBoundarySetup XML can be consumed by the vcell-mbsolver package (MovingBoundarySolver.from_xml).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
simulation_name
|
str
|
simulation name (must use the Moving Boundary solver) |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
vcml_to_ode_input(vcml_content, simulation_name, output_dir_path)
¶
Convert a non-spatial VCML simulation to Sundials ODE solver input (a CVODE or IDA input file)
The named simulation must be configured for CVODE, IDA or the Combined IDA/CVODE solver (Combined
resolves to IDA when the math has fast systems, CVODE otherwise). The input file, with its
.functions file, is written into output_dir_path and can be solved by the pyvcell-odesolver
package (pyvcell_odesolver.solve(input_file, output_file)), which writes VCell's .ida results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
simulation_name
|
str
|
simulation name (must use CVODE, IDA or Combined IDA/CVODE) |
required |
output_dir_path
|
Path
|
output directory path |
required |
A rule-based application (reaction rules, whose network VCell generates with BioNetGen, which libvcell does not include) is converted from the math stored in the document: the network VCell generated when the model was saved. The message then says so.
Returns:
| Type | Description |
|---|---|
bool
|
tuple[bool, str]: the success status, and on success the input file's name ( |
str
|
|
tuple[bool, str]
|
no |
Source code in libvcell/solver_utils.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
vcml_to_sbml(vcml_content, application_name, sbml_file_path, round_trip_validation)
¶
Convert VCML content to SBML file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
application_name
|
str
|
VCell Biomodel application name |
required |
sbml_file_path
|
Path
|
path to resulting SBML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
vcml_to_vcml(vcml_content, vcml_file_path)
¶
Process VCML content to regenerated VCML file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
vcml_file_path
|
Path
|
path to resulting VCML file |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/model_utils.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
Functions¶
sbml_to_finite_volume_input¶
Convert SBML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_content
|
str
|
SBML content |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
vcml_to_finite_volume_input¶
Convert VCML content to finite volume input files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcml_content
|
str
|
VCML content |
required |
simulation_name
|
str
|
simulation name |
required |
output_dir_path
|
Path
|
output directory path |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing the success status and a message |
Source code in libvcell/solver_utils.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
evaluate_expression¶
Evaluate a native-syntax VCell infix expression against a table of symbol values.
Any symbol referenced by the expression must be present in symbol_table; extra
(unreferenced) symbols are permitted and ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression_infix
|
str
|
native VCell infix expression string (e.g. |
required |
symbol_table
|
dict[str, float]
|
mapping of symbol name to 64-bit float value |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
the evaluated value |
Raises:
| Type | Description |
|---|---|
VCellExpressionError
|
if the expression fails to parse, references an unsupplied symbol, fails to evaluate (e.g. division by zero, math domain error), or evaluates to a non-finite value. |
Source code in libvcell/model_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
VCellExpressionError¶
Bases: Exception
Raised when a VCell expression cannot be evaluated.
Attributes:
| Name | Type | Description |
|---|---|---|
error_type |
the originating Java exception's simple class name (e.g. |
|
message |
the error message, or |
Source code in libvcell/model_utils.py
8 9 10 11 12 13 14 15 16 17 18 19 20 | |