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 description: Optional[str] = None

A description of the model

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 name: Optional[str] = None

A human-readable label for the model

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.

field time_scale: Optional[str] = None

The granularity of the time element of the model, typically on the scale of days, weeks, or months for epidemiology models

field time_start: Optional[datetime] = None

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

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:
  • template (Template) – The template to add.

  • parameter_mapping (Optional[Mapping[str, Parameter]]) – A mapping from parameter names in the template to Parameters in the model.

  • initial_mapping (Optional[Mapping[str, Initial]]) – A mapping from concept names in the template to Initials in the model.

Return type:

TemplateModel

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:

TemplateModel

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.

  • format (Optional[str]) – Set the file format explicitly.

  • 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.

  • format (Optional[str]) – Set the file format explicitly.

  • 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.

Parameters:
  • redundant_parameter (str) – The name of the parameter to remove.

  • preserved_parameter (str) – The new name of the parameter to preserve.

eliminate_parameter(name)[source]

Eliminate a parameter from the model by substituting 0.

Parameters:

name (str) – The name of the parameter to be eliminated.

eliminate_unused_parameters()[source]

Remove parameters that are not used in rate laws.

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:

TemplateModel

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:

TemplateModel

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_all_used_parameters()[source]

Get all parameters that are actually used in rate laws.

get_concept(name)[source]

Return the first concept that has the given name.

Parameters:

name (str) – The name to be queried for.

Return type:

Optional[Concept]

Returns:

The first concept that has the given name if it’s present in the TemplateModel.

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.

Parameters:

name (str) – The name to be queried for.

Return type:

List[Concept]

Returns:

A list of concepts that have the given name.

get_concepts_map()[source]

Return a mapping from concept keys to concepts that appear in this template model’s templates.

Returns:

The mapping of concept keys to concepts that appear in this template model’s templates.

Return type:

Dict[str,Concept]

get_concepts_name_map()[source]

Return a mapping from concept names to concepts that appear in this template model’s templates.

Returns:

Mapping of concept names to concepts that appear in this template model’s templates.

Return type:

Dict[str,Concept]

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.

Parameters:

rate_law (sympy.Symbol | sympy.Expr) – A sympy expression or symbol, whose names are extracted.

Return type:

Set[str]

Returns:

A set of parameter names (as strings).

graph_as_json()[source]

Serialize the TemplateModel graph as node-link data.

Return type:

Dict

Returns:

The node-link data as a dictionary.

print_params_table()[source]

Print the table full of parameters.

reset_base_names()[source]

Reset the base names of all concepts in this model to the current name.

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.

Parameters:

param_dict (Dict[str,float]) – Mapping of parameter name to its new value.

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.

update_parameters(parameter_dict)[source]

Update parameter values.

Parameters:

parameter_dict (Dict[str,float]) – Mapping of parameter name to 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 concept: Concept [Required]

The concept associated with the initial.

field expression: SympyExprStr [Required]

The expression for the initial.

Constraints:
  • type = string

  • example = 2*x

classmethod from_json(data, locals_dict=None)[source]

Returns an Initial from a dictionary.

Parameters:
  • data (Dict[str,Any]) – Mapping of Initial attributes to their values.

  • locals_dict (Dict[str,Any]) – Mapping of string symbols to their sympy equivalent.

Return type:

Initial

Returns:

The newly created initial.

get_parameter_names(known_param_names)[source]

Get the names of all parameters in the expression.

Parameters:

known_param_names (list[str]) – List of parameter names.

Return type:

Set[str]

Returns:

The set of parameter names.

substitute_parameter(name, value)[source]

Substitute a parameter value into the initial expression.

Parameters:
  • name (str) – The name of the parameter to substitute.

  • value – The value to substitute.

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.

field value: Optional[float] = None

Value of 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"
   ]
}

Fields:
field parameters: Dict[str, float] [Required]

The parameters of the distribution.

field type: str [Required]

The type of distribution, e.g. ‘uniform’, ‘normal’, etc.

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

get_parameter_names(known_param_names)[source]

Get the names of all parameters in the expression.

Parameters:

known_param_names (list[str]) – List of parameter names.

Return type:

Set[str]

Returns:

The set of parameter names.

substitute_parameter(name, value)[source]

Substitute a parameter value into the observable expression.

