Meta-model
Template model (mira.metamodel.template_model
)
- pydantic model Annotations[source]
Bases:
BaseModel
A metadata model for model-level annotations.
Examples in this metadata model are taken from https://www.ebi.ac.uk/biomodels/BIOMD0000000956, a well-annotated SIR model in the BioModels database.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Annotations", "description": "A metadata model for model-level annotations.\n\nExamples in this metadata model are taken from\nhttps://www.ebi.ac.uk/biomodels/BIOMD0000000956,\na well-annotated SIR model in the BioModels database.", "type": "object", "properties": { "name": { "title": "Name", "description": "A human-readable label for the model", "example": "SIR model of scenarios of COVID-19 spread in CA and NY", "type": "string" }, "description": { "title": "Description", "description": "A description of the model", "example": "The coronavirus disease 2019 (COVID-19) pandemic has placed epidemic modeling at the forefront of worldwide public policy making. Nonetheless, modeling and forecasting the spread of COVID-19 remains a challenge. Here, we detail three regional scale models for forecasting and assessing the course of the pandemic. This work demonstrates the utility of parsimonious models for early-time data and provides an accessible framework for generating policy-relevant insights into its course. We show how these models can be connected to each other and to time series data for a particular region. Capable of measuring and forecasting the impacts of social distancing, these models highlight the dangers of relaxing nonpharmaceutical public health interventions in the absence of a vaccine or antiviral therapies.", "type": "string" }, "license": { "title": "License", "description": "Information about the licensing of the model artifact. Ideally, given as an SPDX identifier like CC0 or CC-BY-4.0. For example, models from the BioModels databases are all licensed under the CC0 public attribution license.", "example": "CC0", "type": "string" }, "authors": { "title": "Authors", "description": "A list of authors/creators of the model. This is not the same as the people who e.g., submitted the model to BioModels", "example": [ "name='Andrea L Bertozzi'", "name='Elisa Franco'", "name='George Mohler'", "name='Martin B Short'", "name='Daniel Sledge'" ], "type": "array", "items": { "$ref": "#/definitions/Author" } }, "references": { "title": "References", "description": "A list of CURIEs (i.e., <prefix>:<identifier>) corresponding to literature references that describe the model. Do **not** duplicate the same publication with different CURIEs (e.g., using pubmed, pmc, and doi)", "example": [ "pubmed:32616574" ], "type": "array", "items": { "type": "string" } }, "time_scale": { "title": "Time Scale", "description": "The granularity of the time element of the model, typically on the scale of days, weeks, or months for epidemiology models", "example": "day", "type": "string" }, "time_start": { "title": "Time Start", "description": "The start time of the applicability of a model, given as a datetime. When the time scale is not so granular, leave the less granular fields as default, i.e., if the time scale is on months, give dates like YYYY-MM-01 00:00", "type": "string", "format": "date-time" }, "time_end": { "title": "Time End", "description": "Similar to the start time of the applicability of a model, the end time is given as a datetime. For example, the Bertozzi 2020 model is applicable between March and August 2020, so this field is annotated with August 1st, 2020.", "type": "string", "format": "date-time" }, "locations": { "title": "Locations", "description": "A location or list of locations where this model is applicable, ideally annotated using a CURIEs referencing a controlled vocabulary such as GeoNames, which has multiple levels of granularity including city/state/country level terms. For example,the Bertozzi 2020 model was for New York City (geonames:5128581) and California (geonames:5332921)", "example": [ "geonames:5128581", "geonames:5332921" ], "type": "array", "items": { "type": "string" } }, "pathogens": { "title": "Pathogens", "description": "The pathogens present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about SARS-CoV-2, this is ncbitaxon:2697049. Do not confuse this field with terms for annotating the disease caused by the pathogen. Note that some models may have multiple pathogens, for simulating double pandemics such as the interaction with SARS-CoV-2 and the seasonal flu.", "example": [ "ncbitaxon:2697049" ], "type": "array", "items": { "type": "string" } }, "diseases": { "title": "Diseases", "description": "The diseases caused by pathogens in the model, given with CURIEs referencing vocabulary for dieases, such as DOID, EFO, or MONDO. For example, the Bertozzi 2020 model is about SARS-CoV-2, which causes COVID-19. In the Human Disease Ontology (DOID), this is referenced by doid:0080600.", "example": [ "doid:0080600" ], "type": "array", "items": { "type": "string" } }, "hosts": { "title": "Hosts", "description": "The hosts present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about human infection by SARS-CoV-2. Therefore, the appropriate annotation for this field would be ncbitaxon:9606. Note that some models have multiple hosts, such as Malaria models that consider humans and mosquitos.", "example": [ "ncbitaxon:9606" ], "type": "array", "items": { "type": "string" } }, "model_types": { "title": "Model Types", "description": "This field describes the type(s) of the model using the Mathematical Modeling Ontology (MAMO), which has terms like 'ordinary differential equation model', 'population model', etc. These should be annotated as CURIEs in the form of mamo:<local unique identifier>. For example, the Bertozzi 2020 model is a population model (mamo:0000028) and ordinary differential equation model (mamo:0000046)", "example": [ "mamo:0000028", "mamo:0000046" ], "type": "array", "items": { "type": "string" } } }, "definitions": { "Author": { "title": "Author", "description": "A metadata model for an author.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the author", "type": "string" } }, "required": [ "name" ] } } }
- Fields:
-
field authors:
List
[Author
] [Optional] A list of authors/creators of the model. This is not the same as the people who e.g., submitted the model to BioModels
-
field diseases:
List
[str
] [Optional] The diseases caused by pathogens in the model, given with CURIEs referencing vocabulary for dieases, such as DOID, EFO, or MONDO. For example, the Bertozzi 2020 model is about SARS-CoV-2, which causes COVID-19. In the Human Disease Ontology (DOID), this is referenced by doid:0080600.
-
field hosts:
List
[str
] [Optional] The hosts present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about human infection by SARS-CoV-2. Therefore, the appropriate annotation for this field would be ncbitaxon:9606. Note that some models have multiple hosts, such as Malaria models that consider humans and mosquitos.
-
field license:
Optional
[str
] = None Information about the licensing of the model artifact. Ideally, given as an SPDX identifier like CC0 or CC-BY-4.0. For example, models from the BioModels databases are all licensed under the CC0 public attribution license.
-
field locations:
List
[str
] [Optional] A location or list of locations where this model is applicable, ideally annotated using a CURIEs referencing a controlled vocabulary such as GeoNames, which has multiple levels of granularity including city/state/country level terms. For example,the Bertozzi 2020 model was for New York City (geonames:5128581) and California (geonames:5332921)
-
field model_types:
List
[str
] [Optional] This field describes the type(s) of the model using the Mathematical Modeling Ontology (MAMO), which has terms like ‘ordinary differential equation model’, ‘population model’, etc. These should be annotated as CURIEs in the form of mamo:<local unique identifier>. For example, the Bertozzi 2020 model is a population model (mamo:0000028) and ordinary differential equation model (mamo:0000046)
-
field pathogens:
List
[str
] [Optional] The pathogens present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about SARS-CoV-2, this is ncbitaxon:2697049. Do not confuse this field with terms for annotating the disease caused by the pathogen. Note that some models may have multiple pathogens, for simulating double pandemics such as the interaction with SARS-CoV-2 and the seasonal flu.
-
field references:
List
[str
] [Optional] A list of CURIEs (i.e., <prefix>:<identifier>) corresponding to literature references that describe the model. Do not duplicate the same publication with different CURIEs (e.g., using pubmed, pmc, and doi)
-
field time_end:
Optional
[datetime
] = None Similar to the start time of the applicability of a model, the end time is given as a datetime. For example, the Bertozzi 2020 model is applicable between March and August 2020, so this field is annotated with August 1st, 2020.
- pydantic model TemplateModel[source]
Bases:
BaseModel
A template model.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "TemplateModel", "description": "A template model.", "type": "object", "properties": { "templates": { "title": "Templates", "description": "A list of any child class of Templates", "type": "array", "items": { "discriminator": { "propertyName": "type", "mapping": { "NaturalConversion": "#/definitions/NaturalConversion", "ControlledConversion": "#/definitions/ControlledConversion", "NaturalDegradation": "#/definitions/NaturalDegradation", "ControlledDegradation": "#/definitions/ControlledDegradation", "GroupedControlledDegradation": "#/definitions/GroupedControlledDegradation", "NaturalProduction": "#/definitions/NaturalProduction", "ControlledProduction": "#/definitions/ControlledProduction", "GroupedControlledConversion": "#/definitions/GroupedControlledConversion", "GroupedControlledProduction": "#/definitions/GroupedControlledProduction", "NaturalReplication": "#/definitions/NaturalReplication", "ControlledReplication": "#/definitions/ControlledReplication", "StaticConcept": "#/definitions/StaticConcept" } }, "oneOf": [ { "$ref": "#/definitions/NaturalConversion" }, { "$ref": "#/definitions/ControlledConversion" }, { "$ref": "#/definitions/NaturalDegradation" }, { "$ref": "#/definitions/ControlledDegradation" }, { "$ref": "#/definitions/GroupedControlledDegradation" }, { "$ref": "#/definitions/NaturalProduction" }, { "$ref": "#/definitions/ControlledProduction" }, { "$ref": "#/definitions/GroupedControlledConversion" }, { "$ref": "#/definitions/GroupedControlledProduction" }, { "$ref": "#/definitions/NaturalReplication" }, { "$ref": "#/definitions/ControlledReplication" }, { "$ref": "#/definitions/StaticConcept" } ] } }, "parameters": { "title": "Parameters", "description": "A dict of parameter values where keys correspond to how the parameter appears in rate laws.", "type": "object", "additionalProperties": { "$ref": "#/definitions/Parameter" } }, "initials": { "title": "Initials", "description": "A dict of initial condition values where keyscorrespond to concept names they apply to.", "type": "object", "additionalProperties": { "$ref": "#/definitions/Initial" } }, "observables": { "title": "Observables", "description": "A list of observables that are readouts from the model.", "type": "object", "additionalProperties": { "$ref": "#/definitions/Observable" } }, "annotations": { "title": "Annotations", "description": "A structure containing model-level annotations. Note that all annotations are optional.", "allOf": [ { "$ref": "#/definitions/Annotations" } ] }, "time": { "title": "Time", "description": "A structure containing time-related annotations. Note that all annotations are optional.", "allOf": [ { "$ref": "#/definitions/Time" } ] } }, "required": [ "templates" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} }, "NaturalConversion": { "title": "NaturalConversion", "description": "Specifies a process of natural conversion from subject to outcome", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalConversion", "const": "NaturalConversion", "enum": [ "NaturalConversion" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject", "outcome" ] }, "ControlledConversion": { "title": "ControlledConversion", "description": "Specifies a process of controlled conversion from subject to outcome,\ncontrolled by the controller.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledConversion", "const": "ControlledConversion", "enum": [ "ControlledConversion" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject", "outcome" ] }, "NaturalDegradation": { "title": "NaturalDegradation", "description": "A template for the degradataion of a species at a proportional rate to its amount.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalDegradation", "const": "NaturalDegradation", "enum": [ "NaturalDegradation" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ] }, "ControlledDegradation": { "title": "ControlledDegradation", "description": "Specifies a process of degradation controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledDegradation", "const": "ControlledDegradation", "enum": [ "ControlledDegradation" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject" ] }, "GroupedControlledDegradation": { "title": "GroupedControlledDegradation", "description": "Specifies a process of degradation controlled by several controllers", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledDegradation", "const": "GroupedControlledDegradation", "enum": [ "GroupedControlledDegradation" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "subject" ] }, "NaturalProduction": { "title": "NaturalProduction", "description": "A template for the production of a species at a constant rate.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalProduction", "const": "NaturalProduction", "enum": [ "NaturalProduction" ], "type": "string" }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the production.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "outcome" ] }, "ControlledProduction": { "title": "ControlledProduction", "description": "Specifies a process of production controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledProduction", "const": "ControlledProduction", "enum": [ "ControlledProduction" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "Provenance of the template", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "outcome" ] }, "GroupedControlledConversion": { "title": "GroupedControlledConversion", "description": "The Template is a parent class for model processes", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledConversion", "const": "GroupedControlledConversion", "enum": [ "GroupedControlledConversion" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "subject", "outcome" ] }, "GroupedControlledProduction": { "title": "GroupedControlledProduction", "description": "Specifies a process of production controlled by several controllers", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledProduction", "const": "GroupedControlledProduction", "enum": [ "GroupedControlledProduction" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the production.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the production.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "outcome" ] }, "NaturalReplication": { "title": "NaturalReplication", "description": "Specifies a process of natural replication of a subject.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalReplication", "const": "NaturalReplication", "enum": [ "NaturalReplication" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the template.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ] }, "ControlledReplication": { "title": "ControlledReplication", "description": "Specifies a process of replication controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledReplication", "const": "ControlledReplication", "enum": [ "ControlledReplication" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the replication.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject" ] }, "StaticConcept": { "title": "StaticConcept", "description": "Specifies a standalone Concept that is not part of a process.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "StaticConcept", "const": "StaticConcept", "enum": [ "StaticConcept" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ] }, "Distribution": { "title": "Distribution", "description": "A distribution of values for a parameter.", "type": "object", "properties": { "type": { "title": "Type", "description": "The type of distribution, e.g. 'uniform', 'normal', etc.", "type": "string" }, "parameters": { "title": "Parameters", "description": "The parameters of the distribution.", "type": "object", "additionalProperties": { "type": "number" } } }, "required": [ "type", "parameters" ] }, "Parameter": { "title": "Parameter", "description": "A Parameter is a special type of Concept that carries a value.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] }, "value": { "title": "Value", "description": "Value of the parameter.", "type": "number" }, "distribution": { "title": "Distribution", "description": "A distribution of values for the parameter.", "allOf": [ { "$ref": "#/definitions/Distribution" } ] } }, "required": [ "name" ] }, "Initial": { "title": "Initial", "description": "Represents the initial conditions for parameters present in the\nmodel.", "type": "object", "properties": { "concept": { "title": "Concept", "description": "The concept associated with the initial.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "expression": { "title": "Expression", "description": "The expression for the initial.", "type": "string", "example": "2*x" } }, "required": [ "concept", "expression" ] }, "Observable": { "title": "Observable", "description": "An observable is a special type of Concept that carries an expression.\n\nObservables are used to define the readouts of a model, useful when a\nreadout is not defined as a state variable but is rather a function of\nstate variables.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] }, "expression": { "title": "Expression", "description": "The expression for the observable.", "type": "string", "example": "2*x" } }, "required": [ "name", "expression" ] }, "Author": { "title": "Author", "description": "A metadata model for an author.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the author", "type": "string" } }, "required": [ "name" ] }, "Annotations": { "title": "Annotations", "description": "A metadata model for model-level annotations.\n\nExamples in this metadata model are taken from\nhttps://www.ebi.ac.uk/biomodels/BIOMD0000000956,\na well-annotated SIR model in the BioModels database.", "type": "object", "properties": { "name": { "title": "Name", "description": "A human-readable label for the model", "example": "SIR model of scenarios of COVID-19 spread in CA and NY", "type": "string" }, "description": { "title": "Description", "description": "A description of the model", "example": "The coronavirus disease 2019 (COVID-19) pandemic has placed epidemic modeling at the forefront of worldwide public policy making. Nonetheless, modeling and forecasting the spread of COVID-19 remains a challenge. Here, we detail three regional scale models for forecasting and assessing the course of the pandemic. This work demonstrates the utility of parsimonious models for early-time data and provides an accessible framework for generating policy-relevant insights into its course. We show how these models can be connected to each other and to time series data for a particular region. Capable of measuring and forecasting the impacts of social distancing, these models highlight the dangers of relaxing nonpharmaceutical public health interventions in the absence of a vaccine or antiviral therapies.", "type": "string" }, "license": { "title": "License", "description": "Information about the licensing of the model artifact. Ideally, given as an SPDX identifier like CC0 or CC-BY-4.0. For example, models from the BioModels databases are all licensed under the CC0 public attribution license.", "example": "CC0", "type": "string" }, "authors": { "title": "Authors", "description": "A list of authors/creators of the model. This is not the same as the people who e.g., submitted the model to BioModels", "example": [ "name='Andrea L Bertozzi'", "name='Elisa Franco'", "name='George Mohler'", "name='Martin B Short'", "name='Daniel Sledge'" ], "type": "array", "items": { "$ref": "#/definitions/Author" } }, "references": { "title": "References", "description": "A list of CURIEs (i.e., <prefix>:<identifier>) corresponding to literature references that describe the model. Do **not** duplicate the same publication with different CURIEs (e.g., using pubmed, pmc, and doi)", "example": [ "pubmed:32616574" ], "type": "array", "items": { "type": "string" } }, "time_scale": { "title": "Time Scale", "description": "The granularity of the time element of the model, typically on the scale of days, weeks, or months for epidemiology models", "example": "day", "type": "string" }, "time_start": { "title": "Time Start", "description": "The start time of the applicability of a model, given as a datetime. When the time scale is not so granular, leave the less granular fields as default, i.e., if the time scale is on months, give dates like YYYY-MM-01 00:00", "type": "string", "format": "date-time" }, "time_end": { "title": "Time End", "description": "Similar to the start time of the applicability of a model, the end time is given as a datetime. For example, the Bertozzi 2020 model is applicable between March and August 2020, so this field is annotated with August 1st, 2020.", "type": "string", "format": "date-time" }, "locations": { "title": "Locations", "description": "A location or list of locations where this model is applicable, ideally annotated using a CURIEs referencing a controlled vocabulary such as GeoNames, which has multiple levels of granularity including city/state/country level terms. For example,the Bertozzi 2020 model was for New York City (geonames:5128581) and California (geonames:5332921)", "example": [ "geonames:5128581", "geonames:5332921" ], "type": "array", "items": { "type": "string" } }, "pathogens": { "title": "Pathogens", "description": "The pathogens present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about SARS-CoV-2, this is ncbitaxon:2697049. Do not confuse this field with terms for annotating the disease caused by the pathogen. Note that some models may have multiple pathogens, for simulating double pandemics such as the interaction with SARS-CoV-2 and the seasonal flu.", "example": [ "ncbitaxon:2697049" ], "type": "array", "items": { "type": "string" } }, "diseases": { "title": "Diseases", "description": "The diseases caused by pathogens in the model, given with CURIEs referencing vocabulary for dieases, such as DOID, EFO, or MONDO. For example, the Bertozzi 2020 model is about SARS-CoV-2, which causes COVID-19. In the Human Disease Ontology (DOID), this is referenced by doid:0080600.", "example": [ "doid:0080600" ], "type": "array", "items": { "type": "string" } }, "hosts": { "title": "Hosts", "description": "The hosts present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about human infection by SARS-CoV-2. Therefore, the appropriate annotation for this field would be ncbitaxon:9606. Note that some models have multiple hosts, such as Malaria models that consider humans and mosquitos.", "example": [ "ncbitaxon:9606" ], "type": "array", "items": { "type": "string" } }, "model_types": { "title": "Model Types", "description": "This field describes the type(s) of the model using the Mathematical Modeling Ontology (MAMO), which has terms like 'ordinary differential equation model', 'population model', etc. These should be annotated as CURIEs in the form of mamo:<local unique identifier>. For example, the Bertozzi 2020 model is a population model (mamo:0000028) and ordinary differential equation model (mamo:0000046)", "example": [ "mamo:0000028", "mamo:0000046" ], "type": "array", "items": { "type": "string" } } } }, "Time": { "title": "Time", "description": "A special type of Concept that represents time.", "type": "object", "properties": { "name": { "title": "Name", "description": "The symbol of the time variable in the model.", "default": "t", "type": "string" }, "units": { "title": "Units", "description": "The units of the time variable.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } } } } }
- Config:
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function TemplateModel.Config.<lambda> at 0x7fe6142ce7a0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function TemplateModel.Config.<lambda> at 0x7fe6142ce660>}
- Fields:
-
field annotations:
Optional
[Annotations
] = None A structure containing model-level annotations. Note that all annotations are optional.
-
field initials:
Dict
[str
,Initial
] [Optional] A dict of initial condition values where keyscorrespond to concept names they apply to.
-
field observables:
Dict
[str
,Observable
] [Optional] A list of observables that are readouts from the model.
-
field parameters:
Dict
[str
,Parameter
] [Optional] A dict of parameter values where keys correspond to how the parameter appears in rate laws.
-
field templates:
List
[Union
[NaturalConversion
,ControlledConversion
,NaturalDegradation
,ControlledDegradation
,GroupedControlledDegradation
,NaturalProduction
,ControlledProduction
,GroupedControlledConversion
,GroupedControlledProduction
,NaturalReplication
,ControlledReplication
,StaticConcept
]] [Required] A list of any child class of Templates
-
field time:
Optional
[Time
] = None A structure containing time-related annotations. Note that all annotations are optional.
- add_parameter(parameter_id, name=None, description=None, value=None, distribution=None, units_mathml=None)[source]
Add a parameter to the template model.
- Parameters:
parameter_id (
str
) – The id of the parameter.name (
str
) – The name of the parameter.description (
str
) – The description of the parameter.value (
float
) – The value of the newly added parameter.distribution (Dict[str,Any]) – Dictionary of distribution attributes to their values to be passed into the Distribution constructor.
units_mathml (
str
) – The unit of the parameter in mathml form.
- add_template(template, parameter_mapping=None, initial_mapping=None)[source]
Add a template to the model.
- Parameters:
- Return type:
- Returns:
A new model with the additional template
- add_transition(transition_name=None, subject_concept=None, outcome_concept=None, rate_law_sympy=None, params_dict=None, mass_action_parameter=None)[source]
Add a transition to a template model. Only Natural templates between a source and an outcome are supported. Multiple parameters can be added explicitly or implicitly.
- Parameters:
transition_name (
str
) – Name of the new transition to be added.subject_concept (
Concept
) – The subject of the new transition.outcome_concept (
Concept
) – The outcome of the new transition.rate_law_sympy (
SympyExprStr
) – The rate law associated with the new transition.params_dict (
Mapping
) – Mapping of parameter attribute to their respective values.mass_action_parameter (
Optional
[Parameter
]) – The mass action parameter that will be set to the transition’s mass action rate law if provided.
- Return type:
- Returns:
The new template model with the added transition.
- draw_graph(path, use_display_name=False, prog='dot', args='', format=None)[source]
Draw a pygraphviz graph of the TemplateModel.
- Parameters:
path (
str
) – The path to the output file.use_display_name (
bool
) – Whether to use the display_name attribute of the concepts as the label in the graph.prog (
str
) – The graphviz layout program to use, such as “dot”, “neato”, etc.args (
str
) – Additional arguments to pass to the graphviz bash program as a string. Example: args=”-Nshape=box -Edir=forward -Ecolor=red”.
- draw_jupyter(path='model.png', use_display_name=False, prog='dot', args='', format=None)[source]
Display in jupyter.
- Parameters:
path (
str
) – The path to the output file.use_display_name (
bool
) – Whether to use the display_name attribute of the concepts as the label in the graph.prog (
str
) – The graphviz layout program to use, such as “dot”, “neato”, etc.args (
str
) – Additional arguments to pass to the graphviz bash program as a string. Example: args=”-Nshape=box -Edir=forward -Ecolor=red”.
- Returns:
The image of the graph.
- Return type:
Image
- eliminate_duplicate_parameter(redundant_parameter, preserved_parameter)[source]
Eliminate a duplicate parameter from the model.
This happens when there are two redundant parameters only one of which is actually used in the model. This function removes the redundant parameter and updates the rate laws to use the preserved parameter.
- eliminate_parameter(name)[source]
Eliminate a parameter from the model by substituting 0.
- Parameters:
name (str) – The name of the parameter to be eliminated.
- extend(template_model, parameter_mapping=None, initial_mapping=None)[source]
Extend this template model with another template model.
- Parameters:
- Returns:
The template model with added templates from the added template model
- Return type:
- classmethod from_json(data)[source]
Return a template model from a dictionary
- Parameters:
data (Dict[str,Any]) – Mapping of template model attributes to their values.
- Return type:
- Returns:
Returns the newly created template model.
- generate_model_graph(use_display_name=False)[source]
Generate a graph based off the template model.
- Parameters:
use_display_name (
bool
) – Whether to use the display_name attribute of the concepts as the label in the graph.- Return type:
DiGraph
- Returns:
A graph
- get_concepts_by_name(name)[source]
Return a list of all concepts that have the given name.
Warning
this could give duplicates if there are nodes with compositional grounding.
- get_concepts_map()[source]
Return a mapping from concept keys to concepts that appear in this template model’s templates.
- get_concepts_name_map()[source]
Return a mapping from concept names to concepts that appear in this template model’s templates.
- get_parameters_from_rate_law(rate_law)[source]
Given a rate law, find its elements that are model parameters.
Rate laws consist of some combination of participants, rate parameters and potentially other factors. This function finds those elements of rate laws that are rate parameters.
- graph_as_json()[source]
Serialize the TemplateModel graph as node-link data.
- Return type:
- Returns:
The node-link data as a dictionary.
- set_initials(initial_dict)[source]
Set the initials of this model to the expression in the given dict.
- Parameters:
initial_dict (Dict[str,SympyExprStr]) – Mapping of initial name to its new expression.
- set_parameters(param_dict)[source]
Set the parameters of this model to the values in the given dict.
- set_rate_law(template_name, rate_law, local_dict=None)[source]
Set the rate law of a template with a given name.
- substitute_parameter(name, value=None)[source]
Substitute a parameter with the value argument if supplied, else substitute the parameter with the parameter’s value.
- Parameters:
name (str) – The name of the parameter to substitute.
value – The value to substitute.
- Returns:
None if there does not exist a parameter with the given name. Else not return value.
- pydantic model Initial[source]
Bases:
BaseModel
Represents the initial conditions for parameters present in the model.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Initial", "description": "Represents the initial conditions for parameters present in the\nmodel.", "type": "object", "properties": { "concept": { "title": "Concept", "description": "The concept associated with the initial.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "expression": { "title": "Expression", "description": "The expression for the initial.", "type": "string", "example": "2*x" } }, "required": [ "concept", "expression" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Initial.Config.<lambda> at 0x7fe6142cd8a0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Initial.Config.<lambda> at 0x7fe6145dcf40>}
- Fields:
-
field expression:
SympyExprStr
[Required] The expression for the initial.
- Constraints:
type = string
example = 2*x
- pydantic model Parameter[source]
Bases:
Concept
A Parameter is a special type of Concept that carries a value.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Parameter", "description": "A Parameter is a special type of Concept that carries a value.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] }, "value": { "title": "Value", "description": "Value of the parameter.", "type": "number" }, "distribution": { "title": "Distribution", "description": "A distribution of values for the parameter.", "allOf": [ { "$ref": "#/definitions/Distribution" } ] } }, "required": [ "name" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Distribution": { "title": "Distribution", "description": "A distribution of values for a parameter.", "type": "object", "properties": { "type": { "title": "Type", "description": "The type of distribution, e.g. 'uniform', 'normal', etc.", "type": "string" }, "parameters": { "title": "Parameters", "description": "The parameters of the distribution.", "type": "object", "additionalProperties": { "type": "number" } } }, "required": [ "type", "parameters" ] } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Concept.Config.<lambda> at 0x7fe6145de2a0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Concept.Config.<lambda> at 0x7fe6145dd440>}
- Fields:
-
field distribution:
Optional
[Distribution
] = None A distribution of values for the parameter.
- pydantic model Distribution[source]
Bases:
BaseModel
A distribution of values for a parameter.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Distribution", "description": "A distribution of values for a parameter.", "type": "object", "properties": { "type": { "title": "Type", "description": "The type of distribution, e.g. 'uniform', 'normal', etc.", "type": "string" }, "parameters": { "title": "Parameters", "description": "The parameters of the distribution.", "type": "object", "additionalProperties": { "type": "number" } } }, "required": [ "type", "parameters" ] }
- pydantic model Observable[source]
Bases:
Concept
An observable is a special type of Concept that carries an expression.
Observables are used to define the readouts of a model, useful when a readout is not defined as a state variable but is rather a function of state variables.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Observable", "description": "An observable is a special type of Concept that carries an expression.\n\nObservables are used to define the readouts of a model, useful when a\nreadout is not defined as a state variable but is rather a function of\nstate variables.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] }, "expression": { "title": "Expression", "description": "The expression for the observable.", "type": "string", "example": "2*x" } }, "required": [ "name", "expression" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Observable.Config.<lambda> at 0x7fe6142ce160>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Observable.Config.<lambda> at 0x7fe6142ce020>}
- Fields:
-
field expression:
SympyExprStr
[Required] The expression for the observable.
- Constraints:
type = string
example = 2*x
- pydantic model Time[source]
Bases:
BaseModel
A special type of Concept that represents time.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Time", "description": "A special type of Concept that represents time.", "type": "object", "properties": { "name": { "title": "Name", "description": "The symbol of the time variable in the model.", "default": "t", "type": "string" }, "units": { "title": "Units", "description": "The units of the time variable.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] } } }
- model_has_grounding(template_model, prefix, identifier)[source]
Returns true or false if a given search curie is present within the TemplateModel.
- Parameters:
template_model (
TemplateModel
) – The TemplateModel to query.prefix (
str
) – The prefix of the search curie.identifier (
str
) – The identifier of the search curie.
- Return type:
- pydantic model Concept[source]
Bases:
BaseModel
A concept is specified by its identifier(s), name, and - optionally - its context.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Concept.Config.<lambda> at 0x7fe6145de2a0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Concept.Config.<lambda> at 0x7fe6145dd440>}
- Fields:
-
field display_name:
str
= None An optional display name for the concept. If not provided, the name can be used for display purposes.
- classmethod from_json(data)[source]
Create a Concept from its JSON representation.
- Parameters:
data – The JSON representation of the Concept.
- Return type:
- Returns:
The Concept object.
- get_included_identifiers(config=None)[source]
Get the identifiers for this concept that are not excluded.
- get_key(config=None)[source]
Get the key for this concept.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the priority prefix and identifier together with the sorted context of this concept.
- is_equal_to(other, with_context=False, config=None)[source]
Test for equality between concepts
- Parameters:
other (
Concept
) – Other Concept to test equality withwith_context (
bool
) – If True, do not consider the two Concepts equal unless they also have exactly the same context. If there is no context,with_context
has no effect.config (
Config
) – Configuration defining priority and exclusion for identifiers.
- Return type:
- Returns:
True if
other
is the same Concept as this one
- refinement_of(other, refinement_func, with_context=False, config=None)[source]
Check if this Concept is a more detailed version of another
- Parameters:
other (
Concept
) – The other Concept to compare with. Assumed to be less detailed.with_context (
bool
) – If True, also consider the context of the Concepts for the refinement.refinement_func (
Callable
[[str
,str
],bool
]) – A function that given a source/more detailed entity and a target/less detailed entity checks if they are in a child-parent and returns a boolean.config (
Config
) – Configuration defining priority and exclusion for identifiers.
- Return type:
- Returns:
True if this Concept is a refinement of another Concept
- with_context(do_rename=False, curie_to_name_map=None, **context)[source]
Return this concept with extra context.
- Parameters:
do_rename – If true, will modify the name of the node based on the context introduced
curie_to_name_map – Use to set a name different from the context values provided in the **context kwarg when do_rename=True. Useful if the context values are e.g. curies or longer names that should be shortened, like {“New York City”: “nyc”}. If not provided ( default behavior), the context values will be used as names.
- Return type:
- Returns:
A new concept containing the given context.
Templates (mira.metamodel.templates
)
Data models for metamodel templates.
Regenerate the JSON schema by running python -m mira.metamodel.schema
.
- pydantic model Template[source]
Bases:
BaseModel
The Template is a parent class for model processes
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Template", "description": "The Template is a parent class for model processes", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field rate_law:
Optional
[SympyExprStr
] = None The rate law for the template.
- Constraints:
type = string
example = 2*x
- classmethod from_json(data, rate_symbols=None)[source]
Create a Template from a JSON object
- Parameters:
data – The JSON object to create the Template from
rate_symbols – A mapping of symbols to use for the rate law. If not provided, the rate law will be parsed without any symbols.
- Return type:
- Returns:
A Template object
- get_controllers()[source]
Return the controllers in this template.
- Returns:
A list of controllers in this template.
- get_independent_mass_action_rate_law(parameter)[source]
Return the mass action rate law for this template with independent action.
- Parameters:
parameter (
str
) – The parameter to use for the mass-action rate.- Return type:
Expr
- Returns:
The mass action rate law for this template with independent action.
- get_interactor_rate_law(independent=False)[source]
Return the rate law for the interactors in this template.
This is the part of the rate law that is the product of the interactors but does not include any parameters.
- Parameters:
independent – If True, the controllers will assume independent action.
- Return type:
Expr
- Returns:
The rate law for the interactors in this template.
- get_mass_action_rate_law(parameter, independent=False)[source]
Return the mass action rate law for this template.
- Parameters:
parameter (
str
) – The parameter to use for the mass-action rate law.independent – If True, the controllers will assume independent action.
- Return type:
Expr
- Returns:
The mass action rate law for this template.
- get_mass_action_symbol()[source]
Get the symbol for the parameter associated with this template’s rate law, assuming it’s mass action.
- Return type:
Optional
[Symbol
]- Returns:
The symbol for the parameter associated with this template’s rate law, assuming it’s mass action. Returns None if the rate law is not mass action or if there is no rate law.
- is_equal_to(other, with_context=False, config=None)[source]
Check if this template is equal to another template
- Parameters:
- Return type:
- Returns:
True if the other Template is equal to this Template
- refinement_of(other, refinement_func, with_context=False, config=None)[source]
Check if this template is a more detailed version of another
- Parameters:
other (
Template
) – The other template to compare with. Is assumed to be less detailed than this template.with_context (
bool
) – If True, also consider the context of Templates’ Concepts for the refinement.refinement_func (
Callable
[[str
,str
],bool
]) – A function that given a source/more detailed entity and a target/less detailed entity checks if they are in a child-parent relationship and returns a boolean.
- Return type:
- Returns:
True if this Template is a refinement of the other Template.
- set_mass_action_rate_law(parameter, independent=False)[source]
Set the rate law of this template to a mass action rate law.
- Parameters:
parameter – The parameter to use for the mass-action rate.
independent – If True, the controllers will assume independent action.
- set_rate_law(rate_law, local_dict=None)[source]
Set the rate law of this template to the given rate law.
- substitute_parameter(name, value)[source]
Substitute a parameter in this template’s rate law.
- Parameters:
name (
str
) – The name of the parameter to substitute.value – The value to substitute.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Returns:
A copy of this template with context added
- with_mass_action_rate_law(parameter, independent=False)[source]
Return a copy of this template with a mass action rate law.
- Parameters:
parameter – The parameter to use for the mass-action rate.
independent – If True, the controllers will assume independent action.
- Return type:
- Returns:
A copy of this template with the mass action rate law.
- pydantic model ControlledConversion[source]
Bases:
Template
Specifies a process of controlled conversion from subject to outcome, controlled by the controller.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "ControlledConversion", "description": "Specifies a process of controlled conversion from subject to outcome,\ncontrolled by the controller.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledConversion", "const": "ControlledConversion", "enum": [ "ControlledConversion" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject", "outcome" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['ControlledConversion'
] = 'ControlledConversion' - Constraints:
const = ControlledConversion
- add_controller(controller)[source]
Add a controller to this template.
- Parameters:
controller (
Concept
) – The controller to add.- Return type:
- Returns:
A new template with the additional controller.
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model ControlledProduction[source]
Bases:
Template
Specifies a process of production controlled by one controller
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "ControlledProduction", "description": "Specifies a process of production controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledProduction", "const": "ControlledProduction", "enum": [ "ControlledProduction" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "Provenance of the template", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "outcome" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['ControlledProduction'
] = 'ControlledProduction' - Constraints:
const = ControlledProduction
- add_controller(controller)[source]
Add a controller to this template.
- Parameters:
controller (
Concept
) – The controller to add.- Return type:
- Returns:
A GroupedControlledProduction template with the additional controller.
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model ControlledDegradation[source]
Bases:
Template
Specifies a process of degradation controlled by one controller
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "ControlledDegradation", "description": "Specifies a process of degradation controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledDegradation", "const": "ControlledDegradation", "enum": [ "ControlledDegradation" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['ControlledDegradation'
] = 'ControlledDegradation' - Constraints:
const = ControlledDegradation
- add_controller(controller)[source]
Add a controller to this template.
- Parameters:
controller (
Concept
) – The controller to add.- Return type:
- Returns:
A new template with the additional controller.
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- with_controller(controller)[source]
Return a copy of this template with the given controller.
- Parameters:
controller – The controller to use for the new template.
- Return type:
- Returns:
A copy of this template as a ControlledDegradation template with the given controller replacing the existing controllers.
- pydantic model NaturalConversion[source]
Bases:
Template
Specifies a process of natural conversion from subject to outcome
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "NaturalConversion", "description": "Specifies a process of natural conversion from subject to outcome", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalConversion", "const": "NaturalConversion", "enum": [ "NaturalConversion" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject", "outcome" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['NaturalConversion'
] = 'NaturalConversion' - Constraints:
const = NaturalConversion
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model NaturalProduction[source]
Bases:
Template
A template for the production of a species at a constant rate.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "NaturalProduction", "description": "A template for the production of a species at a constant rate.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalProduction", "const": "NaturalProduction", "enum": [ "NaturalProduction" ], "type": "string" }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the production.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "outcome" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['NaturalProduction'
] = 'NaturalProduction' - Constraints:
const = NaturalProduction
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model NaturalDegradation[source]
Bases:
Template
A template for the degradataion of a species at a proportional rate to its amount.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "NaturalDegradation", "description": "A template for the degradataion of a species at a proportional rate to its amount.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalDegradation", "const": "NaturalDegradation", "enum": [ "NaturalDegradation" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['NaturalDegradation'
] = 'NaturalDegradation' - Constraints:
const = NaturalDegradation
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model GroupedControlledConversion[source]
Bases:
Template
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "GroupedControlledConversion", "description": "The Template is a parent class for model processes", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledConversion", "const": "GroupedControlledConversion", "enum": [ "GroupedControlledConversion" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "subject", "outcome" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['GroupedControlledConversion'
] = 'GroupedControlledConversion' - Constraints:
const = GroupedControlledConversion
- get_concepts()[source]
Return the concepts in this template.
- Returns:
A list of concepts in this template.
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model GroupedControlledProduction[source]
Bases:
Template
Specifies a process of production controlled by several controllers
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "GroupedControlledProduction", "description": "Specifies a process of production controlled by several controllers", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledProduction", "const": "GroupedControlledProduction", "enum": [ "GroupedControlledProduction" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the production.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the production.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "outcome" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['GroupedControlledProduction'
] = 'GroupedControlledProduction' - Constraints:
const = GroupedControlledProduction
- add_controller(controller)[source]
Add a controller to this template.
- Parameters:
controller (
Concept
) – The controller to add.- Return type:
- Returns:
A new template with the additional controller.
- get_concepts()[source]
Return the concepts in this template.
- Returns:
A list of concepts in this template.
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model GroupedControlledDegradation[source]
Bases:
Template
Specifies a process of degradation controlled by several controllers
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "GroupedControlledDegradation", "description": "Specifies a process of degradation controlled by several controllers", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledDegradation", "const": "GroupedControlledDegradation", "enum": [ "GroupedControlledDegradation" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "subject" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['GroupedControlledDegradation'
] = 'GroupedControlledDegradation' - Constraints:
const = GroupedControlledDegradation
- add_controller(controller)[source]
Add a controller to this template.
- Parameters:
controller (
Concept
) – The controller to add.- Return type:
- Returns:
A new template with the additional controller added.
- get_concepts()[source]
Return the concepts in this template.
- Returns:
A list of concepts in this template.
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model NaturalReplication[source]
Bases:
Template
Specifies a process of natural replication of a subject.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "NaturalReplication", "description": "Specifies a process of natural replication of a subject.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalReplication", "const": "NaturalReplication", "enum": [ "NaturalReplication" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the template.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['NaturalReplication'
] = 'NaturalReplication' - Constraints:
const = NaturalReplication
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model ControlledReplication[source]
Bases:
Template
Specifies a process of replication controlled by one controller
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "ControlledReplication", "description": "Specifies a process of replication controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledReplication", "const": "ControlledReplication", "enum": [ "ControlledReplication" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the replication.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
-
field type:
Literal
['ControlledReplication'
] = 'ControlledReplication' - Constraints:
const = ControlledReplication
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, exclude_concepts=None, curie_to_name_map=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- pydantic model StaticConcept[source]
Bases:
Template
Specifies a standalone Concept that is not part of a process.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "StaticConcept", "description": "Specifies a standalone Concept that is not part of a process.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "StaticConcept", "const": "StaticConcept", "enum": [ "StaticConcept" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8fe0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Template.Config.<lambda> at 0x7fe6142a8ea0>}
- Fields:
- get_concepts()[source]
Return the concepts in this template.
- Returns:
A list of concepts in this template.
- get_key(config=None)[source]
Get the key for this template.
- Parameters:
config (
Optional
[Config
]) – Configuration defining priority and exclusion for identifiers.- Returns:
A tuple of the type and concepts in this template.
- with_context(do_rename=False, curie_to_name_map=None, exclude_concepts=None, **context)[source]
Return a copy of this template with context added
- Parameters:
do_rename – If True, rename the names of the concepts
exclude_concepts – A set of concept names to keep unchanged.
curie_to_name_map – A mapping of context values to names. Useful if the context values are e.g. curies. Will only be used if
do_rename
is True.
- Return type:
- Returns:
A copy of this template with context added
- templates_equal(templ, other_templ, with_context, config)[source]
Check if two Template objects are equal
- Parameters:
- Return type:
- Returns:
True if the two Template objects are equal.
- context_refinement(refined_context, other_context)[source]
Check if one Concept’s context is a refinement of another Concept’s
- Parameters:
refined_context – The assumed more detailed context
other_context – The assumed less detailed context
- Return type:
- Returns:
True if the Concept refined_concept truly is strictly more detailed than other_concept
- match_concepts(self_concepts, other_concepts, with_context=True, config=None, refinement_func=None)[source]
Return true if there is an exact match between two lists of concepts.
- Parameters:
self_concepts (
List
[Concept
]) – The list of concepts to compare to the second list.other_concepts (
List
[Concept
]) – The second list of concepts to compare the first list to.with_context (
bool
) – If True, also consider the contexts of the contained Concepts of the Template when comparing the two lists. Default: True.config (
Config
) – Configuration defining priority and exclusion for identifiers. If None, the default configuration will be used.refinement_func (
Callable
[[str
,str
],bool
]) – A function to use to check if one concept is a refinement of another. If None, the default is to check for equality.
- Return type:
- Returns:
True if there is an exact match between the two lists of concepts.
Operations (mira.metamodel.ops
)
Operations for template models.
- stratify(template_model, *, key, strata, strata_curie_to_name=None, strata_name_lookup=False, structure=None, directed=False, conversion_cls=<class 'mira.metamodel.templates.NaturalConversion'>, cartesian_control=False, modify_names=True, params_to_stratify=None, params_to_preserve=None, concepts_to_stratify=None, concepts_to_preserve=None)[source]
Multiplies a model into several strata.
E.g., can turn the SIR model into a two-city SIR model by splitting each concept into two derived concepts, each with the context for one of the two cities
- Parameters:
template_model (
TemplateModel
) – A template modelkey (
str
) – The (singular) name of the stratification, e.g.,"city"
strata (
Collection
[str
]) – A list of the values for stratification, e.g.,["boston", "nyc"]
or[geonames:4930956, geonames:5128581]
.strata_curie_to_name (
Optional
[Mapping
[str
,str
]]) – If provided, should map from a key used instrata
to a name. For example,{"geonames:4930956": "boston", "geonames:5128581": "nyc"}
.strata_name_lookup (
bool
) – If true, will try to look up the entity names of the strata values under the assumption that they are curies. This flag has no impact ifstrata_curie_to_name
is given.structure (
Optional
[Iterable
[Tuple
[str
,str
]]]) – An iterable of pairs corresponding to a directed network structure where each of the pairs has two strata. If none given, will assume a complete network structure. If no structure is necessary, pass an empty list.directed (
bool
) – Should the reverse direction conversions be added based on the given structure?conversion_cls (
Type
[Template
]) – The template class to be used for conversions between strata defined by the network structure. Defaults toNaturalConversion
cartesian_control (
bool
) –If true, splits all control relationships based on the stratification.
This should be true for an SIR epidemiology model, the susceptibility to infected transition is controlled by infected. If the model is stratified by vaccinated and unvaccinated, then the transition from vaccinated susceptible population to vaccinated infected populations should be controlled by both infected vaccinated and infected unvaccinated populations.
This should be false for stratification of an SIR epidemiology model based on cities, since the infected population in one city won’t (directly, through the perspective of the model) affect the infection of susceptible population in another city.
modify_names (
bool
) – If true, will modify the names of the concepts to include the strata (e.g.,"S"
becomes"S_boston"
). If false, will keep the original names.params_to_stratify (
Optional
[Collection
[str
]]) – A list of parameters to stratify. If none given, will stratify all parameters.params_to_preserve (
Optional
[Collection
[str
]]) – A list of parameters to preserve. If none given, will stratify all parameters.concepts_to_stratify (
Optional
[Collection
[str
]]) – A list of concepts to stratify. If none given, will stratify all concepts.concepts_to_preserve (
Optional
[Collection
[str
]]) – A list of concepts to preserve. If none given, will stratify all concepts.
- Return type:
- Returns:
A stratified template model
- simplify_rate_laws(template_model)[source]
Return a template model after rewriting templates by simplifying rate laws.
- Parameters:
template_model (
TemplateModel
) – A template model- Returns:
A template model with simplified rate laws.
- aggregate_parameters(template_model)[source]
Return a template model after aggregating parameters for mass-action rate laws.
- Parameters:
template_model (
TemplateModel
) – A template model whose rate laws will be aggregated.- Return type:
- Returns:
A template model with aggregated parameters.
- counts_to_dimensionless(tm, counts_unit, norm_factor)[source]
Convert all quantities using a given counts unit to dimensionless units.
- Parameters:
tm (
TemplateModel
) – A template model.counts_unit (
str
) – The unit of the counts.norm_factor (
float
) – The normalization factor to convert counts to dimensionsionless.
- Return type:
- Returns:
A template model with all entity concentrations converted to dimensionless units.
Model comparison (mira.metamodel.comparison
)
- pydantic model ModelComparisonGraphdata[source]
Bases:
BaseModel
A data structure holding a graph representation of TemplateModel delta
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "ModelComparisonGraphdata", "description": "A data structure holding a graph representation of TemplateModel delta", "type": "object", "properties": { "template_models": { "title": "Template Models", "description": "A mapping of template model keys to template models", "type": "object", "additionalProperties": { "$ref": "#/definitions/TemplateModel" } }, "concept_nodes": { "title": "Concept Nodes", "description": "A mapping of model identifiers to a mapping of node identifiers to nodes. Node identifiers have the structure of 'mXnY' where X is the model id and Y is the node id within the model.", "type": "object", "additionalProperties": { "type": "object", "additionalProperties": { "$ref": "#/definitions/Concept" } } }, "template_nodes": { "title": "Template Nodes", "description": "A mapping of model identifiers to a mapping of node identifiers to nodes. Node identifiers have the structure of 'mXnY' where X is the model id and Y is the node id within the model.", "type": "object", "additionalProperties": { "type": "object", "additionalProperties": { "discriminator": { "propertyName": "type", "mapping": { "NaturalConversion": "#/definitions/NaturalConversion", "ControlledConversion": "#/definitions/ControlledConversion", "NaturalDegradation": "#/definitions/NaturalDegradation", "ControlledDegradation": "#/definitions/ControlledDegradation", "GroupedControlledDegradation": "#/definitions/GroupedControlledDegradation", "NaturalProduction": "#/definitions/NaturalProduction", "ControlledProduction": "#/definitions/ControlledProduction", "GroupedControlledConversion": "#/definitions/GroupedControlledConversion", "GroupedControlledProduction": "#/definitions/GroupedControlledProduction", "NaturalReplication": "#/definitions/NaturalReplication", "ControlledReplication": "#/definitions/ControlledReplication", "StaticConcept": "#/definitions/StaticConcept" } }, "oneOf": [ { "$ref": "#/definitions/NaturalConversion" }, { "$ref": "#/definitions/ControlledConversion" }, { "$ref": "#/definitions/NaturalDegradation" }, { "$ref": "#/definitions/ControlledDegradation" }, { "$ref": "#/definitions/GroupedControlledDegradation" }, { "$ref": "#/definitions/NaturalProduction" }, { "$ref": "#/definitions/ControlledProduction" }, { "$ref": "#/definitions/GroupedControlledConversion" }, { "$ref": "#/definitions/GroupedControlledProduction" }, { "$ref": "#/definitions/NaturalReplication" }, { "$ref": "#/definitions/ControlledReplication" }, { "$ref": "#/definitions/StaticConcept" } ] } } }, "inter_model_edges": { "title": "Inter Model Edges", "description": "List of edges. Each edge is a tuple of(source node lookup, target node lookup, role) where role describes if the edge is a refinement of or equal to another node in another model (inter model edge). The edges are considered directed for refinements and undirected for equalities. The node lookup is a tuple of (model id, node id) that defines the lookup of the node in the nodes mapping.", "type": "array", "items": { "type": "array", "minItems": 3, "maxItems": 3, "items": [ { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "integer" }, { "type": "integer" } ] }, { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "integer" }, { "type": "integer" } ] }, { "type": "string" } ] } }, "intra_model_edges": { "title": "Intra Model Edges", "description": "List of edges. Each edge is a tuple of(source node lookup, target node lookup, role) where role describes if the edge incoming to, outgoing from or controls a template/process in the same model (intra model edge). The edges are considered directed. The node lookup is a tuple of (model id, node id) that defines the lookup of the node in the nodes mapping.", "type": "array", "items": { "type": "array", "minItems": 3, "maxItems": 3, "items": [ { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "integer" }, { "type": "integer" } ] }, { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "integer" }, { "type": "integer" } ] }, { "type": "string" } ] } } }, "required": [ "template_models" ], "definitions": { "Unit": { "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }, "Concept": { "title": "Concept", "description": "A concept is specified by its identifier(s), name, and - optionally -\nits context.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } }, "required": [ "name" ] }, "Provenance": { "title": "Provenance", "type": "object", "properties": {} }, "NaturalConversion": { "title": "NaturalConversion", "description": "Specifies a process of natural conversion from subject to outcome", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalConversion", "const": "NaturalConversion", "enum": [ "NaturalConversion" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject", "outcome" ] }, "ControlledConversion": { "title": "ControlledConversion", "description": "Specifies a process of controlled conversion from subject to outcome,\ncontrolled by the controller.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledConversion", "const": "ControlledConversion", "enum": [ "ControlledConversion" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject", "outcome" ] }, "NaturalDegradation": { "title": "NaturalDegradation", "description": "A template for the degradataion of a species at a proportional rate to its amount.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalDegradation", "const": "NaturalDegradation", "enum": [ "NaturalDegradation" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ] }, "ControlledDegradation": { "title": "ControlledDegradation", "description": "Specifies a process of degradation controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledDegradation", "const": "ControlledDegradation", "enum": [ "ControlledDegradation" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject" ] }, "GroupedControlledDegradation": { "title": "GroupedControlledDegradation", "description": "Specifies a process of degradation controlled by several controllers", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledDegradation", "const": "GroupedControlledDegradation", "enum": [ "GroupedControlledDegradation" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "subject": { "title": "Subject", "description": "The subject of the degradation.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the degradation.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "subject" ] }, "NaturalProduction": { "title": "NaturalProduction", "description": "A template for the production of a species at a constant rate.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalProduction", "const": "NaturalProduction", "enum": [ "NaturalProduction" ], "type": "string" }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the production.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "outcome" ] }, "ControlledProduction": { "title": "ControlledProduction", "description": "Specifies a process of production controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledProduction", "const": "ControlledProduction", "enum": [ "ControlledProduction" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "Provenance of the template", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "outcome" ] }, "GroupedControlledConversion": { "title": "GroupedControlledConversion", "description": "The Template is a parent class for model processes", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledConversion", "const": "GroupedControlledConversion", "enum": [ "GroupedControlledConversion" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "subject": { "title": "Subject", "description": "The subject of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "outcome": { "title": "Outcome", "description": "The outcome of the conversion.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the conversion.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "subject", "outcome" ] }, "GroupedControlledProduction": { "title": "GroupedControlledProduction", "description": "Specifies a process of production controlled by several controllers", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "GroupedControlledProduction", "const": "GroupedControlledProduction", "enum": [ "GroupedControlledProduction" ], "type": "string" }, "controllers": { "title": "Controllers", "description": "The controllers of the production.", "type": "array", "items": { "$ref": "#/definitions/Concept" } }, "outcome": { "title": "Outcome", "description": "The outcome of the production.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the production.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controllers", "outcome" ] }, "NaturalReplication": { "title": "NaturalReplication", "description": "Specifies a process of natural replication of a subject.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "NaturalReplication", "const": "NaturalReplication", "enum": [ "NaturalReplication" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the template.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ] }, "ControlledReplication": { "title": "ControlledReplication", "description": "Specifies a process of replication controlled by one controller", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "ControlledReplication", "const": "ControlledReplication", "enum": [ "ControlledReplication" ], "type": "string" }, "controller": { "title": "Controller", "description": "The controller of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "subject": { "title": "Subject", "description": "The subject of the replication.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance of the replication.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "controller", "subject" ] }, "StaticConcept": { "title": "StaticConcept", "description": "Specifies a standalone Concept that is not part of a process.", "type": "object", "properties": { "rate_law": { "title": "Rate Law", "description": "The rate law for the template.", "type": "string", "example": "2*x" }, "name": { "title": "Name", "description": "The name of the template.", "type": "string" }, "display_name": { "title": "Display Name", "description": "The display name of the template.", "type": "string" }, "type": { "title": "Type", "default": "StaticConcept", "const": "StaticConcept", "enum": [ "StaticConcept" ], "type": "string" }, "subject": { "title": "Subject", "description": "The subject.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "provenance": { "title": "Provenance", "description": "The provenance.", "type": "array", "items": { "$ref": "#/definitions/Provenance" } } }, "required": [ "subject" ] }, "Distribution": { "title": "Distribution", "description": "A distribution of values for a parameter.", "type": "object", "properties": { "type": { "title": "Type", "description": "The type of distribution, e.g. 'uniform', 'normal', etc.", "type": "string" }, "parameters": { "title": "Parameters", "description": "The parameters of the distribution.", "type": "object", "additionalProperties": { "type": "number" } } }, "required": [ "type", "parameters" ] }, "Parameter": { "title": "Parameter", "description": "A Parameter is a special type of Concept that carries a value.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] }, "value": { "title": "Value", "description": "Value of the parameter.", "type": "number" }, "distribution": { "title": "Distribution", "description": "A distribution of values for the parameter.", "allOf": [ { "$ref": "#/definitions/Distribution" } ] } }, "required": [ "name" ] }, "Initial": { "title": "Initial", "description": "Represents the initial conditions for parameters present in the\nmodel.", "type": "object", "properties": { "concept": { "title": "Concept", "description": "The concept associated with the initial.", "allOf": [ { "$ref": "#/definitions/Concept" } ] }, "expression": { "title": "Expression", "description": "The expression for the initial.", "type": "string", "example": "2*x" } }, "required": [ "concept", "expression" ] }, "Observable": { "title": "Observable", "description": "An observable is a special type of Concept that carries an expression.\n\nObservables are used to define the readouts of a model, useful when a\nreadout is not defined as a state variable but is rather a function of\nstate variables.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the concept.", "type": "string" }, "display_name": { "title": "Display Name", "description": "An optional display name for the concept. If not provided, the name can be used for display purposes.", "type": "string" }, "description": { "title": "Description", "description": "An optional description of the concept.", "type": "string" }, "identifiers": { "title": "Identifiers", "description": "A mapping of namespaces to identifiers.", "type": "object", "additionalProperties": { "type": "string" } }, "context": { "title": "Context", "description": "A mapping of context keys to values.", "type": "object", "additionalProperties": { "type": "string" } }, "units": { "title": "Units", "description": "The units of the concept.", "allOf": [ { "$ref": "#/definitions/Unit" } ] }, "expression": { "title": "Expression", "description": "The expression for the observable.", "type": "string", "example": "2*x" } }, "required": [ "name", "expression" ] }, "Author": { "title": "Author", "description": "A metadata model for an author.", "type": "object", "properties": { "name": { "title": "Name", "description": "The name of the author", "type": "string" } }, "required": [ "name" ] }, "Annotations": { "title": "Annotations", "description": "A metadata model for model-level annotations.\n\nExamples in this metadata model are taken from\nhttps://www.ebi.ac.uk/biomodels/BIOMD0000000956,\na well-annotated SIR model in the BioModels database.", "type": "object", "properties": { "name": { "title": "Name", "description": "A human-readable label for the model", "example": "SIR model of scenarios of COVID-19 spread in CA and NY", "type": "string" }, "description": { "title": "Description", "description": "A description of the model", "example": "The coronavirus disease 2019 (COVID-19) pandemic has placed epidemic modeling at the forefront of worldwide public policy making. Nonetheless, modeling and forecasting the spread of COVID-19 remains a challenge. Here, we detail three regional scale models for forecasting and assessing the course of the pandemic. This work demonstrates the utility of parsimonious models for early-time data and provides an accessible framework for generating policy-relevant insights into its course. We show how these models can be connected to each other and to time series data for a particular region. Capable of measuring and forecasting the impacts of social distancing, these models highlight the dangers of relaxing nonpharmaceutical public health interventions in the absence of a vaccine or antiviral therapies.", "type": "string" }, "license": { "title": "License", "description": "Information about the licensing of the model artifact. Ideally, given as an SPDX identifier like CC0 or CC-BY-4.0. For example, models from the BioModels databases are all licensed under the CC0 public attribution license.", "example": "CC0", "type": "string" }, "authors": { "title": "Authors", "description": "A list of authors/creators of the model. This is not the same as the people who e.g., submitted the model to BioModels", "example": [ "name='Andrea L Bertozzi'", "name='Elisa Franco'", "name='George Mohler'", "name='Martin B Short'", "name='Daniel Sledge'" ], "type": "array", "items": { "$ref": "#/definitions/Author" } }, "references": { "title": "References", "description": "A list of CURIEs (i.e., <prefix>:<identifier>) corresponding to literature references that describe the model. Do **not** duplicate the same publication with different CURIEs (e.g., using pubmed, pmc, and doi)", "example": [ "pubmed:32616574" ], "type": "array", "items": { "type": "string" } }, "time_scale": { "title": "Time Scale", "description": "The granularity of the time element of the model, typically on the scale of days, weeks, or months for epidemiology models", "example": "day", "type": "string" }, "time_start": { "title": "Time Start", "description": "The start time of the applicability of a model, given as a datetime. When the time scale is not so granular, leave the less granular fields as default, i.e., if the time scale is on months, give dates like YYYY-MM-01 00:00", "type": "string", "format": "date-time" }, "time_end": { "title": "Time End", "description": "Similar to the start time of the applicability of a model, the end time is given as a datetime. For example, the Bertozzi 2020 model is applicable between March and August 2020, so this field is annotated with August 1st, 2020.", "type": "string", "format": "date-time" }, "locations": { "title": "Locations", "description": "A location or list of locations where this model is applicable, ideally annotated using a CURIEs referencing a controlled vocabulary such as GeoNames, which has multiple levels of granularity including city/state/country level terms. For example,the Bertozzi 2020 model was for New York City (geonames:5128581) and California (geonames:5332921)", "example": [ "geonames:5128581", "geonames:5332921" ], "type": "array", "items": { "type": "string" } }, "pathogens": { "title": "Pathogens", "description": "The pathogens present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about SARS-CoV-2, this is ncbitaxon:2697049. Do not confuse this field with terms for annotating the disease caused by the pathogen. Note that some models may have multiple pathogens, for simulating double pandemics such as the interaction with SARS-CoV-2 and the seasonal flu.", "example": [ "ncbitaxon:2697049" ], "type": "array", "items": { "type": "string" } }, "diseases": { "title": "Diseases", "description": "The diseases caused by pathogens in the model, given with CURIEs referencing vocabulary for dieases, such as DOID, EFO, or MONDO. For example, the Bertozzi 2020 model is about SARS-CoV-2, which causes COVID-19. In the Human Disease Ontology (DOID), this is referenced by doid:0080600.", "example": [ "doid:0080600" ], "type": "array", "items": { "type": "string" } }, "hosts": { "title": "Hosts", "description": "The hosts present in the model, given with CURIEs referencing vocabulary for taxa, ideally, NCBI Taxonomy. For example, the Bertozzi 2020 model is about human infection by SARS-CoV-2. Therefore, the appropriate annotation for this field would be ncbitaxon:9606. Note that some models have multiple hosts, such as Malaria models that consider humans and mosquitos.", "example": [ "ncbitaxon:9606" ], "type": "array", "items": { "type": "string" } }, "model_types": { "title": "Model Types", "description": "This field describes the type(s) of the model using the Mathematical Modeling Ontology (MAMO), which has terms like 'ordinary differential equation model', 'population model', etc. These should be annotated as CURIEs in the form of mamo:<local unique identifier>. For example, the Bertozzi 2020 model is a population model (mamo:0000028) and ordinary differential equation model (mamo:0000046)", "example": [ "mamo:0000028", "mamo:0000046" ], "type": "array", "items": { "type": "string" } } } }, "Time": { "title": "Time", "description": "A special type of Concept that represents time.", "type": "object", "properties": { "name": { "title": "Name", "description": "The symbol of the time variable in the model.", "default": "t", "type": "string" }, "units": { "title": "Units", "description": "The units of the time variable.", "allOf": [ { "$ref": "#/definitions/Unit" } ] } } }, "TemplateModel": { "title": "TemplateModel", "description": "A template model.", "type": "object", "properties": { "templates": { "title": "Templates", "description": "A list of any child class of Templates", "type": "array", "items": { "discriminator": { "propertyName": "type", "mapping": { "NaturalConversion": "#/definitions/NaturalConversion", "ControlledConversion": "#/definitions/ControlledConversion", "NaturalDegradation": "#/definitions/NaturalDegradation", "ControlledDegradation": "#/definitions/ControlledDegradation", "GroupedControlledDegradation": "#/definitions/GroupedControlledDegradation", "NaturalProduction": "#/definitions/NaturalProduction", "ControlledProduction": "#/definitions/ControlledProduction", "GroupedControlledConversion": "#/definitions/GroupedControlledConversion", "GroupedControlledProduction": "#/definitions/GroupedControlledProduction", "NaturalReplication": "#/definitions/NaturalReplication", "ControlledReplication": "#/definitions/ControlledReplication", "StaticConcept": "#/definitions/StaticConcept" } }, "oneOf": [ { "$ref": "#/definitions/NaturalConversion" }, { "$ref": "#/definitions/ControlledConversion" }, { "$ref": "#/definitions/NaturalDegradation" }, { "$ref": "#/definitions/ControlledDegradation" }, { "$ref": "#/definitions/GroupedControlledDegradation" }, { "$ref": "#/definitions/NaturalProduction" }, { "$ref": "#/definitions/ControlledProduction" }, { "$ref": "#/definitions/GroupedControlledConversion" }, { "$ref": "#/definitions/GroupedControlledProduction" }, { "$ref": "#/definitions/NaturalReplication" }, { "$ref": "#/definitions/ControlledReplication" }, { "$ref": "#/definitions/StaticConcept" } ] } }, "parameters": { "title": "Parameters", "description": "A dict of parameter values where keys correspond to how the parameter appears in rate laws.", "type": "object", "additionalProperties": { "$ref": "#/definitions/Parameter" } }, "initials": { "title": "Initials", "description": "A dict of initial condition values where keyscorrespond to concept names they apply to.", "type": "object", "additionalProperties": { "$ref": "#/definitions/Initial" } }, "observables": { "title": "Observables", "description": "A list of observables that are readouts from the model.", "type": "object", "additionalProperties": { "$ref": "#/definitions/Observable" } }, "annotations": { "title": "Annotations", "description": "A structure containing model-level annotations. Note that all annotations are optional.", "allOf": [ { "$ref": "#/definitions/Annotations" } ] }, "time": { "title": "Time", "description": "A structure containing time-related annotations. Note that all annotations are optional.", "allOf": [ { "$ref": "#/definitions/Time" } ] } }, "required": [ "templates" ] } } }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function ModelComparisonGraphdata.Config.<lambda> at 0x7fe614121ee0>, <class ‘mira.metamodel.templates.Template’>: <function ModelComparisonGraphdata.Config.<lambda> at 0x7fe614121f80>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function ModelComparisonGraphdata.Config.<lambda> at 0x7fe614121c60>}
- Fields:
-
field concept_nodes:
Dict
[int
,Dict
[int
,Concept
]] [Optional] A mapping of model identifiers to a mapping of node identifiers to nodes. Node identifiers have the structure of ‘mXnY’ where X is the model id and Y is the node id within the model.
-
field inter_model_edges:
List
[Tuple
[Tuple
[int
,int
],Tuple
[int
,int
],str
]] [Optional] List of edges. Each edge is a tuple of(source node lookup, target node lookup, role) where role describes if the edge is a refinement of or equal to another node in another model (inter model edge). The edges are considered directed for refinements and undirected for equalities. The node lookup is a tuple of (model id, node id) that defines the lookup of the node in the nodes mapping.
-
field intra_model_edges:
List
[Tuple
[Tuple
[int
,int
],Tuple
[int
,int
],str
]] [Optional] List of edges. Each edge is a tuple of(source node lookup, target node lookup, role) where role describes if the edge incoming to, outgoing from or controls a template/process in the same model (intra model edge). The edges are considered directed. The node lookup is a tuple of (model id, node id) that defines the lookup of the node in the nodes mapping.
-
field template_models:
Dict
[int
,TemplateModel
] [Required] A mapping of template model keys to template models
-
field template_nodes:
Dict
[int
,Dict
[int
,Union
[NaturalConversion
,ControlledConversion
,NaturalDegradation
,ControlledDegradation
,GroupedControlledDegradation
,NaturalProduction
,ControlledProduction
,GroupedControlledConversion
,GroupedControlledProduction
,NaturalReplication
,ControlledReplication
,StaticConcept
]]] [Optional] A mapping of model identifiers to a mapping of node identifiers to nodes. Node identifiers have the structure of ‘mXnY’ where X is the model id and Y is the node id within the model.
- classmethod from_template_models(template_models, refinement_func)[source]
Create a ModelComparisonGraphdata from a list of TemplateModels
- Parameters:
- Return type:
- Returns:
The ModelComparisonGraphdata
- class TemplateModelComparison(template_models, refinement_func)[source]
Bases:
object
Compares TemplateModels in a graph friendly structure
Create a ModelComparisonGraphdata from a list of TemplateModels
- Parameters:
- class TemplateModelDelta(template_model1, template_model2, refinement_function, tag1='1', tag2='2', tag1_color='blue', tag2_color='green', merge_color='orange')[source]
Bases:
object
Defines the differences between TemplateModels as a networkx graph
Create a TemplateModelDelta
- Parameters:
template_model1 (
TemplateModel
) – The first template modeltemplate_model2 (
TemplateModel
) – The second template modelrefinement_function (
Callable
[[str
,str
],bool
]) – The refinement function to use when comparing conceptstag1 (
str
) – The tag for the first template model. Default: “1”tag2 (
str
) – The tag for the second template model. Default: “2”tag1_color (
str
) – The color for the first template model. Default: “blue”tag2_color (
str
) – The color for the second template model. Default: “green”merge_color (
str
) – The color for the merged template model. Default: “orange”
- draw_graph(path, prog='dot', args='', format=None)[source]
Draw a pygraphviz graph of the differences using
- classmethod for_jupyter(template_model1, template_model2, refinement_function, name='model.png', tag1='1', tag2='2', tag1_color='blue', tag2_color='green', merge_color='orange', prog='dot', args='', format=None, **kwargs)[source]
Display in jupyter
- Parameters:
template_model1 – The first template model
template_model2 – The second template model
refinement_function – The refinement function to use
name – The name of the output file
tag1 – The tag for the first template model
tag2 – The tag for the second template model
tag1_color – The color for the first template model
tag2_color – The color for the second template model
merge_color – The color for the merged template model
prog (
str
) – The graphviz layout program to use, such as “dot”, “neato”, etc.args (
str
) – Additional arguments to pass to the graphviz bash program as a string. Example: “args=”-Nshape=box -Edir=forward -Ecolor=red”kwargs – Keyword arguments to pass to IPython.display.Image
- Returns:
The IPython Image object
- class RefinementClosure(transitive_closure)[source]
Bases:
object
A wrapper class for storing a transitive closure and exposing a function to check for refinement relationship.
Typical usage would involve: >>> from mira.dkg.web_client import get_transitive_closure_web >>> rc = RefinementClosure(get_transitive_closure_web()) >>> rc.is_ontological_child(‘doid:0080314’, ‘bfo:0000016’)
Initialize the RefinementClosure
Meta-model schema (mira.metamodel.schema
)
Rebuild with python -m mira.metamodel.schema
.
Model search (mira.metamodel.search
)
- find_models_with_grounding(template_models, prefix, identifier)[source]
Filter a dict of models to ones containing a given grounding in any role.
- Parameters:
template_models (
Mapping
[str
,TemplateModel
]) – A dict of template models.prefix (
str
) – A prefix of a CURIE.identifier (
str
) – An identifier of a CURIE.
- Return type:
- Returns:
A dict of template models containing the given grounding.
Model I/O (mira.metamodel.io
)
Input/output functions for metamodels.
- model_from_json_file(fname)[source]
Return a TemplateModel from a JSON file.
- Parameters:
fname (str or Path) – A file path.
- Return type:
- Returns:
A TemplateModel deserialized from the JSON file.
- model_to_json_file(model, fname)[source]
Dump a TemplateModel into a JSON file.
- Parameters:
model (TemplateModel) – A template model to dump to a JSON file.
fname (str or Path) – A file path to dump the model into.
Units (mira.metamodel.units
)
- pydantic model Unit[source]
Bases:
BaseModel
A unit of measurement.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Unit", "description": "A unit of measurement.", "type": "object", "properties": { "expression": { "title": "Expression", "description": "The expression for the unit.", "type": "string", "example": "2*x" } }, "required": [ "expression" ] }
- Config:
arbitrary_types_allowed: bool = True
json_decoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Unit.Config.<lambda> at 0x7fe6145ddee0>}
json_encoders: dict = {<class ‘mira.metamodel.utils.SympyExprStr’>: <function Unit.Config.<lambda> at 0x7fe6145ddda0>}
- Fields:
-
field expression:
SympyExprStr
[Required] The expression for the unit.
- Constraints:
type = string
example = 2*x
Utilities (mira.metamodel.utils
)
- get_parseable_expression(s)[source]
Return an expression that can be parsed using sympy.
- Return type:
Decapodes (mira.metamodel.decapodes
)
- class Decapode(variables, op1s, op2s, summations, tangent_variables)[source]
Bases:
object
MIRA’s internal representation of a decapode compute graph or decaexpr JSON.
Create a Decapode based off multiple mappings of different parts of a Decapode.
- Parameters:
- class Variable(id, type, name, expression=None, identifiers=<factory>)[source]
Bases:
object
Dataclass that represents a variable in MIRA’s internal representation of a Decapode.
- expression
The expression of the variable.
- Type:
sympy.Expr
- class TangentVariable(id, incl_var)[source]
Bases:
object
Dataclass that represents a tangent variable in MIRA’s internal representation of a Decapode.
- class Summation(id, summands, sum)[source]
Bases:
object
Dataclass that represents a summation in MIRA’s internal representation of a decapode.
- class Op1(id, src, tgt, function_str)[source]
Bases:
object
Dataclass that represents unary operations in MIRA’s internal representation of a decapode.
- class Op2(id, proj1, proj2, res, function_str)[source]
Bases:
object
Dataclass that represents binary operations in MIRA’s internal representation of a decapode.