sys-bio / libOmexMeta

libOmexMeta is a library aimed at providing developer-level support for reading, writing, editing and managing semantic annotations for biosimulation models.
https://sys-bio.github.io/libOmexMeta/
Apache License 2.0
8 stars 6 forks source link

Reading Reactions from SBML files #47

Closed jhgennari closed 3 years ago

jhgennari commented 3 years ago

RDF.from_file() does the wrong thing with Reactions when reading from an SBML file. For example, from BioModels #385, for the reaction tagged as metaid_0000042, the system produces annotations as follows:

http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000042 bqbiol:isPropertyOf local:Process0000 ; bqbiol:isVersionOf https://identifiers.org/opb:OPB_00592 . local:Process0000 semsim:hasMediatorParticipant local:MediatorParticipant0000 ; semsim:hasSinkParticipant local:SinkParticipant0000 ; semsim:hasSourceParticipant local:SourceParticipant0000, local:SourceParticipant0001, local:SourceParticipant0002 .

Whereas, it should produce annotations like

http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000042 semsim:hasMediatorParticipant local:MediatorParticipant0000 ; semsim:hasSinkParticipant local:SinkParticipant0000 ; semsim:hasSourceParticipant local:SourceParticipant0000, local:SourceParticipant0001, local:SourceParticipant0002 . local: ProcessProperty001 bqbiol:isPropertyOf http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000042; bqbiol:isVersionOf https://identifiers.org/opb:OPB_00592 .

This sort of issue is also demonstrated in great detail in the supplemental material jupyter notebook for the manuscript.

CiaranWelsh commented 3 years ago

I'm hoping that this is an easy fix. I found that the SBMLSemanticExtraction was using an old call to PhysicalProcess. Updating it and reading model 385 with .

from pyomexmeta import RDF, Editor

rdf = RDF.from_file("BIOMD0000000385.xml", "rdfxml")
rdf.to_file("turtle", "385.rdf")

produces the rdf below. @jhgennari Please confirm whether this solves your issue. If it does I'll merge the changes and close the issue.

Thanks,

// 385.rdf

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix bqmodel: <http://biomodels.net/model-qualifiers/> .
@prefix bqbiol: <http://biomodels.net/biology-qualifiers/> .
@prefix semsim: <http://bime.uw.edu/semsim/> .
@prefix OMEXlib: <http://omex-library.org/> .
@prefix local: <http://omex-library.org/NewOmex.omex/NewModel.rdf#> .

local:MediatorParticipant0000
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000033> .

local:MediatorParticipant0001
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000032> .

local:MediatorParticipant0002
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000031> .

local:ProcessProperty0000
    bqbiol:isPropertyOf <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000042> ;
    bqbiol:isVersionOf <https://identifiers.org/opb:OPB_00592> .

local:ProcessProperty0001
    bqbiol:isPropertyOf <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000043> ;
    bqbiol:isVersionOf <https://identifiers.org/opb:OPB_00592> .

local:ProcessProperty0002
    bqbiol:isPropertyOf <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000044> ;
    bqbiol:isVersionOf <https://identifiers.org/opb:OPB_00592> .

local:ProcessProperty0003
    bqbiol:isPropertyOf <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000045> ;
    bqbiol:isVersionOf <https://identifiers.org/opb:OPB_00592> .

local:SinkParticipant0000
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000030> .

local:SinkParticipant0001
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000030> .

local:SinkParticipant0002
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000029> .

local:SinkParticipant0003
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000031> .

local:SourceParticipant0000
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000029> .

local:SourceParticipant0001
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000032> .

local:SourceParticipant0002
    semsim:hasMultiplier "2"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000031> .

local:SourceParticipant0003
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000029> .

local:SourceParticipant0004
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000033> .

local:SourceParticipant0005
    semsim:hasMultiplier "2"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000031> .

local:SourceParticipant0006
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000030> .

local:SourceParticipant0007
    semsim:hasMultiplier "1"^^rdf:double ;
    semsim:hasPhysicalEntityReference <http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000034> .