Parameters:
  • name (str) – The name of the parameter to substitute.

  • value – The value to substitute.

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"
         ]
      }
   }
}

Fields:
field name: str = 't'

The symbol of the time variable in the model.

field units: Optional[Unit] = None

The units of the time variable.

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:

bool

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 context: Mapping[str, str] [Optional]

A mapping of context keys to values.

field description: Optional[str] = None

An optional description of the concept.

field display_name: str = None

An optional display name for the concept. If not provided, the name can be used for display purposes.

field identifiers: Mapping[str, str] [Optional]

A mapping of namespaces to identifiers.

field name: str [Required]

The name of the concept.

field units: Optional[Unit] = None

The units of the concept.

classmethod from_json(data)[source]

Create a Concept from its JSON representation.

Parameters:

data – The JSON representation of the Concept.

Return type:

Concept

Returns:

The Concept object.

get_curie(config=None)[source]

Get the priority prefix/identifier pair for this concept.

Parameters:

config (Optional[Config]) – Configuration defining priority and exclusion for identifiers.

Return type:

Tuple[str, str]

Returns:

A tuple of the priority prefix and identifier for this concept.

get_curie_str(config=None)[source]

Get the priority prefix/identifier as a CURIE string.

Parameters:

config (Optional[Config]) – Configuration defining priority and exclusion for identifiers.

Return type:

str

Returns:

A CURIE string for this concept.

get_included_identifiers(config=None)[source]

Get the identifiers for this concept that are not excluded.

Parameters:

config (Optional[Config]) – Configuration defining priority and exclusion for identifiers.

Return type:

Dict[str, str]

Returns:

A dict of identifiers for this concept that are not excluded as defined by the config.

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 with

  • with_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:

bool

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:

bool

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:

Concept

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 display_name: Optional[str] = None

The display name of the template.

field name: Optional[str] = None

The name of the template.

field rate_law: Optional[SympyExprStr] = None

The rate law for the template.

Constraints:
  • type = string

  • example = 2*x

deactivate()[source]

Deactivate this template by setting its rate law to zero.

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:

Template

Returns:

A Template object

get_concept_names()[source]

Return the concept names in this template.

Return type:

Set[str]

Returns:

The set of concept names in this template.

get_concepts()[source]

Return the concepts in this template.

Return type:

List[Concept]

Returns:

A list of concepts in this template.

get_concepts_by_role()[source]

Return the concepts in this template as a dict keyed by role.

Return type:

Dict[str, Concept]

Returns:

A dict of concepts in this template keyed by role.

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_interactors()[source]

Return the interactors in this template.

Return type:

List[Concept]

Returns:

A list of interactors 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.

Return type:

Tuple

Returns:

A tuple of the type and concepts 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.

get_parameter_names()[source]

Get the set of parameter names.

Return type:

Set[str]

Returns:

The set of parameter names.

is_equal_to(other, with_context=False, config=None)[source]

Check if this template is equal to another template

Parameters:
  • other (Template) – The other template to check for equality with this one with

  • with_context (bool) – If True, the contexts are taken into account when checking for equality. Default: False.

  • config (Config) – Configuration defining priority and exclusion for identifiers.

Return type:

bool

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:

bool

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.

update_parameter_name(old_name, new_name)[source]

Update the name of a parameter in the rate law.

Parameters:
  • old_name (str) – The old name of the parameter.

  • new_name (str) – The new name of the parameter.

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:

Template

Returns:

A copy of this template with the mass action rate law.

with_rate_law(rate_law, local_dict=None)[source]
Return type:

Template

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 controller: Concept [Required]

The controller of the conversion.

field outcome: Concept [Required]

The outcome of the conversion.

field provenance: List[Provenance] [Optional]

The provenance of the conversion.

field subject: Concept [Required]

The subject of the conversion.

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:

GroupedControlledConversion

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:

ControlledConversion

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:

ControlledConversion

Returns:

A copy of this template with the given controller.

concept_keys: ClassVar[List[str]] = ['controller', 'subject', 'outcome']
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 controller: Concept [Required]

The controller of the production.

field outcome: Concept [Required]

The outcome of the production.

field provenance: List[Provenance] [Optional]

Provenance of the template

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:

GroupedControlledProduction

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:

