biosimulators_utils.sedml package#
Submodules#
biosimulators_utils.sedml.data_model module#
Data model for SED
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- class biosimulators_utils.sedml.data_model.AbstractTask(id: str | None = None, name: str | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
Base class for tasks
- is_equal(other)[source]#
Determine if tasks are equal
- Parameters:
other (
AbstractTask
) – another content item- Returns:
True
, if two tasks are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.AddElementModelChange(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None, new_elements: str | None = None)[source]#
Bases:
ModelChange
An addition of an element to a model
- is_equal(other)[source]#
Determine if model changes are equal
- Parameters:
other (
AddElementModelChange
) – another content item- Returns:
True
, if two model changes are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.Algorithm(kisao_id: str | None = None, changes: list[AlgorithmParameterChange] | None = None)[source]#
Bases:
SedBase
A simulation algorithm
- changes[source]#
parameter changes
- Type:
list
ofAlgorithmParameterChange
- class biosimulators_utils.sedml.data_model.AlgorithmParameterChange(kisao_id: str | None = None, new_value: str | None = None)[source]#
Bases:
SedBase
A changed parameter of an algorithm
- is_equal(other)[source]#
Determine if parameter changes are equal
- Parameters:
other (
AlgorithmParameterChange
) – another parameter change- Returns:
True
, if two parameter changes are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.AxisScale(value)[source]#
Bases:
str
,Enum
Scale of an axis
- class biosimulators_utils.sedml.data_model.Color[source]#
Bases:
str
6-character hexidecimal RGB color or 8-character hexidecimal RGBA color
- class biosimulators_utils.sedml.data_model.ComputeModelChange(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None, variables: list[Variable] | None = None, parameters: list[Parameter] | None = None, math: str | None = None)[source]#
Bases:
ModelChange
,Calculation
A replacement of an element of a model
- is_equal(other)[source]#
Determine if model changes are equal
- Parameters:
other (
ComputeModelChange
) – another content item- Returns:
True
, if two model changes are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.Curve(id: str | None = None, name: str | None = None, x_scale: AxisScale | None = None, y_scale: AxisScale | None = None, x_data_generator: DataGenerator | None = None, y_data_generator: DataGenerator | None = None, style: Style | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A curve in a 2D plot
- class biosimulators_utils.sedml.data_model.DataGenerator(id: str | None = None, name: str | None = None, variables: list[Variable] | None = None, parameters: list[Parameter] | None = None, math: str | None = None)[source]#
Bases:
Calculation
,SedIdGroupMixin
A data generator
- is_equal(other)[source]#
- Determine if data generators
are equal
- Parameters:
other (
DataGenerator
) – another content item- Returns:
True
, if two data generators are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.DataSet(id: str | None = None, name: str | None = None, label: str | None = None, data_generator: DataGenerator | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A data set in a report
- class biosimulators_utils.sedml.data_model.FillStyle(color: Color | None = None)[source]#
Bases:
SedBase
Style of a marker
- class biosimulators_utils.sedml.data_model.FunctionalRange(id: str | None = None, name: str | None = None, range: Range | None = None, variables: list[Variable] | None = None, parameters: list[Parameter] | None = None, math: str | None = None)[source]#
Bases:
Range
,Calculation
A functional range
- is_equal(other)[source]#
Determine if ranges are equal
- Parameters:
other (
FunctionalRange
) – another content item- Returns:
True
, if two ranges are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.LineStyle(type: LineStyleType | None = None, color: Color | None = None, thickness: float | None = None)[source]#
Bases:
SedBase
Style of a line
- class biosimulators_utils.sedml.data_model.LineStyleType(value)[source]#
Bases:
str
,Enum
Style of a line of a curve
- class biosimulators_utils.sedml.data_model.MarkerStyle(type: MarkerStyleType | None = None, size: float | None = None, fill_color: Color | None = None, line_color: Color | None = None, line_thickness: float | None = None)[source]#
Bases:
SedBase
Style of a marker
- class biosimulators_utils.sedml.data_model.MarkerStyleType(value)[source]#
Bases:
str
,Enum
Style of a marker of a curve
- class biosimulators_utils.sedml.data_model.Model(id: str | None = None, name: str | None = None, source: str | None = None, language: str | None = None, changes: list[ModelChange] | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A model
- changes[source]#
model changes
- Type:
list
ofModelChange
- has_structural_changes()[source]#
Check if there are structural model changes present.
Add element
Replace element
Remove element
- Returns:
True
, if structural model changes are present- Return type:
bool
- class biosimulators_utils.sedml.data_model.ModelAttributeChange(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None, new_value: str | None = None)[source]#
Bases:
ModelChange
A change of an attribute of a model
- is_equal(other)[source]#
Determine if model attribute changes are equal
- Parameters:
other (
ModelAttributeChange
) – another content item- Returns:
True
, if two model attribute changes are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.ModelChange(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
,TargetGroupMixin
A change to a model
- is_equal(other)[source]#
Determine if model changes are equal
- Parameters:
other (
ModelChange
) – another content item- Returns:
True
, if two model changes are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.ModelLanguage(value)[source]#
Bases:
str
,Enum
Model language
- class biosimulators_utils.sedml.data_model.ModelLanguageEdamId(value)[source]#
Bases:
str
,Enum
Model language EDAM id
- class biosimulators_utils.sedml.data_model.ModelLanguagePattern(value)[source]#
Bases:
str
,Enum
Model language
- class biosimulators_utils.sedml.data_model.OneStepSimulation(id: str | None = None, name: str | None = None, algorithm: Algorithm | None = None, step: float | None = None)[source]#
Bases:
Simulation
A single simulation step
- is_equal(other)[source]#
Determine if simulations are equal
- Parameters:
other (
OneStepSimulation
) – another content item- Returns:
True
, if two simulations are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.Output(id: str | None = None, name: str | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
An output
- class biosimulators_utils.sedml.data_model.Parameter(id: str | None = None, name: str | None = None, value: float | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A parameter involved in a data generator
- class biosimulators_utils.sedml.data_model.Plot(id: str | None = None, name: str | None = None)[source]#
Bases:
Output
A 2D plot
- class biosimulators_utils.sedml.data_model.Plot2D(id: str | None = None, name: str | None = None, curves: list[Curve] | None = None)[source]#
Bases:
Plot
A 2D plot
- class biosimulators_utils.sedml.data_model.Plot3D(id: str | None = None, name: str | None = None, surfaces: list[Surface] | None = None)[source]#
Bases:
Plot
A 3D plot
- class biosimulators_utils.sedml.data_model.Range(id: str | None = None, name: str | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A range
- class biosimulators_utils.sedml.data_model.RemoveElementModelChange(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None)[source]#
Bases:
ModelChange
A removal of an element from a model
- class biosimulators_utils.sedml.data_model.RepeatedTask(id: str | None = None, name: str | None = None, range: Range | None = None, reset_model_for_each_iteration: bool | None = None, changes: list[SetValueComputeModelChange] | None = None, sub_tasks: list[SubTask] | None = None, ranges: list[Range] | None = None)[source]#
Bases:
AbstractTask
A repeated task
- reset_model_for_each_iteration[source]#
whether to reset the model for each iteration of the repeated task
- Type:
bool
- changes[source]#
set value model changes
- Type:
list
ofSetValueComputeModelChange
- is_equal(other)[source]#
Determine if repeated tasks are equal
- Parameters:
other (
RepeatedTask
) – another content item- Returns:
True
, if two repeated tasks are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.ReplaceElementModelChange(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None, new_elements: str | None = None)[source]#
Bases:
ModelChange
A replacement of an element of a model
- is_equal(other)[source]#
Determine if model changes are equal
- Parameters:
other (
ReplaceElementModelChange
) – another content item- Returns:
True
, if two model changes are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.Report(id: str | None = None, name: str | None = None, data_sets: list[DataSet] | None = None)[source]#
Bases:
Output
A report
- class biosimulators_utils.sedml.data_model.SedBase[source]#
Bases:
ABC
Base class for SED classes
- class biosimulators_utils.sedml.data_model.SedDocument(level: int = 1, version: int = 3, models: list[Model] | None = None, simulations: list[Simulation] | None = None, tasks: list[AbstractTask] | None = None, data_generators: list[DataGenerator] | None = None, outputs: list[Output] | None = None, styles: list[Style] | None = None, metadata: Metadata | None = None)[source]#
Bases:
SedBase
A SED-ML document
- simulations[source]#
simulations
- Type:
list
ofSimulation
- tasks[source]#
tasks
- Type:
list
ofAbstractTask
- data_generators[source]#
data generators
- Type:
list
ofDataGenerator
- is_equal(other)[source]#
Determine if SED-ML documents are equal
- Parameters:
other (
SedDocument
) – another SED-ML document- Returns:
True
, if two SED-ML documents are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.SedIdGroupMixin(id: str | None = None, name: str | None = None)[source]#
Bases:
ABC
Object with an id and optional name
- is_equal(other)[source]#
Determine if simulations are equal
- Parameters:
other (
SedIdGroupMixin
) – another content item- Returns:
True
, if two simulations are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.SetValueComputeModelChange(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None, variables: list[Variable] | None = None, parameters: list[Parameter] | None = None, math: str | None = None, model: Model | None = None, range: Range | None = None, symbol: str | None = None)[source]#
Bases:
ComputeModelChange
,Calculation
A change that sets the value of an attribute of a model within an iteration of a repeated task
- is_equal(other)[source]#
Determine if model changes are equal
- Parameters:
other (
SetValueComputeModelChange
) – another content item- Returns:
True
, if two model changes are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.Simulation(id: str | None = None, name: str | None = None, algorithm: Algorithm | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A simulation
- is_equal(other)[source]#
Determine if simulations are equal
- Parameters:
other (
Simulation
) – another content item- Returns:
True
, if two simulations are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.SteadyStateSimulation(id: str | None = None, name: str | None = None, algorithm: Algorithm | None = None)[source]#
Bases:
Simulation
A steady-state simulation
- class biosimulators_utils.sedml.data_model.Style(id: str | None = None, name: str | None = None, base: Style | None = None, line: LineStyle | None = None, marker: MarkerStyle | None = None, fill: FillStyle | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A graphical style
- class biosimulators_utils.sedml.data_model.SubTask(task: AbstractTask | None = None, order: int | None = None)[source]#
Bases:
SedBase
A subtask of a repeated task
- class biosimulators_utils.sedml.data_model.Surface(id: str | None = None, name: str | None = None, x_scale: AxisScale | None = None, y_scale: AxisScale | None = None, z_scale: AxisScale | None = None, x_data_generator: DataGenerator | None = None, y_data_generator: DataGenerator | None = None, z_data_generator: DataGenerator | None = None, style: Style | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A surface in a 3D plot
- class biosimulators_utils.sedml.data_model.Symbol(value)[source]#
Bases:
str
,Enum
Variable sumbol
- class biosimulators_utils.sedml.data_model.TargetGroupMixin(target=None, target_namespaces=None)[source]#
Bases:
ABC
Object with an id and optional name
- is_equal(other)[source]#
Determine if simulations are equal
- Parameters:
other (
TargetGroupMixin
) – another content item- Returns:
True
, if two simulations are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.Task(id: str | None = None, name: str | None = None, model: Model | None = None, simulation: Simulation | None = None)[source]#
Bases:
AbstractTask
A task
- class biosimulators_utils.sedml.data_model.UniformRange(id: str | None = None, name: str | None = None, start: float | None = None, end: float | None = None, number_of_steps: int | None = None, number_of_points: int | None = None, type: UniformRangeType | None = None)[source]#
Bases:
Range
A uniform range
- is_equal(other)[source]#
Determine if ranges are equal
- Parameters:
other (
UniformRange
) – another content item- Returns:
True
, if two ranges are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.UniformTimeCourseSimulation(id: str | None = None, name: str | None = None, algorithm: Algorithm | None = None, initial_time: float | None = None, output_start_time: float | None = None, output_end_time: float | None = None, number_of_steps: int | None = None, number_of_points: int | None = None)[source]#
Bases:
Simulation
A uniform time course simulation
- is_equal(other)[source]#
Determine if simulations are equal
- Parameters:
other (
UniformTimeCourseSimulation
) – another content item- Returns:
True
, if two simulations are equal- Return type:
bool
- class biosimulators_utils.sedml.data_model.Variable(id: str | None = None, name: str | None = None, target: str | None = None, target_namespaces: dict | None = None, symbol: str | None = None, task: AbstractTask | None = None, model: Model | None = None)[source]#
Bases:
SedBase
,SedIdGroupMixin
A model variable
- class biosimulators_utils.sedml.data_model.VectorRange(id: str | None = None, name: str | None = None, values: list[float] | None = None)[source]#
Bases:
Range
A vector range
- is_equal(other)[source]#
Determine if ranges are equal
- Parameters:
other (
VectorRange
) – another content item- Returns:
True
, if two ranges are equal- Return type:
bool
biosimulators_utils.sedml.exceptions module#
Exceptions for SED-ML
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2021-01-12
- Copyright:
2021, Center for Reproducible Biomedical Modeling
- License:
MIT
- exception biosimulators_utils.sedml.exceptions.SedmlExecutionError[source]#
Bases:
BioSimulatorsException
Error that a SED document could not be executed
- exception biosimulators_utils.sedml.exceptions.UnsupportedModelLanguageError[source]#
Bases:
BioSimulatorsException
,NotImplementedError
Error that a SED document could not be executed
biosimulators_utils.sedml.exec module#
Utilities for executing tasks in SED documents
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.sedml.exec.exec_plot_2d(plot, variable_results, base_out_path, rel_out_path, formats, task, log)[source]#
Execute a 2D plot, generating the curves which are available
- Parameters:
plot (
Plot2D
) – plotvariable_results (
VariableResults
) – result of each data generatorbase_out_path (
str
) – base path to store the plot. Complete path is{base_out_path}/{rel_out_path}/{plot.id}.csv
rel_out_path (
str
, optional) – path relative tobase_out_path
to store the plotformats (
list
ofVizFormat
, optional) – plot format (e.g., pdf)task (
Task
) – tasklog (
ReportLog
, optional) – log of plot
- Returns:
Status
: statusException
: exception for failurebool
: whethertask
contributes a variable to the plot
- Return type:
tuple
- biosimulators_utils.sedml.exec.exec_plot_3d(plot, variable_results, base_out_path, rel_out_path, formats, task, log)[source]#
Execute a 3D plot, generating the surfaces which are available
- Parameters:
plot (
Plot3D
) – plotvariable_results (
VariableResults
) – result of each data generatorbase_out_path (
str
) – base path to store the plot. Complete path is{base_out_path}/{rel_out_path}/{plot.id}.pdf
rel_out_path (
str
, optional) – path relative tobase_out_path
to store the plotformats (
list
ofVizFormat
, optional) – plot format (e.g., pdf)task (
Task
) – tasklog (
ReportLog
, optional) – log of plot
- Returns:
Status
: statusException
: exception for failurebool
: whethertask
contributes a variable to the plot
- Return type:
tuple
- biosimulators_utils.sedml.exec.exec_repeated_task(task, task_executer, task_vars, doc, apply_xml_model_changes=False, model_etrees=None, pretty_print_modified_xml_models=False, config=None, preprocessed_task=None, get_value_executer=None, set_value_executer=None, reset_executer=None)[source]#
Execute a repeated SED task
- Parameters:
task (
RepeatedTask
) – tasktask_executer (
types.FunctionType
) –function to execute each task in the SED-ML file. The function must implement the following interface:
def exec_task(task, variables, preprocessed_task=None, log=None, config=None, **simulator_config): ''' Execute a simulation and return its results Args: task (:obj:`Task`): task variables (:obj:`list` of :obj:`Variable`): variables that should be recorded preprocessed_task (:obj:`object`, optional): preprocessed information about the task, including possible model changes and variables. This can be used to avoid repeatedly executing the same initialization for repeated calls to this method. log (:obj:`TaskLog`, optional): log for the task config (:obj:`Config`, optional): BioSimulators common configuration **simulator_config (:obj:`dict`, optional): optional simulator-specific configuration Returns: :obj:`VariableResults`: results of variables ''' pass
task_vars (
list
ofVariable
) – variables that task must recorddoc (
SedDocument
orstr
) – SED document or a path to SED-ML file which defines a SED documentapply_xml_model_changes (
bool
, optional) – ifTrue
, apply any model changes specified in the SED-ML file before callingtask_executer
.model_etrees (
dict
ofstr
toetree._Element
)pretty_print_modified_xml_models (
bool
, optional) – ifTrue
, pretty print modified XML modelsconfig (
Config
, optional) – BioSimulators common configuration
- Returns:
results of the variables
- Return type:
VariableResults
- biosimulators_utils.sedml.exec.exec_report(report, variable_results, base_out_path, rel_out_path, formats, task, log=None, type=<class 'biosimulators_utils.sedml.data_model.Report'>)[source]#
Execute a report, generating the data sets which are available
- Parameters:
report (
Report
) – reportvariable_results (
VariableResults
) – result of each data generatorbase_out_path (
str
) –path to store the outputs
CSV: directory in which to save outputs to files
{base_out_path}/{rel_out_path}/{report.id}.csv
HDF5: directory in which to save a single HDF5 file (
{base_out_path}/reports.h5
), with reports at keys{rel_out_path}/{report.id}
within the HDF5 file
rel_out_path (
str
, optional) – path relative tobase_out_path
to store the outputsformats (
list
ofReportFormat
, optional) – report format (e.g., csv or h5)task (
Task
) – tasklog (
ReportLog
, optional) – log of reporttype (
types.Type
) – type of output (e.g., subclass ofOutput
such asReport
,Plot2D
)
- Returns:
DataSetResults
: reportStatus
: statusException
: exception for failurebool
: whethertask
contribute a variable to the report
- Return type:
tuple
- biosimulators_utils.sedml.exec.exec_sed_doc(task_executer, doc, working_dir, base_out_path, rel_out_path=None, apply_xml_model_changes=False, log=None, indent=0, pretty_print_modified_xml_models=False, log_level=StandardOutputErrorCapturerLevel.c, config=None, get_value_executer=None, set_value_executer=None, preprocessed_task_executer=None, reset_executer=None)[source]#
Execute the tasks specified in a SED document and generate the specified outputs
- Parameters:
task_executer (
types.FunctionType
) –function to execute each task in the SED-ML file. The function must implement the following interface:
def exec_task(task, variables, preprocessed_task=None, log=None, config=None, **simulator_config): ''' Execute a simulation and return its results Args: task (:obj:`Task`): task variables (:obj:`list` of :obj:`Variable`): variables that should be recorded preprocessed_task (:obj:`object`, optional): preprocessed information about the task, including possible model changes and variables. This can be used to avoid repeatedly executing the same initialization for repeated calls to this method. log (:obj:`TaskLog`, optional): log for the task config (:obj:`Config`, optional): BioSimulators common configuration **simulator_config (:obj:`dict`, optional): optional simulator-specific configuration Returns: :obj:`VariableResults`: results of variables ''' pass
doc (
SedDocument
orstr
) – SED document or a path to SED-ML file which defines a SED documentworking_dir (
str
) – working directory of the SED document (path relative to which models are located)base_out_path (
str
) –path to store the outputs
CSV: directory in which to save outputs to files
{base_out_path}/{rel_out_path}/{report.id}.csv
HDF5: directory in which to save a single HDF5 file (
{base_out_path}/reports.h5
), with reports at keys{rel_out_path}/{report.id}
within the HDF5 file
rel_out_path (
str
, optional) – path relative tobase_out_path
to store the outputsapply_xml_model_changes (
bool
, optional) – ifTrue
, apply any model changes specified in the SED-ML file before callingtask_executer
.log (
SedDocumentLog
, optional) – log of the documentindent (
int
, optional) – degree to indent status messagespretty_print_modified_xml_models (
bool
, optional) – ifTrue
, pretty print modified XML modelslog_level (
StandardOutputErrorCapturerLevel
, optional) – level at which to log outputconfig (
Config
) – configuration
- Returns:
ReportResults
: results of each reportSedDocumentLog
: log of the document
- Return type:
tuple
- biosimulators_utils.sedml.exec.exec_task(task, task_executer, task_vars, doc, log=None, config=None, preprocessed_task=None)[source]#
Execute a basic SED task
- Parameters:
task (
Task
) – tasktask_executer (
types.FunctionType
) –function to execute each task in the SED-ML file. The function must implement the following interface:
def exec_task(task, variables, preprocessed_task=None, log=None, config=None, **simulator_config): ''' Execute a simulation and return its results Args: task (:obj:`Task`): task variables (:obj:`list` of :obj:`Variable`): variables that should be recorded preprocessed_task (:obj:`object`, optional): preprocessed information about the task, including possible model changes and variables. This can be used to avoid repeatedly executing the same initialization for repeated calls to this method. log (:obj:`TaskLog`, optional): log for the task config (:obj:`Config`, optional): BioSimulators common configuration **simulator_config (:obj:`dict`, optional): optional simulator-specific configuration Returns: :obj:`tuple`: * :obj:`VariableResults`: results of variables * :obj:`TaskLog`: log ''' pass
task_vars (
list
ofVariable
) – variables that task must recorddoc (
SedDocument
orstr
) – SED document or a path to SED-ML file which defines a SED documentlog (
TaskLog
, optional) – logconfig (
Config
, optional) – BioSimulators common configuration
- Returns:
results of the variables
- Return type:
VariableResults
biosimulators_utils.sedml.io module#
Utilities for reading and writing SED documents to SED-ML files
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- class biosimulators_utils.sedml.io.SedmlSimulationReader[source]#
Bases:
object
SED-ML reader
- run(filename, validate_semantics=True, validate_models_with_languages=True, validate_targets_with_model_sources=True, config=None)[source]#
Base class for reading a SED document
- Parameters:
filename (
str
) – path to SED-ML documentvalidate_semantics (
bool
, optional) – ifTrue
, check that SED-ML is semantically validvalidate_models_with_languages (
bool
, optional) – ifTrue
, validate modelsvalidate_targets_with_model_sources (
bool
, optional) – ifTrue
, validate targets against their modelsconfig (
Config
, optional) – whether to fail on missing includes
- Returns:
SED document
- Return type:
data_model.SedDocument
- Raises:
ValueError – if any of the following conditions are met * The SED document contains changes other than instances of SedChangeAttribute * The models or simulations don’t have unique ids * A model or simulation references cannot be resolved
- class biosimulators_utils.sedml.io.SedmlSimulationWriter[source]#
Bases:
object
SED-ML writer
- _obj_to_sed_obj_map[source]#
map from data model objects to their corresponding libSED-ML objects
- Type:
object
=>object
- run(doc, filename, validate_semantics=True, validate_models_with_languages=True, validate_targets_with_model_sources=True, config=None)[source]#
Save a SED document to an SED-ML XML file
- Parameters:
doc (
data_model.SedDocument
) – SED documentfilename (
str
) – Path to save simulation experiment in SED-ML formatvalidate_semantics (
bool
, optional) – ifTrue
, check that SED-ML is semantically validvalidate_models_with_languages (
bool
, optional) – ifTrue
, validate modelsvalidate_targets_with_model_sources (
bool
, optional) – ifTrue
, validate targets against their modelsconfig (
Config
, optional) – whether to fail on missing includes
- Raises:
NotImplementedError – document uses an supported type of task or output
biosimulators_utils.sedml.math module#
Data model for SED
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.sedml.math.compile_math(math)[source]#
Compile a mathematical expression
- Parameters:
math (
str
) – mathematical expression- Returns:
compiled expression
- Return type:
_ast.Expression
- biosimulators_utils.sedml.math.eval_math(math, compiled_math, workspace)[source]#
Compile a mathematical expression
- Parameters:
math (
str
) – mathematical expressioncompiled_math (
_ast.Expression
) – compiled expressionworkspace (
dict
) – values to use for the symbols in the expression
- Returns:
result of the expression
- Return type:
object
- Raises:
ValueError – if the expression could not be evaluated
biosimulators_utils.sedml.model_utils module#
Utilities for working with models referenced by SED documents
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2021-04-05
- Copyright:
2021, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.sedml.model_utils.build_combine_archive_for_model(model_filename, model_language, simulation_type, archive_filename, extra_contents=None, config=None, **model_language_options)[source]#
Build A COMBINE/OMEX archive with a SED-ML file for a model
- Parameters:
model_filename (
str
) – path to model filemodel_language (
ModelLanguage
) – model languagesimulation_type (
type
) – subclass ofSimulation
archive_filename (
str
) – path to save COMBINE/OMEX archiveextra_contents (
dict
ofstr
->CombineArchiveContent
, optional) – dictionary that maps the local paths of additional files to include in the COMBINE/OMEX archive to their intended locations within the COMBINE/OMEX archiveconfig (
Config
, optional) – whether to fail on missing includes**model_language_options – additional options to pass to the methods for individual model formats
- biosimulators_utils.sedml.model_utils.get_parameters_variables_outputs_for_simulation(model_filename, model_language, simulation_type, algorithm_kisao_id=None, change_level=<class 'biosimulators_utils.sedml.data_model.SedDocument'>, native_ids=False, native_data_types=False, model_language_options=None)[source]#
Get the possible observables for a simulation of a model
This method supports the following formats
SBML
SBML-fbc
SBML-qual
- Parameters:
model_filename (
str
) – path to model filemodel_language (
str
) – model language (e.g.,urn:sedml:language:sbml
)simulation_type (
types.Type
) – subclass ofSimulation
algorithm_kisao_id (
str
, optional) – KiSAO id of the algorithm for simulating the model (e.g.,KISAO_0000019
for CVODE)change_level (
types.Type
, optional) – level at which model changes will be made (SedDocument
orTask
)native_ids (
bool
, optional) – whether to return the raw id and name of each model component rather than the suggested name for the variable of an associated SED-ML data generatornative_data_types (
bool
, optional) – whether to return new_values in their native data typesmodel_language_options (
dict
, optional) – additional options to pass to the methods for individual model formats. Dictionary that maps model languages (ModelLanguage
) to dictionaries of optional keyword arguments for each language
- Returns:
possible attributes of a model that can be changed and their default values
list
ofSimulation
: simulation of the modellist
ofVariable
: possible observables for a simulation of the modellist
ofPlot
: possible plots of the results of a simulation of the model- Return type:
list
ofModelAttributeChange
- Raises:
UnsupportedModelLanguageError – if
model_language
is not a supported language
biosimulators_utils.sedml.utils module#
Utilities for working with SED documents
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.sedml.utils.add_namespaces_to_xml_node(node, namespace_prefixes, namespaces)[source]#
Add namespaces to an XML node
- Parameters:
node (
libsedml.XMLNode
) – XML nodenamespace_prefixes (
set
ofstr
) – namespace prefixes used in the node which aren’t defined in the nodenamespaces (
libsedml.XMLNamespaces
) – namespaces for the parent document
- biosimulators_utils.sedml.utils.append_all_nested_children_to_doc(doc)[source]#
Append all nested children to a SED document
- Parameters:
doc (
SedDocument
) – SED document
- biosimulators_utils.sedml.utils.apply_changes_to_xml_model(model, model_etree, sed_doc=None, working_dir=None, variable_values=None, range_values=None, validate_unique_xml_targets=True, set_value_executer=None, preprocessed_task_sub_executer=None)[source]#
Modify an XML-encoded model according to a model change
- Parameters:
model (
Model
) – modelmodel_etree (
etree._ElementTree
) – element tree for modelsed_doc (
SedDocument
, optional) – parent SED document; used to resolve sources defined by reference to other models; required for compute changesworking_dir (
str
, optional) – working directory of the SED document (path relative to which models are located); required for compute changesvariable_values (
dict
, optional) – dictionary which contains the value of each variable of each compute model changerange_values (
dict
, optional) – dictionary which contains the value of each range of each set value compute model changevalidate_unique_xml_targets (
bool
, optional) – whether to validate the XML targets match uniue objects
- biosimulators_utils.sedml.utils.calc_compute_model_change_new_value(change, variable_values=None, range_values=None)[source]#
Calculate the new value of a compute model change
- Parameters:
change (
ComputeModelChange
) – changevariable_values (
dict
, optional) – dictionary which contains the value of each variable of each compute model changerange_values (
dict
, optional) – dictionary which contains the value of each range of each set value compute model change
- Returns:
new value
- Return type:
float
- biosimulators_utils.sedml.utils.calc_data_generator_results(data_generator, variable_results)[source]#
Calculate the results of a data generator from the results of its variables
- Parameters:
data_generator (
DataGenerator
) – data generatorvariable_results (
VariableResults
) – results for the variables of the data generator
- Returns:
result of data generator
- Return type:
numpy.ndarray
- biosimulators_utils.sedml.utils.calc_data_generators_results(data_generators, variable_results, output, task, make_shapes_consistent=True)[source]#
Calculator the values of a list of data generators
- Parameters:
data_generators (
list
ofDataGenerator
) – SED taskvariable_results (
VariableResults
) – results of the SED variables involved in the data generatorsoutput (
Output
) – SED outputtask (
Task
) – SED taskmake_shapes_consistent (
bool
, optional) – where to make the shapes of the data generators consistent (e.g., for concatenation into a table for a report)
- Returns:
DataGeneratorResults
: values of the data generatorsdict
ofstr
toStatus
: dictionary that maps the id of each data generator to its statusException
: exception for failuresbool
: where the task contributes to any of the data generators
- Return type:
tuple
- biosimulators_utils.sedml.utils.convert_xml_node_to_string(node)[source]#
Generate a string representation of an XML node
- Parameters:
node (
libsedml.XMLNode
) – XML node- Returns:
string representation of the node
- Return type:
str
- biosimulators_utils.sedml.utils.does_model_language_use_xpath_variable_targets(language)[source]#
Determine if the model language uses XPaths to target variables of data generators
- Parameters:
language (
str
) – language- Returns:
True
, if the model language is encoded in XML- Return type:
bool
- biosimulators_utils.sedml.utils.get_data_generators_for_output(output)[source]#
Get the data generators involved in an output
- Parameters:
output (
Output
) – report or plot- Returns:
data generators involved in the output
- Return type:
set
ofDataGenerator
- biosimulators_utils.sedml.utils.get_first_last_models_executed_by_task(task)[source]#
Get the models executed by a task in the order they are executed
- Parameters:
task (
Task
) – task- Returns:
models
- Return type:
tuple
ofModel
- biosimulators_utils.sedml.utils.get_model_changes_for_task(task)[source]#
Get the changes to models for a task
- Parameters:
task (
Task
) – task- Returns:
changes to the model
- Return type:
list
ofModelChange
- biosimulators_utils.sedml.utils.get_models_referenced_by_model_change(change)[source]#
Get the models referenced from a model change
- Parameters:
change (
ModelChange
) – model change- Returns:
models
- Return type:
set
ofModel
- biosimulators_utils.sedml.utils.get_models_referenced_by_range(range)[source]#
Get the models referenced by a range
- Parameters:
range (
Range
) – range- Returns:
models
- Return type:
set
ofModel
- biosimulators_utils.sedml.utils.get_models_referenced_by_task(task)[source]#
Get the models referenced from a task
- Parameters:
task (
Task
) – task- Returns:
models
- Return type:
set
ofModel
- biosimulators_utils.sedml.utils.get_namespaces_for_sed_object(obj)[source]#
Get the namespace prefixes and URIs defined for a SED object
- Parameters:
obj (
libsedml.SedBase
) – SED object- Returns:
dictionary that maps the prefixes of namespaces to their URIs
- Return type:
dict
- biosimulators_utils.sedml.utils.get_range_len(range)[source]#
Get the length of a range
- Parameters:
range (
Range
) – range- Returns:
length of the range
- Return type:
int
- Raises:
NotImplementedError – if range isn’t an instance of
UniformRange
,VectorRange
, orFunctionalRange
.
- biosimulators_utils.sedml.utils.get_task_results_shape(task)[source]#
Get the shape of the results of a task
- Parameters:
task (
Task
) – task- Returns:
shape of the results of a task
- Return type:
tuple
ofint
- biosimulators_utils.sedml.utils.get_value_of_variable_model_xml_targets(variable, model_etrees)[source]#
Get the value of a variable of a model
- Parameters:
variable (
Variable
) – variablemodel_etrees (
dict
ofstr
toetree._Element
) – dictionary that maps the ids of models to paths to files which contain their XML definitions
- Returns:
value
- Return type:
float
- biosimulators_utils.sedml.utils.get_values_of_variable_model_xml_targets_of_model_change(change, sed_doc, model_etrees, working_dir)[source]#
Get the values of the model variables of a compute model change
- Parameters:
change (
ComputeModelChange
) – compute model changesed_doc (
SedDocument
) – SED documentmodel_etrees (
dict
ofstr
toetree._Element
) – map from the ids of models to element trees of their sourcesworking_dir (
str
) – working directory of the SED document (path relative to which models are located)
- Returns:
- dictionary which contains the value of each variable of each
compute model change
- Return type:
dict
- biosimulators_utils.sedml.utils.get_variables_for_data_generators(data_generators)[source]#
Get the variables involved in a collection of generators
- Parameters:
data_generators (
list
ofDataGenerator
) – data generators- Returns:
variables involved in the data generators
- Return type:
set
ofVariable
- biosimulators_utils.sedml.utils.get_variables_for_task(doc, task)[source]#
Get the variables that a task must record
- Parameters:
doc (
SedDocument
) – SED documenttask (
Task
) – task
- Returns:
variables that task must record
- Return type:
list
ofVariable
- biosimulators_utils.sedml.utils.get_xml_node_namespace_tag_target(etree, target_namespaces=None)[source]#
Get the namespace, tag, and target of an XML node
- Parameters:
etree (
etree._Element
) – element treetarget_namespaces (
dict
, optional) – dictionary that maps the prefixes of namespaces to their URIs
- Returns:
str
: namespace URIstr
: namespace prefixstr
: tagstr
: target for use with SED target XPathsdict
: dictionary that maps the prefixes of namespaces to their URIs
- Return type:
tuple
- biosimulators_utils.sedml.utils.is_executable_task(doc: SedDocument, task: Task)[source]#
Check if a task actually has outputs that a simulator needs to find
- Parameters:
doc (
SedDocument
) – sedml documenttask (
Task
) – task
- Returns:
bool
value of whether the task is an “executable” one
- biosimulators_utils.sedml.utils.is_model_language_encoded_in_xml(language)[source]#
Determine if the model language is encoded in XML
- Parameters:
language (
str
) – language- Returns:
True
, if the model language is encoded in XML- Return type:
bool
- biosimulators_utils.sedml.utils.remove_algorithm_parameter_changes(sed_doc)[source]#
Remove algorithm parameter changes from a SED document
- Parameters:
sed_doc (
SedDocument
) – SED document
- biosimulators_utils.sedml.utils.remove_model_changes(sed_doc)[source]#
Remove model changes from a SED document
- Parameters:
sed_doc (
SedDocument
) – SED document
- biosimulators_utils.sedml.utils.remove_plots(sed_doc)[source]#
Remove plots from a SED document
- Parameters:
sed_doc (
SedDocument
) – SED document
- biosimulators_utils.sedml.utils.replace_complex_data_generators_with_generators_for_individual_variables(sed_doc)[source]#
Remove model changes from a SED document
- Parameters:
sed_doc (
SedDocument
) – SED document
- biosimulators_utils.sedml.utils.resolve_model(model, sed_doc, working_dir)[source]#
Resolve the source of a model
- Parameters:
model (
Model
) –model whose
source
is one of the followingA path to a file
A URL
A MIRIAM URN for an entry in the BioModelsl database (e.g.,
urn:miriam:biomodels.db:BIOMD0000000012
)A reference to another model, using the
id
of the other model (e.g.,#other-model-id
). In this case, the model also inherits changes from the parent model.
sed_doc (
SedDocument
) – parent SED document; used to resolve sources defined by reference to other modelsworking_dir (
str
) – working directory of the SED document (path relative to which models are located)
- Returns:
temporary path to the source of the modified model, if the model needed to be resolved from
- Return type:
str
- biosimulators_utils.sedml.utils.resolve_model_and_apply_xml_changes(orig_model, sed_doc, working_dir, apply_xml_model_changes=True, save_to_file=True, pretty_print_modified_xml_models=False, set_value_executer=None, preprocessed_task_sub_executer=None)[source]#
Resolve the source of a model and, optionally, apply XML changes to the model.
- Parameters:
model (
Model
) –model whose
source
is one of the followingA path to a file
A URL
A MIRIAM URN for an entry in the BioModelsl database (e.g.,
urn:miriam:biomodels.db:BIOMD0000000012
)A reference to another model, using the
id
of the other model (e.g.,#other-model-id
). In this case, the model also inherits changes from the parent model.
sed_doc (
SedDocument
) – parent SED document; used to resolve sources defined by reference to other modelsworking_dir (
str
) – working directory of the SED document (path relative to which models are located)apply_xml_model_changes (
bool
, optional) – ifTrue
, apply any model changes specified in the SED-ML file before callingtask_executer
.save_to_file (
bool
) – whether to save the resolved/modified model to a filepretty_print_modified_xml_models (
bool
, optional) – ifTrue
, pretty print modified XML models
- Returns:
Model
: modified modelstr
: temporary path to the source of the modified model, if the model needed to be resolved from a remote source of modifiedetree._Element
: element tree for the resolved/modified model
- Return type:
tuple
- biosimulators_utils.sedml.utils.resolve_range(range, model_etrees=None)[source]#
Resolve the values of a range
- Parameters:
range (
Range
) – rangemodel_etrees (
dict
ofstr
toetree._Element
) – map from the ids of models to element trees of their sources; required to resolve variables of functional ranges
- Returns:
values of the range
- Return type:
list
offloat
- Raises:
NotImplementedError – if range isn’t an instance of
UniformRange
,VectorRange
, orFunctionalRange
.
biosimulators_utils.sedml.validation module#
Methods for validating SED objects
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-09
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.sedml.validation.validate_algorithm(algorithm)[source]#
Validate an algorithm
- Parameters:
algorithm (
Algorithm
) – algorithm- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_calculation(calculation)[source]#
Validate that all of the symbols needed for a calculation are defined
- Parameters:
expression (
Calculation
)- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of warmings (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_data_generator(data_generator, model_etrees=None, validate_targets_with_model_sources=True)[source]#
Validate a data generator
Parameters have ids
Variables have ids
Variables have target OR symbol
Variables don’t have model references
Have math
Math is valid
- Parameters:
data_generator (
DataGenerator
) – data generatormodel_etrees (
dict
, optional) – dictionary that maps models to XML element trees of their sourcesvalidate_targets_with_model_sources (
bool
, optional) – whether to validate the targets of the variables of the data generator
- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of warnings (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_data_generator_variables(variables, model_etrees=None, validate_targets_with_model_sources=True)[source]#
Check variables have a symbol or target
- Parameters:
variables (
list
ofVariable
) – variablesmodel_etrees (
dict
, optional) – dictionary that maps models to XML element trees of their sourcesvalidate_targets_with_model_sources (
bool
, optional) – whether to validate the targets of the variables of the data generator
- Returns:
nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
nested
list
ofstr
- biosimulators_utils.sedml.validation.validate_doc(doc, working_dir, validate_semantics=True, validate_models_with_languages=True, validate_targets_with_model_sources=True, config=None)[source]#
Validate a SED document
- Parameters:
doc (
SedDocument
) – SED documentworking_dir (
str
) – working directory (e.g., for referencing model files)validate_semantics (
bool
, optional) – ifTrue
, check that SED-ML is semantically validvalidate_models_with_languages (
bool
, optional) – ifTrue
, validate modelsvalidate_targets_with_model_sources (
bool
, optional) – ifTrue
, validate targets against their modelsconfig (
Config
, optional) – whether to fail on missing includes
- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_model(model, model_ids, working_dir, validate_models_with_languages=True, config=None, check_in_model_source=True, model_etree=None)[source]#
Check a model
- Parameters:
model (
Model
) – modelmodel_ids (
list
ofstr
) – ids of modelsworking_dir (
str
) – working directory (e.g., for referencing model files)validate_models_with_languages (
bool
, optional) – ifTrue
, validate modelsconfig (
Config
, optional) – whether to fail on missing includes
- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of warnings (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_model_change_types(changes, types=(<class 'biosimulators_utils.sedml.data_model.ModelChange'>, ))[source]#
Check that model changes are valid
- Parameters:
changes (
list
ofModelChange
) – model changestypes (
type
ortuple
oftype
, optional) – valid type(s) of model changes
- Returns:
nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
nested
list
ofstr
- biosimulators_utils.sedml.validation.validate_model_changes(model, check_in_model_source=True, model_etree=None)[source]#
Check that model changes are semantically valid
Check that the variables of compute model changes are valid
- Parameters:
model (
Model
) – model- Returns:
nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
nested
list
ofstr
- biosimulators_utils.sedml.validation.validate_model_language(language, valid_languages)[source]#
Check that model is encoded in a specific language
- Parameters:
language (
str
) – model languagevalid_language (
ModelLanguage
orlist
ofModelLanguage
) – valid language(s)
- Returns:
nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
nested
list
ofstr
- biosimulators_utils.sedml.validation.validate_model_source(model, model_ids, working_dir, validate_models_with_languages=True, config=None)[source]#
Check the source of a model
- Parameters:
model (
Model
) – modelmodel_ids (
list
ofstr
) – ids of modelsworking_dir (
str
) – working directory (e.g., for referencing model files)validate_models_with_languages (
bool
, optional) – ifTrue
, validate modelsconfig (
Config
, optional) – whether to fail on missing includes
- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of warnings (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_model_with_language(source, language, name=None, config=None)[source]#
Check that a model is valid
- Parameters:
source (
str
) – path to modellanguage (
ModelLanguage
) – languagename (
str
, optional) – name of model for use in error messagesconfig (
Config
, optional) – whether to fail on missing includes
- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)object
: model object
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_output(output)[source]#
Validate an output
Reports * Data sets have ids and labels * Data sets reference data generators
Plots
Curves and surfaces have ids
x, y, z attributes reference data generators
- Parameters:
output (
Output
) – output- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of warnings (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_reference(obj, obj_label, attr_name, attr_label)[source]#
- biosimulators_utils.sedml.validation.validate_repeated_task_has_one_model(task)[source]#
Validate a that a repeated task involves a single model
- Parameters:
task (
RepeatedTask
) – repeated task- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of warnings (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_simulation(simulation)[source]#
Check that simulation is a valid simulation
- Parameters:
simulation (
Simulation
) – simulation- Returns:
nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)nested
list
ofstr
: nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
tuple
- biosimulators_utils.sedml.validation.validate_simulation_type(simulation, types)[source]#
Check that simulation is a time course simulation
- Parameters:
simulation (
Simulation
) – simulationtypes (
type
) – valid simulation types
- Returns:
nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
nested
list
ofstr
- biosimulators_utils.sedml.validation.validate_target(target, namespaces, context, language, model_id, model_etree=None, doc=None, check_in_model_source=False, warn_xpaths_not_validated=True, model_change=False)[source]#
Validate that a target is a valid XPath and that the namespaces needed to resolve a target are defined
- Parameters:
target (
str
) – XPath to a model element or attributenamespaces (
dict
) – dictionary that maps prefixes of namespaces to their URIscontext (
type
)language (
str
) – model languagemodel_id (
str
) – model idmodel_etree (
etree.Element
, optional) – XML element tree for model sourcedoc (
SedDocument
, optional) – SED documentcheck_in_model_source (
bool
, optional) – whether to check that the target exists in the sourcewarn_xpaths_not_validated (
bool
, optional) – whether to warn that XPaths cannot be validatedmodel_changes (
bool
, optional) – whether the model has changes that could validate or invalidate XPaths.
- Returns:
nested list of errors (e.g., required ids missing or ids not unique)
- Return type:
nested
list
ofstr
- biosimulators_utils.sedml.validation.validate_target_xpaths(targets, model_etree, attr='id', separator=None)[source]#
Validate that the target of each model change or variable matches one object in an XML-encoded model and, optionally, return the value of one of its attributes.
- Parameters:
targets (
list
ofTargetGroupMixin
) – model changes or variablesmodel_source (
lxml.etree._ElementTree
) – element tree for the XML model documentattr (
str
, optional) – attribute to get values ofseparator (
str
, optional) – string to use when combining attributes into a single id (i.e. ‘J0.n’ from ‘J0’ and ‘n’.) If None, don’t combine and just use final id.
- Returns:
- dictionary that maps each XPath to the
value of the attribute of the object in the XML file that matches the XPath
- Return type:
dict
ofstr
tostr
biosimulators_utils.sedml.warnings module#
Warnings for misuse of SED-ML
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- exception biosimulators_utils.sedml.warnings.IllogicalSedmlWarning[source]#
Bases:
BioSimulatorsWarning
Warning that a SED document is illogical, such as when a report or plot contains no datasets, curves, or surfaces.
- exception biosimulators_utils.sedml.warnings.InconsistentVariableShapesWarning[source]#
Bases:
BioSimulatorsWarning
Warning that the variables of a data generator have different shapes.
- exception biosimulators_utils.sedml.warnings.NoCurvesWarning[source]#
Bases:
IllogicalSedmlWarning
Warning that a 2D plot does not contain any curves
- exception biosimulators_utils.sedml.warnings.NoDataSetsWarning[source]#
Bases:
IllogicalSedmlWarning
Warning that a report does not contain any data sets
- exception biosimulators_utils.sedml.warnings.NoOutputsWarning[source]#
Bases:
IllogicalSedmlWarning
Warning that a SED document does not have any outputs
- exception biosimulators_utils.sedml.warnings.NoSurfacesWarning[source]#
Bases:
IllogicalSedmlWarning
Warning that a 3D plot does not contain any surfaces
- exception biosimulators_utils.sedml.warnings.NoTasksWarning[source]#
Bases:
IllogicalSedmlWarning
Warning that a SED document does not have any tasks
- exception biosimulators_utils.sedml.warnings.SedmlFeatureNotSupportedWarning[source]#
Bases:
BioSimulatorsWarning
Warning that a feature of a SED document was skipped because it requires a SED feature that is not yet supported. The warning is only used when skipping a portion of a document doesn’t affect the semantic meaning of the unskipped portions of the document (e.g., skipping generating a plot doesn’t adversely affect reports).