<http://omex-library.org/NewOmex.omex/NewModel.xml#_272044>
    bqbiol:hasTaxon [
        rdf:_1 <http://identifiers.org/taxonomy/33090> ;
        a rdf:Bag
    ] ;
    bqmodel:is [
        rdf:_1 <http://identifiers.org/biomodels.db/MODEL1109270001> ;
        a rdf:Bag
    ], [
        rdf:_1 <http://identifiers.org/biomodels.db/BIOMD0000000385> ;
        a rdf:Bag
    ], [
        rdf:_1 <http://identifiers.org/obo.go/GO:0019253> ;
        a rdf:Bag
    ] ;
    bqmodel:isDescribedBy [
        rdf:_1 <http://identifiers.org/pubmed/22001849> ;
        a rdf:Bag
    ] ;
    <http://purl.org/dc/elements/1.1/creator> [
        rdf:_1 [
            <http://www.w3.org/2001/vcard-rdf/3.0#EMAIL> "viji@ebi.ac.uk" ;
            <http://www.w3.org/2001/vcard-rdf/3.0#N> [
                <http://www.w3.org/2001/vcard-rdf/3.0#Family> "Chelliah" ;
                <http://www.w3.org/2001/vcard-rdf/3.0#Given> "Vijayalakshmi"
            ] ;
            <http://www.w3.org/2001/vcard-rdf/3.0#ORG> [
                <http://www.w3.org/2001/vcard-rdf/3.0#Orgname> "EMBL-EBI"
            ]
        ] ;
        rdf:_2 [
            <http://www.w3.org/2001/vcard-rdf/3.0#EMAIL> "nikoloski@mpimp-golm.mpg.de" ;
            <http://www.w3.org/2001/vcard-rdf/3.0#N> [
                <http://www.w3.org/2001/vcard-rdf/3.0#Family> "Nikoloski" ;
                <http://www.w3.org/2001/vcard-rdf/3.0#Given> "Zoran"
            ] ;
            <http://www.w3.org/2001/vcard-rdf/3.0#ORG> [
                <http://www.w3.org/2001/vcard-rdf/3.0#Orgname> "Institute  of Biochemistry and Biology, University of Potsdam, 14476 Potsdam, Germany"
            ]
        ] ;
        rdf:_3 [
            <http://www.w3.org/2001/vcard-rdf/3.0#EMAIL> "arnold@mpimp-golm.mpg.de" ;
            <http://www.w3.org/2001/vcard-rdf/3.0#N> [
                <http://www.w3.org/2001/vcard-rdf/3.0#Family> "Arnold" ;
                <http://www.w3.org/2001/vcard-rdf/3.0#Given> "Anne"
            ] ;
            <http://www.w3.org/2001/vcard-rdf/3.0#ORG> [
                <http://www.w3.org/2001/vcard-rdf/3.0#Orgname> "Max-Planck-Institute of Molecular Plant Physiology"
            ]
        ] ;
        a rdf:Bag
    ] ;
    <http://purl.org/dc/terms/created> [
        <http://purl.org/dc/terms/W3CDTF> "2011-10-19T14:51:13Z"
    ] ;
    <http://purl.org/dc/terms/modified> [
        <http://purl.org/dc/terms/W3CDTF> "2012-04-20T19:52:45Z"
    ] .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000029>
    bqbiol:isVersionOf [
        rdf:_1 <http://identifiers.org/obo.chebi/CHEBI:16710> ;
        a rdf:Bag
    ] .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000030>
    bqbiol:isVersionOf [
        rdf:_1 <http://identifiers.org/obo.chebi/CHEBI:17050> ;
        a rdf:Bag
    ] .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000031>
    bqbiol:isVersionOf [
        rdf:_1 <http://identifiers.org/obo.chebi/CHEBI:16474> ;
        a rdf:Bag
    ] .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000032>
    bqbiol:isVersionOf [
        rdf:_1 <http://identifiers.org/obo.chebi/CHEBI:16526> ;
        a rdf:Bag
    ] .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000033>
    bqbiol:isVersionOf [
        rdf:_1 <http://identifiers.org/obo.chebi/CHEBI:15379> ;
        a rdf:Bag
    ] .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000034>
    bqbiol:isVersionOf [
        rdf:_1 <http://identifiers.org/obo.chebi/CHEBI:25523> ;
        a rdf:Bag
    ] .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000042>
    semsim:hasMediatorParticipant local:MediatorParticipant0000 ;
    semsim:hasSinkParticipant local:SinkParticipant0000 ;
    semsim:hasSourceParticipant local:SourceParticipant0000, local:SourceParticipant0001, local:SourceParticipant0002 .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000043>
    semsim:hasMediatorParticipant local:MediatorParticipant0001 ;
    semsim:hasSinkParticipant local:SinkParticipant0001 ;
    semsim:hasSourceParticipant local:SourceParticipant0003, local:SourceParticipant0004, local:SourceParticipant0005 .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000044>
    semsim:hasMediatorParticipant local:MediatorParticipant0002 ;
    semsim:hasSinkParticipant local:SinkParticipant0002 ;
    semsim:hasSourceParticipant local:SourceParticipant0006 .

<http://omex-library.org/NewOmex.omex/NewModel.xml#metaid_0000045>
    semsim:hasSinkParticipant local:SinkParticipant0003 ;
    semsim:hasSourceParticipant local:SourceParticipant0007 .
CiaranWelsh commented 3 years ago

Potential fix implemented in PR #57

CiaranWelsh commented 3 years ago

@jhgennari how are we looking on this? I'd like to integrate these changes soon. Cheers,

jhgennari commented 3 years ago

The 385 output looks good to me. So I think you can try to integrate changes. Will you make a new release? Or an alpha release of some kind?

CiaranWelsh commented 3 years ago

Merged