ControlledProduction

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:

ControlledProduction

Returns:

A copy of this template with the given controller replacing the existing controller.

concept_keys: ClassVar[List[str]] = ['controller', 'outcome']
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 controller: Concept [Required]

The controller of the degradation.

field provenance: List[Provenance] [Optional]

The provenance of the degradation.

field subject: Concept [Required]

The subject of the degradation.

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:

GroupedControlledDegradation

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:

ControlledDegradation

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:

ControlledDegradation

Returns:

A copy of this template as a ControlledDegradation template with the given controller replacing the existing controllers.

concept_keys: ClassVar[List[str]] = ['controller', 'subject']
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 outcome: Concept [Required]

The outcome of the conversion.

field provenance: List[Provenance] [Optional]

The provenance of the conversion.

field subject: Concept [Required]

The subject of the conversion.

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:

NaturalConversion

Returns:

A copy of this template with context added

concept_keys: ClassVar[List[str]] = ['subject', 'outcome']
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 outcome: Concept [Required]

The outcome of the production.

field provenance: List[Provenance] [Optional]

The provenance of the production.

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:

NaturalProduction

Returns:

A copy of this template with context added

concept_keys: ClassVar[List[str]] = ['outcome']
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 provenance: List[Provenance] [Optional]

The provenance of the degradation.

field subject: Concept [Required]

The subject of the degradation.

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:

NaturalDegradation

Returns:

A copy of this template with context added

concept_keys: ClassVar[List[str]] = ['subject']
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 controllers: List[Concept] [Required]

The controllers of the conversion.

field outcome: Concept [Required]

The outcome of the conversion.

field provenance: List[Provenance] [Optional]

The provenance of the conversion.

field subject: Concept [Required]

The subject of the conversion.

field type: Literal['GroupedControlledConversion'] = 'GroupedControlledConversion'
Constraints:
  • const = GroupedControlledConversion

add_controller(controller)[source]

Add an additional controller.

Return type:

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:

GroupedControlledConversion

Returns:

A copy of this template with context added

with_controllers(controllers)[source]

Return a copy of this template with the given controllers.

Parameters:

controllers – The controllers to use for the new template.

Return type:

GroupedControlledConversion

Returns:

A copy of this template with the given controllers.

concept_keys: ClassVar[List[str]] = ['controllers', 'subject', 'outcome']
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 controllers: List[Concept] [Required]

The controllers of the production.

field outcome: Concept [Required]

The outcome of the production.

field provenance: List[Provenance] [Optional]

The provenance of the production.

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:

GroupedControlledProduction

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:

GroupedControlledProduction

Returns:

A copy of this template with context added

with_controllers(controllers)[source]

Return a copy of this template with the given controllers.

Parameters:

controllers – The controllers to use for the new template.

Return type:

GroupedControlledProduction

Returns:

A copy of this template with the given controllers replacing the existing controllers.

concept_keys: ClassVar[List[str]] = ['controllers', 'outcome']
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 controllers: List[Concept] [Required]

The controllers of the degradation.

field provenance: List[Provenance] [Optional]

The provenance of the degradation.

field subject: Concept [Required]

The subject of the degradation.

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:

GroupedControlledDegradation

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:

GroupedControlledDegradation

Returns:

A copy of this template with context added

with_controllers(controllers)[source]

Return a copy of this template with the given controllers.

Parameters:

controllers – The controllers to use for the new template.

Return type:

GroupedControlledDegradation

Returns:

A copy of this template with the given controllers replacing the existing controllers.

concept_keys: ClassVar[List[str]] = ['controllers', 'subject']
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 provenance: List[Provenance] [Optional]

The provenance of the template.

field subject: Concept [Required]

The subject of the replication.

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:

NaturalReplication

Returns:

A copy of this template with context added

concept_keys: ClassVar[List[str]] = ['subject']
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 controller: Concept [Required]

The controller of the replication.

field provenance: List[Provenance] [Optional]

The provenance of the replication.

field subject: Concept [Required]

The subject of the replication.

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:

ControlledReplication

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:

ControlledReplication

Returns:

A copy of this template with the given controller replacing the existing controller.

concept_keys: ClassVar[List[str]] = ['controller', 'subject']
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:
field provenance: List[Provenance] [Optional]

The provenance.

