EnzymeML / PyEnzyme

🧬 - Data management and modeling framework based on EnzymeML.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REST API: Unit and creator entries do not appear in the EnzymeML documents

StephanM87 opened this issue · comments

When I send a request to the /create Enpoint, containing the following JSON:

JSON
{
  'name': 'decarboxylation',
  'pubmedid': '23232',
  'url': 'www.example.com',
  'doi': 'doi:10.101012323',
  'created': '10.01.2022',
  'modified': '11.01.2022',
  'vessels': {
    'vessel1': {
      'name': 'eppi',
      'volume': 1.0,
      'unit': 'ml',
      'constant': True,
      'id': 'v1',
      'meta_id': 'asd',
      'uri': 'sffdfd',
      'creator_id': 'dsffd'
    },
    'vessel2': {
      'name': 'falcon',
      'volume': 1.0,
      'unit': 'ul',
      'constant': True,
      'id': 'v2',
      'meta_id': 'asd',
      'uri': 'sffdfd',
      'creator_id': 'a1'
    }
  },
  'units': {
    'mL': {
      'name': 'mL',
      'id': 'u0',
      'meta_id': 'meta_u0',
      'units': [
        {
          'kind': 'litre',
          'exponent': -3.0,
          'scale': 0,
          'multiplier': 0.0
        }
      ],
      'ontology': ''
    },
    'uL': {
      'name': 'uL',
      'id': 'u1',
      'meta_id': 'meta_u1',
      'units': [
        {
          'kind': 'litre',
          'exponent': -6.0,
          'scale': 0,
          'multiplier': 0.0
        }
      ],
      'ontology': ''
    },
    'mole_l': {
      'name': 'mole',
      'id': 'u2',
      'meta_id': 'meta_u2',
      'units': [
        {
          'kind': 'mole',
          'exponent': -9.0,
          'scale': 0,
          'multiplier': 0.0
        }
      ],
      'ontology': 'SBO_0000472'
    }
  },
  'creators': {
    'creator1': {
      'given_name': 'Jan',
      'family_name': 'jansen',
      'mail': 'sdads',
      'id': 'a1'
    }
  },
  'proteins': {
    'protein_1': {
      'name': 'ahas',
      'id': 'p0',
      'vessel_id': 'v1',
      'meta_id': 'adsd',
      'init_conc': 0.0,
      'constant': True,
      'boundary': False,
      'unit': 'mmole/l',
      'ontology': 'SBO:0000176',
      'uri': 'fdsffsd',
      'creator_id': 'dsfdfsd',
      'sequence': 'ASDF',
      'ecnumber': '1.1.1.1',
      'organism': 'e.coli',
      'organism_tax_id': 'awdwada',
      'uniprotid': 'dffdsdf'
    }
  },
  'reactants': {
    'reactant1': {
      'name': 'acetaldehyde',
      'id': 's1',
      'vessel_id': 'sfdg',
      'meta_id': 'sdfsf',
      'init_conc': 0.0,
      'constant': False,
      'boundary': False,
      'unit': 'mgram/ml',
      'ontology': 'SBO:0000377',
      'uri': 'fdfs',
      'creator_id': 'sdfds',
      'smiles': 'fds',
      'inchi': 'sdfdsf',
      'chebi_id': 'sefsef'
    }
  },
  'reactions': {
    'protein_1': {
      'name': 'decarboxaltion',
      'reversible': True,
      'temperature': 37.0,
      'temperature_unit': 'Celsius',
      'ph': 5.0,
      'ontology': 'SBO:0000176',
      'id': 'r1',
      'meta_id': 'meta_r1',
      'uri': 'www.www.',
      'creator_id': 'creator_1',
      'model': None,
      'educts': [
        {
          'species_id': 'name',
          'stoichiometry': 1.0,
          'constant': True,
          'ontology': 'SBO:0000176'
        }
      ],
      'products': [
        
      ],
      'modifiers': [
        
      ]
    }
  },
  'level': 3,
  'version': '2'
}

I receive a EnzymeML document, which looks like this:

EnzymeML
<?xml version="1.0" encoding="UTF-8"?>

-<sbml version="2" level="3" xmlns="http://www.sbml.org/sbml/level3/version2/core">


-<model name="decarboxylation" id="decarboxylation">


-<annotation>


-<enzymeml:references xmlns:enzymeml="http://sbml.org/enzymeml/version2">

<enzymeml:doi>doi:10.101012323</enzymeml:doi>

<enzymeml:pubmedID>https://identifiers.org/pubmed:23232</enzymeml:pubmedID>

<enzymeml:url>www.example.com</enzymeml:url>

