Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new link system
Browse files Browse the repository at this point in the history
JR-1991 committed Dec 9, 2023
1 parent 5e5f05b commit f38d5b3
Showing 6 changed files with 72 additions and 12 deletions.
7 changes: 7 additions & 0 deletions links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "EnzymeML Links"
module: "links"
links:
- name: "sbml"
template: "sbml.toml"
script: "sbml.py"
function: "link"
Empty file added links/__init__.py
Empty file.
Binary file added links/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added links/__pycache__/sbml.cpython-311.pyc
Binary file not shown.
53 changes: 53 additions & 0 deletions links/sbml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from typing import Dict
from sdRDM import Linker


def link(
dataset: "DataModel", # type: ignore
template: Dict,
):
"""
Links the dataset to an SBML document based on the provided mapping template.
Args:
dataset: The dataset to be linked.
template: The mapping template specifying the link between the dataset and SBML.
Raises:
AssertionError: If the mapping template does not specify a 'SBML' source.
Returns:
None
"""

linker = Linker(template)

assert (
"SBML" in linker.__sources__
), "Not able to link to SBML. Please specify a 'SBML' source in the mapping template."

sbmldoc = linker.__sources__["SBML"]()
linker(dataset, sbmldoc)

for vessel in dataset.vessels:
linker(vessel, sbmldoc.model)

for protein in dataset.proteins:
linker(protein, sbmldoc.model)

for reactant in dataset.reactants:
linker(reactant, sbmldoc.model)

for reaction in dataset.reactions:
mapped = linker(reaction, sbmldoc.model)

for educt in reaction.educts:
linker(educt, mapped.reactions)

for product in reaction.products:
linker(product, mapped.reactions)

for modifier in reaction.modifiers:
linker(modifier, mapped.reactions)

return sbmldoc
24 changes: 12 additions & 12 deletions links/sbml.toml
Original file line number Diff line number Diff line change
@@ -7,71 +7,71 @@ SBML = "https://github.com/JR-1991/sbml-specifications.git@Refactored-version"
id = "SBML/model/id"
name = "SBML/model/name"

[vessels]
["EnzymeMLDocument/vessels"]
id = "SBML/model/compartments/id"
name = "SBML/model/compartments/name"
volume = "SBML/model/compartments/size"
unit = "SBML/model/compartments/units"
constant = "SBML/model/compartments/constant"

[proteins]
["EnzymeMLDocument/proteins"]
id = "SBML/model/species/id"
name = "SBML/model/species/name"
vessel_id = "SBML/model/species/compartment"
constant = "SBML/model/species/constant"
init_conc = "SBML/model/species/initial_concentration"
unit = "SBML/model/species/substance_units"

[complexes]
["EnzymeMLDocument/complexes"]
id = "SBML/model/species/id"
name = "SBML/model/species/name"
vessel_id = "SBML/model/species/compartment"
constant = "SBML/model/species/constant"
init_conc = "SBML/model/species/initial_concentration"
unit = "SBML/model/species/substance_units"

[reactants]
["EnzymeMLDocument/reactants"]
id = "SBML/model/species/id"
name = "SBML/model/species/name"
vessel_id = "SBML/model/species/compartment"
constant = "SBML/model/species/constant"
init_conc = "SBML/model/species/initial_concentration"
unit = "SBML/model/species/substance_units"

[reactions]
["EnzymeMLDocument/reactions"]
id = "SBML/model/reactions/id"
name = "SBML/model/reactions/name"
reversible = "SBML/model/reactions/reversible"

[global_parameters]
["EnzymeMLDocument/parameters"]
id = "SBML/model/parameters/id"
name = "SBML/model/parameters/name"
value = "SBML/model/parameters/value"
unit = "SBML/model/parameters/units"

["reactions/model"]
["EnzymeMLDocument/reactions/model"]
id = "SBML/model/reactions/kinetic_law/id"
name = "SBML/model/reactions/kinetic_law/name"
equation = "SBML/model/reactions/kinetic_law/math"

["reactions/model/parameters"]
["EnzymeMLDocument/reactions/model/parameters"]
id = "SBML/model/reactions/kinetic_law/local_parameters/id"
name = "SBML/model/reactions/kinetic_law/local_parameters/name"
value = "SBML/model/reactions/kinetic_law/local_parameters/value"
unit = "SBML/model/reactions/kinetic_law/local_parameters/units"

["reactions/educts"]
["EnzymeMLDocument/reactions/educts"]
id = "SBML/model/reactions/reactants/id"
species_id = "SBML/model/reactions/reactants/species"
stoichiometry = "SBML/model/reactions/reactants/stoichiometry"
constant = "SBML/model/reactions/reactants/constant"

["reactions/products"]
["EnzymeMLDocument/reactions/products"]
id = "SBML/model/reactions/products/id"
species_id = "SBML/model/reactions/products/species"
stoichiometry = "SBML/model/reactions/products/stoichiometry"
constant = "SBML/model/reactions/products/constant"

["reactions/modifiers"]
["EnzymeMLDocument/reactions/modifiers"]
id = "SBML/model/reactions/modifiers/id"
species_id = "SBML/model/reactions/modifiers/species"
species_id = "SBML/model/reactions/modifiers/species"

0 comments on commit f38d5b3

Please sign in to comment.