From f38d5b3f5d44694e3963bc7d352a55b1b4f5f34e Mon Sep 17 00:00:00 2001 From: Jan Range Date: Sat, 9 Dec 2023 17:47:51 +0100 Subject: [PATCH] new link system --- links.yml | 7 +++ links/__init__.py | 0 links/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 176 bytes links/__pycache__/sbml.cpython-311.pyc | Bin 0 -> 1987 bytes links/sbml.py | 53 +++++++++++++++++++++ links/sbml.toml | 24 +++++----- 6 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 links.yml create mode 100644 links/__init__.py create mode 100644 links/__pycache__/__init__.cpython-311.pyc create mode 100644 links/__pycache__/sbml.cpython-311.pyc create mode 100644 links/sbml.py 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 0000000000000000000000000000000000000000..5de9f125a6c9e68b0d9d145eb114d12fae75f668 GIT binary patch literal 176 zcmZ3^%ge<81V$4}QbF`%5CH>>P{wCAAY(d13PUi1CZpdNI#eokgyc4`rrD%OvW&&XDsgDi64Q~|#C6)(xuBweKt*X%P!mDR4=EA~8_y)z*t^!w zIw8oGBH*xxBKZ)hKJ?H73PSl$IN8!3tUX!c#LXz;(i3lHy;d9ud3t{HX8e8cy_tC) z|C&t35yjBT#BdBo9Y3}T&W1&3#n&BLtyK(%79+!yd{E&d z!{%q{qm^caNR3E&G~Y)o{xOtz0`Sw2gnp1B=sb!@H%8x$Bbzcu zHc&%8f!wE~swC7v<veU)x10;x3QGOtz0Mb7hSV1LIjgBRw6b=NlWxWYC)Uu*qgem3E3K@LvEqUizmgRjV@(Lw#Q(FN z(}oOfB^zJECC4!c?074(oXYC9#%d}P~}y@Eg56}$RZI$}|VP0I=MVgqOS zsbn#;>UNQa;i*%%&2#ZLEt85Z`3i@B|LG>gFm@`GpR6bvM*dA6e^Q}vu$LvkrC?td zE6eBNHvb*?6WiNCDQtV&*Y+uFtit?gHFyo+njBg(nIE&MQFIK`30>Gb^HoafMOe}S z7kDusmUc_jX1RpTe=;`jW?vQ81WyjzsaBvPd^O1AYr_n_9wr!i5Z_mM)s*;Akw##7 z7GEDFNkDMkAfdeepzt}|3@elk(>BaKT38*nA1lDKcDQF-b(0hru}QTM)FcL0;DzOD zhrYsB?YAHVJt3$N;j?jMkrkB3WF`1JFaVsKX%x~ zySdm+-18FmIzsz1x4apiF_ss`T@R2C+H2n2{cd8(ODuJS_Ghs-yU0O&-?4)GI6%JB z{=&;FbrX3nk?#l{$Q+}hMEYp+4DJGL=Aypp9P;PF<}bV-W#sAVhUjB)W4|H$7OdMD zFt7FZpiAl%`o4V|ru_eieF+AlN>UHabjG!ZW;^3LP?x22FF8AqVeF@-22mIX=n^9m F{{y+-{Y?M> literal 0 HcmV?d00001 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