</enzymeml:references>

</annotation>


-<listOfUnitDefinitions>


-<unitDefinition name="ml" id="u0" metaid="METAID_U0">


-<listOfUnits>

<unit multiplier="1" scale="-3" exponent="1" kind="litre"/>

</listOfUnits>

</unitDefinition>


-<unitDefinition name="ul" id="u1" metaid="METAID_U1">


-<listOfUnits>

<unit multiplier="1" scale="-6" exponent="1" kind="litre"/>

</listOfUnits>

</unitDefinition>


-<unitDefinition name="mmole / l" id="u2" metaid="METAID_U2">


-<listOfUnits>

<unit multiplier="1" scale="1" exponent="-1" kind="litre"/>

<unit multiplier="1" scale="-3" exponent="1" kind="mole"/>

</listOfUnits>

</unitDefinition>


-<unitDefinition name="mgram / ml" id="u3" metaid="METAID_U3">


-<listOfUnits>

<unit multiplier="1" scale="-3" exponent="1" kind="gram"/>

<unit multiplier="1" scale="-3" exponent="-1" kind="litre"/>

</listOfUnits>

</unitDefinition>


-<unitDefinition name="celsius" id="u4" metaid="METAID_U4">


-<listOfUnits>

<unit multiplier="1" scale="1" exponent="1" kind="kelvin"/>

</listOfUnits>

</unitDefinition>

</listOfUnitDefinitions>


-<listOfCompartments>

<compartment name="eppi" id="v0" constant="true" units="u0" size="1" spatialDimensions="3"/>

<compartment name="falcon" id="v1" constant="true" units="u1" size="1" spatialDimensions="3"/>

</listOfCompartments>


-<listOfSpecies>


-<species name="ahas" id="p0" metaid="METAID_P0" constant="true" boundaryCondition="false" hasOnlySubstanceUnits="false" substanceUnits="u2" initialConcentration="0" compartment="v1" sboTerm="SBO:0000176">


-<annotation>


-<enzymeml:protein xmlns:enzymeml="http://sbml.org/enzymeml/version2">

<enzymeml:sequence>ASDF</enzymeml:sequence>

<enzymeml:ECnumber>1.1.1.1</enzymeml:ECnumber>

<enzymeml:uniprotID>dffdsdf</enzymeml:uniprotID>

<enzymeml:organism>e.coli</enzymeml:organism>

</enzymeml:protein>

</annotation>

</species>


-<species name="acetaldehyde" id="s0" metaid="METAID_S0" constant="false" boundaryCondition="false" hasOnlySubstanceUnits="false" substanceUnits="u3" initialConcentration="0" compartment="sfdg" sboTerm="SBO:0000377">


-<annotation>


-<enzymeml:reactant xmlns:enzymeml="http://sbml.org/enzymeml/version2">

<enzymeml:inchi>sdfdsf</enzymeml:inchi>

<enzymeml:smiles>fds</enzymeml:smiles>

</enzymeml:reactant>

</annotation>

</species>

</listOfSpecies>


-<listOfReactions>


-<reaction name="decarboxaltion" id="r0" metaid="METAID_R0" sboTerm="SBO:0000176" reversible="true">


-<listOfReactants>

<speciesReference constant="true" sboTerm="SBO:0000176" stoichiometry="1" species="name"/>

</listOfReactants>

</reaction>

</listOfReactions>

</model>

</sbml>

I unfortunately cannot spot the creator or the defined unit? Is there any help?

Thank you for the issue submission Stephan!

Regarding the handling of authors, these are currently not written in the SBML file but to the metadata of the OMEX archive. This is an artifact from PyEnzyme's initial implementation due to an error using libSBML. It is an ongoing ToDo that just yet hasn't been fixed, but will be done in the future. For this, I created a new issue to not lose track.

In terms of units, it is not meant for the user to insert UnitDef objects manually, because that would require a background in libSBML. To dive deeper into the workings of the /create, the source code of the endpoint rebuilds the entire document, where units are individually inferred from the given objects - Just as "regular" PyEnzyme code. Unit definitions are thus parsed from their "string" counterparts, which has some advantages:

  • Users are not expected to take care of unit definitions, which is a technicality the library handles well
  • Unit definitions are essential for SBML but not PyEnzyme's JSON format. In general, IDs should be handled by the API not the user (PyEnzyme assigns IDs to almost anything)
  • Last but not least, it reduces boilerplate in the JSON input

Finally, the issue is that I can not remove the "unit"-part from the schema since it is derived from the PyDantic data model by FastAPI . Once I'll figure a way out to discard parts from the scheme, this will definitely be removed.

Hope that helped :-)