|
From: <nik...@us...> - 2016-06-09 13:14:15
|
Revision: 640
http://sourceforge.net/p/sbfc/code/640
Author: niko-rodrigue
Date: 2016-06-09 13:14:12 +0000 (Thu, 09 Jun 2016)
Log Message:
-----------
Added a test class for Arman SBML2BioPAX code, mainly to see how the generated BioPAX look like.
Modified Paths:
--------------
trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java
trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesTests.java
Added Paths:
-----------
trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesArmanTests.java
Modified: trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java
===================================================================
--- trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java 2016-06-07 14:56:42 UTC (rev 639)
+++ trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java 2016-06-09 13:14:12 UTC (rev 640)
@@ -38,6 +38,10 @@
import org.biopax.paxtools.model.level3.UnificationXref;
import org.biopax.paxtools.model.level3.XReferrable;
import org.biopax.paxtools.model.level3.Xref;
+import org.identifiers.registry.RegistryDatabase;
+import org.identifiers.registry.RegistryLocalProvider;
+import org.identifiers.registry.RegistryUtilities;
+import org.identifiers.registry.data.DataType;
import org.sbml.jsbml.AbstractNamedSBase;
import org.sbml.jsbml.AbstractSBase;
import org.sbml.jsbml.Annotation;
@@ -180,29 +184,22 @@
}
private <T extends Xref> T resourceToXref(Class<T> xrefClass, String xrefId, String resource) {
- // Sample miriam resource: urn:miriam:chebi:CHEBI%3A15589
+ // using the miriam common library to get the id and database String regardless of the form of the URI.
- // TODO - the miriam common library could be used to get the id and database String regardless of the form of the URI.
-
- String[] tokens = resource.split(":");
T xref = bioPAXFactory.create(xrefClass, xrefId);
- // biomodels.db -> biomodels; ec-code -> ec code
- String dataBase = tokens[2]
- .replace(".", " ")
- .replace("-", " ")
- .replace(" db", " database")
- .replace("obo ", "")
- ;
- xref.setDb(dataBase);
- String idToken = tokens[3];
- try {
- URI uri = new URI(idToken);
- xref.setId(uri.getPath());
- } catch (URISyntaxException e) {
- log.warn("Problem parsing the URI, " + idToken + ":" + e.getLocalizedMessage());
- xref.setId(idToken);
+ String idToken = RegistryUtilities.getElementPart(resource);
+ String dataBase = RegistryUtilities.getDataPart(resource);
+ DataType datatype = RegistryUtilities.getDataType(dataBase);
+
+ if (datatype != null) {
+ dataBase = datatype.getName();
+ } else {
+ log.warn("Cannnot get Datatype for: " + resource);
}
+ xref.setDb(dataBase);
+ xref.setId(idToken);
+
return xref;
}
Added: trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesArmanTests.java
===================================================================
--- trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesArmanTests.java (rev 0)
+++ trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesArmanTests.java 2016-06-09 13:14:12 UTC (rev 640)
@@ -0,0 +1,268 @@
+package org.sbfc.test.sbml2biopax;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.biopax.paxtools.model.BioPAXElement;
+import org.biopax.paxtools.model.level3.Complex;
+import org.biopax.paxtools.model.level3.PhysicalEntity;
+import org.biopax.paxtools.model.level3.SmallMolecule;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.sbfc.converter.exceptions.ConversionException;
+import org.sbfc.converter.exceptions.ReadModelException;
+import org.sbfc.converter.exceptions.WriteModelException;
+import org.sbfc.converter.models.BioPAXModel;
+import org.sbfc.converter.models.SBMLModel;
+import org.sbfc.converter.sbml2biopax.SBML2BioPAX_Arman;
+import org.sbml.jsbml.CVTerm;
+import org.sbml.jsbml.Model;
+import org.sbml.jsbml.Reaction;
+import org.sbml.jsbml.SBMLDocument;
+import org.sbml.jsbml.Species;
+
+/**
+ * Tests to check the conversion of an SBML species into a BioPAX PhysicalEntity, making sure that any information
+ * that is possible to keep is kept properly.
+ *
+ * @author rodrigue
+ *
+ */
+public class SBMLSpeciesArmanTests {
+
+ /**
+ * SBMLDocument used as a starting point in the tests
+ */
+ static private SBMLDocument doc;
+
+ /**
+ * BioPAX Model holding the result of the conversion
+ */
+ static private org.biopax.paxtools.model.Model biopaxModel;
+
+ /**
+ *
+ */
+ @BeforeClass public static void initialSetUp()
+ {
+ doc = new SBMLDocument(3, 1);
+
+ Model m = doc.createModel("sbml2physicalEntitytest");
+ m.setName("sbml2physicalEntity test");
+
+ m.createCompartment("cell");
+ m.createCompartment("extra_cellular");
+
+ // SmallMolecule => child of SBO 247 (327) or has a chebi or a kegg.compound annotation
+ Species s1 = m.createSpecies("S1");
+ s1.setSBOTerm(247);
+ s1.setName("SmallMolecule");
+ s1.setCompartment("cell"); // All other SBML species attributes are ignored at the moment.
+
+ Species s2 = m.createSpecies("S2");
+ s2.setSBOTerm(327);
+ s2.setName("SmallMolecule");
+ s2.setCompartment("extra_cellular");
+
+ Species s3 = m.createSpecies("S3");
+ s3.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "http://identifiers.org/chebi/CHEBI:15377"));
+ s3.setName("SmallMolecule");
+ s3.setCompartment("cell");
+ try {
+ s3.appendNotes("Adding a small notes to this species"); // The SBML Notes should be somehow stored in the BioPAX comment element.
+ s3.appendNotes("Chebi: CHEBI:15377");
+ s3.appendNotes("Definition: An oxygen hydride consisting of an oxygen atom that is covalently bonded to two hydrogen atoms.");
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+
+ // no need to always test different deprecated URI but we should at least test a few.
+ Species s4 = m.createSpecies("S4");
+ s4.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:obo.chebi:CHEBI%3A23436"));
+ s4.setName("SmallMolecule");
+ s4.setCompartment("cell");
+
+ Species s5 = m.createSpecies("S5");
+ s5.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "http://purl.obolibrary.org/obo/CHEBI#CHEBI:8116"));
+ s5.setName("SmallMolecule");
+ s5.setCompartment("cell");
+
+ Species s6 = m.createSpecies("S6");
+ s6.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "http://identifiers.org/kegg.compound/C00001"));
+ s6.setName("SmallMolecule");
+ s6.setCompartment("cell");
+
+
+ // Complex => has an intact annotation or child of SBO 253 (296, 286)
+ Species s7 = m.createSpecies("S7");
+ s7.setName("Complex");
+ s7.setSBOTerm(253);
+ s7.setCompartment("cell");
+
+ Species s8 = m.createSpecies("S8");
+ s8.setName("Complex");
+ s8.setSBOTerm(296);
+ s8.setCompartment("cell");
+
+ Species s9 = m.createSpecies("S9");
+ s9.setName("Complex");
+ s9.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "http://identifiers.org/intact/EBI-9691559"));
+ s9.setCompartment("cell");
+
+
+ // TODO - Protein child of SBO 297 or has annotation to uniprot, urn:miriam:kegg.compound:C00173, interpro, ensembl:ENSRNOP*, ensembl:ENSP*
+ Species s10 = m.createSpecies("S10");
+ s10.setName("Protein");
+ s10.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "http://identifiers.org/uniprot/P04156"));
+ s10.setCompartment("cell");
+
+
+
+ // TODO - DNA chebi:CHEBI%3A9160, ensembl:ENSG*, ensembl:ENSRNOG*, kegg.compound:C00039, child of SBO 251?
+
+
+
+ // TODO - RNA chebi:CHEBI%3A33699, chebi:CHEBI%3A17843, ensembl:ENSRNOT*, ensembl:ENST*, kegg.compound:C00731, RNA=SBO 250 (also child of SBO 404?)
+
+
+
+ // TODO - test (DnaRegion?, RnaRegion?)
+
+
+
+ // Gene=243
+
+ // Reactions
+ Reaction r1 = m.createReaction();
+ r1.createReactant(s1);
+ r1.createReactant(s2);
+ r1.createReactant(s3);
+ r1.createReactant(s4);
+ r1.createReactant(s5);
+ r1.createReactant(s6);
+
+ r1.createProduct(s7);
+ r1.createProduct(s8);
+ r1.createProduct(s9);
+ r1.createProduct(s10);
+
+ try {
+
+ SBMLModel sbfcSBMLModel = new SBMLModel(doc);
+ SBML2BioPAX_Arman sbml2biopax = new SBML2BioPAX_Arman();
+ BioPAXModel sbfcBiopaxModel = (BioPAXModel) sbml2biopax.convert(sbfcSBMLModel);
+
+ biopaxModel = sbfcBiopaxModel.getModel();
+
+ // Uncomment to see the content of the SBML and the BioPAX file as XML
+ System.out.println("SBML model encoded as XML:\n " + sbfcSBMLModel.modelToString() + "\n\n");
+ System.out.println("BioPAX model encoded as OWL/XML:\n " + sbfcBiopaxModel.modelToString() + "\n\n");
+ } catch (WriteModelException e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ } catch (ConversionException e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ } catch (ReadModelException e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+
+ }
+
+ /**
+ *
+ */
+ @Before public void setUp() {
+
+
+ }
+
+ /**
+ *
+ */
+ @Test public void smallMoleculeTest()
+ {
+ // Because 'xml:base="http://www.humanmetabolism.org/#' is added to the Biopax file, on the top level RDF element,
+ // all RDF:ID need to have this string as base.
+ String idBase = "http://www.humanmetabolism.org/#";
+
+ BioPAXElement elem = biopaxModel.getByID(idBase + "S1");
+
+ System.out.println("BioPAX Model contains an element with id 'S1' = " + biopaxModel.containsID(idBase + "S1") + ", "
+ + (elem != null ? elem.getClass().getSimpleName() : " element 'S1' not found!"));
+
+ assertTrue("The SBO ID 247 should be a biopax SmallMolecule", elem instanceof SmallMolecule);
+
+ PhysicalEntity pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "SmallMolecule");
+
+ elem = biopaxModel.getByID(idBase + "S7");
+
+ assertTrue("SBO ID 253 should be a biopax Complex", elem instanceof Complex);
+
+ pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "Complex");
+
+ elem = biopaxModel.getByID(idBase + "S2");
+
+ assertTrue("Any child of the SBO ID 247 should be a biopax SmallMolecule", elem instanceof SmallMolecule);
+
+ pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "SmallMolecule");
+
+ elem = biopaxModel.getByID(idBase + "S8");
+
+ assertTrue("Any child of the SBO ID 253 should be a biopax Complex", elem instanceof Complex);
+
+ pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "Complex");
+
+
+ // putting those tests at the end as we know that the current converter does not make use of SBO at the moment // TODO - remove this comment when the tests pass !
+
+
+ elem = biopaxModel.getByID(idBase + "S3");
+
+ assertTrue("Most Chebi annotations should be a biopax SmallMolecule", elem instanceof SmallMolecule);
+
+ pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "SmallMolecule");
+
+ // TODO - Once it is implemented test that the proper EntityReference are created and that the annotation are attached there
+ // For example, here we should have a SmallMoleculeReference element where a UnificationXRef is attached
+
+ elem = biopaxModel.getByID(idBase + "S4");
+
+ assertTrue("Most Chebi annotations should be a biopax SmallMolecule", elem instanceof SmallMolecule);
+
+ pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "SmallMolecule");
+
+ elem = biopaxModel.getByID(idBase + "S5");
+
+ assertTrue("Most Chebi annotations should be a biopax SmallMolecule", elem instanceof SmallMolecule);
+
+ pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "SmallMolecule");
+
+ elem = biopaxModel.getByID(idBase + "S9");
+
+ assertTrue("Intact annotations should be a biopax Complex", elem instanceof Complex);
+
+ pEntity = (PhysicalEntity) elem;
+ assertTrue(pEntity.getDisplayName() == "Complex");
+
+
+
+
+
+
+ }
+
+}
Property changes on: trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesArmanTests.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesTests.java
===================================================================
--- trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesTests.java 2016-06-07 14:56:42 UTC (rev 639)
+++ trunk/test/org/sbfc/test/sbml2biopax/SBMLSpeciesTests.java 2016-06-09 13:14:12 UTC (rev 640)
@@ -99,7 +99,7 @@
Species s8 = m.createSpecies("S8");
s8.setName("Complex");
- s7.setSBOTerm(296);
+ s8.setSBOTerm(296);
Species s9 = m.createSpecies("S9");
s9.setName("Complex");
@@ -166,7 +166,8 @@
assertTrue(pEntity.getDisplayName() == "SmallMolecule");
// TODO - Once it is implemented test that the proper EntityReference are created and that the annotation are attached there
- // For example, here we should have an SmallMoleculeReference element where a UnificationXRef is attached
+ // For example, here we should have a SmallMoleculeReference element where a UnificationXRef is attached
+ // And the SmallMoleculeReference need to have as RDF:ID, the identifiers.org URI is available
elem = biopaxModel.getByID("S4");
@@ -210,14 +211,14 @@
elem = biopaxModel.getByID("S7");
- assertTrue("Intact annotations should be a biopax Complex", elem instanceof Complex);
+ assertTrue("The SBO ID 253 should be a biopax Complex", elem instanceof Complex);
pEntity = (PhysicalEntity) elem;
assertTrue(pEntity.getDisplayName() == "Complex");
elem = biopaxModel.getByID("S8");
- assertTrue("Intact annotations should be a biopax Complex", elem instanceof Complex);
+ assertTrue("Any child of the SBO ID 253 should be a biopax Complex", elem instanceof Complex);
pEntity = (PhysicalEntity) elem;
assertTrue(pEntity.getDisplayName() == "Complex");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|