diff --git a/links.yml b/links.yml new file mode 100644 index 0000000..257fbaa --- /dev/null +++ b/links.yml @@ -0,0 +1,7 @@ +name: "EnzymeML Links" +module: "links" +links: + - name: "sbml" + template: "sbml.toml" + script: "sbml.py" + function: "link" \ No newline at end of file diff --git a/links/__init__.py b/links/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/links/__pycache__/__init__.cpython-311.pyc b/links/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..5de9f12 Binary files /dev/null and b/links/__pycache__/__init__.cpython-311.pyc differ diff --git a/links/__pycache__/sbml.cpython-311.pyc b/links/__pycache__/sbml.cpython-311.pyc new file mode 100644 index 0000000..d9b499e Binary files /dev/null and b/links/__pycache__/sbml.cpython-311.pyc differ diff --git a/links/sbml.py b/links/sbml.py new file mode 100644 index 0000000..54e981a --- /dev/null +++ b/links/sbml.py @@ -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 diff --git a/links/sbml.toml b/links/sbml.toml index 22f8bdd..71701b9 100644 --- a/links/sbml.toml +++ b/links/sbml.toml @@ -7,14 +7,14 @@ 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" @@ -22,7 +22,7 @@ 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" @@ -30,7 +30,7 @@ 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" @@ -38,40 +38,40 @@ 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" \ No newline at end of file