field subject: Concept [Required]

The subject.

field type: Literal['StaticConcept'] = 'StaticConcept'
Constraints:
  • const = StaticConcept

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:

StaticConcept

Returns:

A copy of this template with context added

concept_keys: ClassVar[List[str]] = ['subject']
templates_equal(templ, other_templ, with_context, config)[source]

Check if two Template objects are equal

Parameters:
  • templ (Template) – A template to compare.

  • other_templ (Template) – The other template to compare.

  • with_context (bool) – If True, also check the contexts of the contained Concepts of the Template.

  • config (Config) – Configuration defining priority and exclusion for identifiers.

Return type:

bool

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:

bool

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:

bool

Returns:

True if there is an exact match between the two lists of concepts.

is_production(template)[source]

Return True if the template is a form of production.

is_degradation(template)[source]

Return True if the template is a form of degradation.

is_conversion(template)[source]

Return True if the template is a form of conversion.

is_replication(template)[source]

Return True if the template is a form of replication.

has_subject(template)[source]

Return True if the template has a subject.

has_outcome(template)[source]

Return True if the template has an outcome.

has_controller(template)[source]

Check if the template has a controller.

Parameters:

template (Template) – The template to check. The template must be representing a controlled process.

Return type:

bool

Returns:

True if the template has a controller

num_controllers(template)[source]

Return the number of controllers in the template.

get_binding_templates(a, b, c, kf, kr)[source]

Return a list of templates emulating a reversible binding process.

conversion_to_deg_prod(conv_template)[source]

Given a conversion template, compile into degradation/production templates.

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 model

  • key (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 in strata 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 if strata_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 to NaturalConversion

  • 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:

TemplateModel

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:

TemplateModel

Returns:

A template model with aggregated parameters.

get_term_roles(term, template, parameters)[source]

Return terms in a rate law by role.

Parameters:
  • term – A sympy expression.

  • template (Template) – A template.

  • parameters (Mapping[str, Parameter]) – A dict of parameters in the template model, needed to interpret the semantics of rate laws.

Return type:

Mapping[str, List[str]]

Returns:

A dict of lists of symbols in the term by role.

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:

TemplateModel

Returns:

A template model with all entity concentrations converted to dimensionless units.

deactivate_templates(template_model, condition)[source]

Deactivate templates that satisfy a given condition.

Parameters:

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:
  • template_models (List[TemplateModel]) – The list of TemplateModels to compare

  • refinement_func (Callable[[str, str], bool]) – The refinement function to use when comparing concepts

Return type:

ModelComparisonGraphdata

Returns:

The ModelComparisonGraphdata

get_similarity_score(model1_id, model2_id)[source]

Get the similarity score of the model comparison

Parameters:
  • model1_id (int) – The id of the first model

  • model2_id (int) – The id of the second model

Return type:

float

Returns:

The similarity score

get_similarity_scores()[source]

Get the similarity scores for all model comparisons

Returns:

A list of dictionaries with the model ids and the similarity score

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:
  • template_models (List[TemplateModel]) – The list of TemplateModels to compare

  • refinement_func (Callable[[str, str], bool]) – The refinement function to use when comparing concepts

compare_models()[source]

Run model comparison

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 model

  • template_model2 (TemplateModel) – The second template model

  • refinement_function (Callable[[str, str], bool]) – The refinement function to use when comparing concepts

  • tag1 (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

Parameters:
  • path (str) – The path to the output file

  • prog (str) – The graphviz layout program to use, such as “dot”, “neato”, etc.

  • format (Optional[str]) – Set the file format explicitly

  • args (str) – Additional arguments to pass to the graphviz bash program as a string. Example: “args=”-Nshape=box -Edir=forward -Ecolor=red “

graph_as_json()[source]

Return the comparison graph json serializable node-link data

Return type:

Dict

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.

  • format (Optional[str]) – Set the file format explicitly

  • 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

Parameters:

transitive_closure (Set[Tuple[str, str]]) – The transitive closure of the refinement relationship

is_ontological_child(child_curie, parent_curie)[source]

Check if the child is a refinement of the parent

Parameters:
  • child_curie (str) – The child curie

  • parent_curie (str) – The parent curie

Return type:

bool

Returns:

True if the child is a refinement of the parent, False otherwise

get_dkg_refinement_closure()[source]

Return a refinement closure from the DKG

Return type:

RefinementClosure

Returns:

The refinement closure

Meta-model schema (mira.metamodel.schema)

Rebuild with python -m mira.metamodel.schema.

get_json_schema()[source]

Get the JSON schema for MIRA.

Returns:

The JSON schema for MIRA.

Return type:

JSON

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:

Mapping[str, TemplateModel]

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:

TemplateModel

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.

expression_to_mathml(expression, *args, **kwargs)[source]

Convert a sympy expression to MathML string.

Here we pay attention to not style underscores and numeric suffixes in special ways.

Parameters:
  • expression (Expr) – A sympy expression to convert.

  • args (list) – Additional arguments to pass to sympy.mathml.

  • kwargs (dict) – Additional keyword arguments to pass to sympy.mathml.

Return type:

str

Returns:

A MathML string representing the sympy expression.

mathml_to_expression(xml_str)[source]

Convert a MathML string to a sympy expression.

Parameters:

xml_str (str) – A MathML string.

Return type:

Expr

Returns:

A sympy expression.

Notes

This function is a wrapper around the SBMLMathMLParser class from the sbmlmath package, which has to be installed.

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

classmethod from_json(data)[source]
Return type:

Unit

Utilities (mira.metamodel.utils)

get_parseable_expression(s)[source]

Return an expression that can be parsed using sympy.

Return type:

str

revert_parseable_expression(s)[source]

Return an expression to its original form.

Return type:

str

safe_parse_expr(s, local_dict=None)[source]

Parse an expression that may contain lambda functions.

Return type:

Expr

class SympyExprStr(*args)[source]

Bases: Expr

sanity_check_tm(tm)[source]

Apply a short sanity check to a template model.

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:
  • variables (Dict[int,Variable]) – Mapping of Variables.

  • op1s (Dict[int,Op1]) – Mapping of Op1s (Operation 1s).

  • op2s (Dict[int,Op2]) – Mapping of Op2s (Operation 2s).

  • summations (Dict[int,Summation]) – Mapping of Summations.

  • tangent_variables (Dict[int,TangentVariable]) – Mapping of TangentVariables.

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.

id

The id of the tangent variable

Type:

int

type

The type of the variable.

Type:

str

name

The name of the variable.

Type:

str

expression

The expression of the variable.

Type:

sympy.Expr

identifiers

The mapping of namespaces to identifiers associated with the Variable.

Type:

Mapping[str,str]

class TangentVariable(id, incl_var)[source]

Bases: object

Dataclass that represents a tangent variable in MIRA’s internal representation of a Decapode.

id

The id of the tangent variable.

Type:

int

incl_var

The variable that is the result of a derivative operation associated with the tangent variable.

Type:

Variable

class Summation(id, summands, sum)[source]

Bases: object

Dataclass that represents a summation in MIRA’s internal representation of a decapode.

id

The id of the summation.

Type:

int

summands

A list of Variables that are a part of the summation.

Type:

list[Variable]

sum

The Variable that is the result of the summation.

Type:

Variable

class Op1(id, src, tgt, function_str)[source]

Bases: object

Dataclass that represents unary operations in MIRA’s internal representation of a decapode.

id

The id of the operation.

Type:

int

src

The Variable that is the source of the operation.

Type:

Variable

tgt

The Variable that is the target of the operation.

Type:

Variable

function_str

The operator of the operation.

Type:

str

class Op2(id, proj1, proj2, res, function_str)[source]

Bases: object

Dataclass that represents binary operations in MIRA’s internal representation of a decapode.

id

The id of the operation.

Type:

int

proj1

The Variable that is the first input to the operation.

Type:

Variable

proj2

The Variable that is the second input to the operation.

Type:

Variable

res

The variable that is the result of the operation.

Type:

Variable

function_str

The operator of the operation.

Type:

str

class RootVariable(id, type, name, expression=<factory>, identifiers=<factory>)[source]

Bases: Variable

Dataclass that represents a variable that is the output of a unary ( derivative) operation and the output of a series of unary and binary operations as well.

expression

A list containing both expressions associated with a RootVariable: One expression built up from a unary operation (derivative) and one built up from a series of unary and binary operations.

Type:

list[sympy.Expr]