|
From: <tra...@us...> - 2016-07-26 05:32:43
|
Revision: 682
http://sourceforge.net/p/sbfc/code/682
Author: tramy-nguyen
Date: 2016-07-26 05:32:40 +0000 (Tue, 26 Jul 2016)
Log Message:
-----------
modified parsing of each pathway so it will create reactions, species, model, and compartments as valid sbml files.
Modified Paths:
--------------
trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java
trunk/test/org/sbfc/test/biopax2sbml/InteractionTests.java
trunk/test/org/sbfc/test/biopax2sbml/PhysicalEntityTests.java
trunk/test/org/sbfc/test/sbml2biopax/ReadingSBMLFileTests.java
Modified: trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java
===================================================================
--- trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java 2016-07-25 06:08:42 UTC (rev 681)
+++ trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java 2016-07-26 05:32:40 UTC (rev 682)
@@ -104,9 +104,11 @@
import org.sbml.jsbml.SpeciesReference;
import org.sbml.jsbml.UnitDefinition;
import org.sbml.jsbml.ext.comp.CompConstants;
+import org.sbml.jsbml.ext.comp.CompModelPlugin;
import org.sbml.jsbml.ext.comp.CompSBMLDocumentPlugin;
import org.sbml.jsbml.ext.comp.ExternalModelDefinition;
import org.sbml.jsbml.ext.comp.ModelDefinition;
+import org.sbml.jsbml.ext.comp.Submodel;
import org.sbml.jsbml.ext.qual.QualModelPlugin;
import org.sbml.jsbml.xml.XMLAttributes;
import org.sbml.jsbml.xml.XMLNamespaces;
@@ -145,7 +147,7 @@
//GO ontology obo file path
private final static String goOntology_filePath = "src/org/sbfc/ontology/go.obo";
-
+
private final static OboOntology ontology = new OboOntology(goOntology_filePath);
//The URL prefix for biopax RDFId
@@ -185,8 +187,8 @@
* @throws ReadModelException
*/
public SBMLModel sbmlExport(BioPAXModel biopaxmodel) throws SBMLException, ConversionException, ReadModelException {
-
-
+
+
//Keep track of the mapping between biopax RDFId to SBML id;
biopaxId2sbmlId = new HashMap<String, String>();
sbmlId2biopaxId = new HashMap<String, String>();
@@ -218,14 +220,36 @@
* first before parsing other biopax entities.
*/
org.sbml.jsbml.Model sbmlModel = parsePathways(bioModel, sbmlDoc);
- // addSBMLHistory(sbmlModel, sbmlOrganization);
- // addSBMLNotes(sbmlModel, "This model has been automatically generated by BioPAX2SBML");
+ addSBMLHistory(sbmlModel, sbmlOrganization);
+ addSBMLNotes(sbmlModel, "This model has been automatically generated by BioPAX2SBML");
//parseEntities(bioModel, sbmlModel);
+ validateSBMLFile(sbmlDoc);
return biopaxSBMLModel;
}
+ private void validateSBMLFile(SBMLDocument document)
+ {
+
+ String message = "Validation Problems Found by Webservice\n";
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.GENERAL_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.IDENTIFIER_CONSISTENCY, true);
+ // document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.OVERDETERMINED_MODEL, true);
+ // document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.UNITS_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.MATHML_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.SBO_CONSISTENCY, true);
+ // document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.MODELING_PRACTICE, true);
+ long numberOfErrors = document.checkConsistency();
+ for (int i = 0; i < numberOfErrors; i++)
+ {
+ String error = document.getError(i).getMessage();
+ message += i + ":" + error + "\n";
+ i++;
+ }
+ println(message);
+ }
+
private void mappAllEntities(org.biopax.paxtools.model.Model bioModel) throws ConversionException
{
for (Gene gene : bioModel.getObjects(Gene.class))
@@ -290,16 +314,16 @@
}
org.sbml.jsbml.Model topModel = sbmlDoc.createModel("topLevel_sbmlModel");
-
+
//TODO: add all species replacements and replacedby from toplevel_sbmlModel to submodels
CompSBMLDocumentPlugin compDoc = (CompSBMLDocumentPlugin) sbmlDoc.getPlugin(CompConstants.shortLabel);
-
+ CompModelPlugin compModel= (CompModelPlugin) sbmlDoc.getModel().getPlugin(CompConstants.shortLabel);
for(Pathway pathway : pathways)
{
org.sbml.jsbml.Model subModel = parsePathway(pathway, sbmlDoc);
- ModelDefinition modelDef = new ModelDefinition(subModel);
- compDoc.addModelDefinition(modelDef);
+ Submodel s = compModel.createSubmodel("submodel__"+subModel.getId());
+ s.setModelRef(subModel.getId());
}
return sbmlDoc.getModel();
}
@@ -328,6 +352,10 @@
{
if(entity instanceof Interaction)
{
+ if(entity instanceof Control)
+ {
+ continue;
+ }
if(mappedEntities.get(entity.getRDFId()) != null)
{
Reaction pathwayComponent = (Reaction) mappedEntities.get(entity.getRDFId());
@@ -338,7 +366,13 @@
if(sbmlModel.getSpecies(species.getId()) == null)
{
sbmlModel.addSpecies(species.clone());
+ Compartment compartment = (Compartment) getSBaseFromId(species.getCompartment());
+ if(sbmlModel.getCompartment(compartment.getId()) == null)
+ {
+ sbmlModel.addCompartment(compartment);
+ }
}
+
}
for(SpeciesReference reactant : pathwayComponent.getListOfReactants())
{
@@ -346,6 +380,11 @@
if(sbmlModel.getSpecies(species.getId()) == null)
{
sbmlModel.addSpecies(species.clone());
+ Compartment compartment = (Compartment) getSBaseFromId(species.getCompartment());
+ if(sbmlModel.getCompartment(compartment.getId()) == null)
+ {
+ sbmlModel.addCompartment(compartment);
+ }
}
}
for(SpeciesReference product : pathwayComponent.getListOfProducts())
@@ -354,6 +393,11 @@
if(sbmlModel.getSpecies(species.getId()) == null)
{
sbmlModel.addSpecies(species.clone());
+ Compartment compartment = (Compartment) getSBaseFromId(species.getCompartment());
+ if(sbmlModel.getCompartment(compartment.getId()) == null)
+ {
+ sbmlModel.addCompartment(compartment);
+ }
}
}
sbmlModel.addReaction(pathwayComponent.clone());
@@ -455,9 +499,9 @@
sbmlModel.setName(sbmlModelName);
}
- sbmlModel.setTimeUnits(UnitDefinition.TIME);
- sbmlModel.setVolumeUnits(UnitDefinition.VOLUME);
- sbmlModel.setSubstanceUnits(UnitDefinition.SUBSTANCE);
+ // sbmlModel.setTimeUnits(UnitDefinition.TIME);
+ // sbmlModel.setVolumeUnits(UnitDefinition.VOLUME);
+ // sbmlModel.setSubstanceUnits(UnitDefinition.SUBSTANCE);
return sbmlModel;
}
@@ -967,7 +1011,7 @@
sbmlSpecies.setHasOnlySubstanceUnits(true);
sbmlSpecies.setBoundaryCondition(false);
sbmlSpecies.setConstant(false);
-
+ sbmlSpecies.setInitialAmount(1);
if(entity.getXref() != null)
{
parseXref(entity.getXref(), sbmlSpecies);
@@ -1166,7 +1210,8 @@
String compartmentId = null;
if(cellLocId.contains("http://identifiers.org/"))
{
- compartmentId = parseCellularLocationURL(cellularLocVocab);
+ compartmentId = replaceInvalidSBMLcharId(parseCellularLocationURL(cellularLocVocab));
+
}
else
{
@@ -1221,13 +1266,13 @@
compartmentId = (cellLocId.length() > 10) ?
cellLocId.substring(cellLocId.length() - 10) : cellLocId;
- //check to see if cellularLocation is a URL and look up the term in identifiers.org and use its name
- if(cellLocId.contains("http://identifiers.org/go/"))
- {
- compartmentId = ontology.getTerm(compartmentId).getName().replaceAll(" ", "_");
- }
+ //check to see if cellularLocation is a URL and look up the term in identifiers.org and use its name
+ if(cellLocId.contains("http://identifiers.org/go/"))
+ {
+ compartmentId = ontology.getTerm(compartmentId).getName().replaceAll(" ", "_");
+ }
- return compartmentId;
+ return compartmentId;
}
private Compartment getDefaultCompartment(org.sbml.jsbml.Model sbmlModel)
@@ -1388,20 +1433,22 @@
private void parsePhysicalInteraction(Interaction entity) throws ConversionException
{
Reaction reaction = createReaction(entity);
- reaction.setReversible(false);
reaction.setFast(false);
if (entity instanceof TemplateReaction)
{
parseTemplateReaction((TemplateReaction) entity, reaction);
+ reaction.setReversible(false);
}
else if (entity instanceof MolecularInteraction)
{
parseMolecularInteraction((MolecularInteraction) entity, reaction);
+ reaction.setReversible(true);
}
else if (entity instanceof GeneticInteraction)
{
parseGeneticInteraction((GeneticInteraction) entity, reaction);
+ reaction.setReversible(true);
}
setInteraction_SBO(entity, reaction);
@@ -1565,7 +1612,21 @@
ListOf<SpeciesReference> products = getSpeciesReferences(conversion.getLeft(), conversion.getParticipantStoichiometry());
reaction.setListOfProducts(products);
}
+ else
+ {
+ //TODO: what happens when no direction is found? Assume reversible?
+ reaction.setReversible(true);
+ //Parse for reactant/substrate
+ ListOf<SpeciesReference> reactants = getSpeciesReferences(conversion.getLeft(), conversion.getParticipantStoichiometry());
+ reaction.setListOfReactants(reactants);
+
+ //Parse for product
+ ListOf<SpeciesReference> products = getSpeciesReferences(conversion.getRight(), conversion.getParticipantStoichiometry());
+ reaction.setListOfProducts(products);
+
+ }
+
setConversion_SBO(conversion, reaction);
}
@@ -1615,6 +1676,10 @@
for(Controller controller : controllerList)
{
ModifierSpeciesReference modifierSpecies = getModifierSpeciesReference(controller);
+ if(modifierSpecies == null)
+ {
+ continue;
+ }
modifierSpecies.setId(getValidSBMLId(control));
String modifierSpeciesName = getValidSBMLName(control);
if(modifierSpecies != null)
@@ -1648,7 +1713,9 @@
}
else
{
- throw new ConversionException("Unable to create a ModifierSpeciesReference with this entity: " + entity.getRDFId());
+ //throw new ConversionException("Unable to create a ModifierSpeciesReference with this entity: " + entity.getRDFId());
+ //TODO: if the entity is a pathway, TBD how to deal with it. maybe use annotations?
+ return null;
}
return modifierSpecies;
}
@@ -1795,7 +1862,8 @@
}
else
{
- throw new ConversionException("The reaction for " + process.getRDFId() + " must exist in the SBML Document in order to create a ModifierSpeciesReference for the Controlled interaction.");
+ //throw new ConversionException("The reaction for " + process.getRDFId() + " must exist in the SBML Document in order to create a ModifierSpeciesReference for the Controlled interaction.");
+ //TODO: if process is a pathway, then TBD how to determine. Maybe set as annotations?
}
}
Modified: trunk/test/org/sbfc/test/biopax2sbml/InteractionTests.java
===================================================================
--- trunk/test/org/sbfc/test/biopax2sbml/InteractionTests.java 2016-07-25 06:08:42 UTC (rev 681)
+++ trunk/test/org/sbfc/test/biopax2sbml/InteractionTests.java 2016-07-26 05:32:40 UTC (rev 682)
@@ -320,6 +320,32 @@
Reaction conversion = sbmlModel.getReaction("some_Conversion");
Assert.assertTrue(conversion.getSBOTerm() == SBO.getConversion());
}
+
+ private void validateSBMLFile(SBMLDocument document)
+ {
+
+ String message = "Validation Problems Found by Webservice\n";
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.GENERAL_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.IDENTIFIER_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.OVERDETERMINED_MODEL, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.UNITS_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.MATHML_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.SBO_CONSISTENCY, true);
+ document.setConsistencyChecks(org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY.MODELING_PRACTICE, true);
+ long numberOfErrors = document.checkConsistency();
+ for (int i = 0; i < numberOfErrors; i++)
+ {
+ String error = document.getError(i).getMessage();
+ message += i + ":" + error + "\n";
+ i++;
+ }
+ System.out.println(message);
+ }
+
+ @Test public void test_PathwayInteraction()
+ {
+
+ }
@Test public void test_InteractionReaction()
{
Modified: trunk/test/org/sbfc/test/biopax2sbml/PhysicalEntityTests.java
===================================================================
--- trunk/test/org/sbfc/test/biopax2sbml/PhysicalEntityTests.java 2016-07-25 06:08:42 UTC (rev 681)
+++ trunk/test/org/sbfc/test/biopax2sbml/PhysicalEntityTests.java 2016-07-26 05:32:40 UTC (rev 682)
@@ -82,7 +82,8 @@
/**
*
*/
- @BeforeClass public static void initialSetUp()
+ //@BeforeClass
+ public static void initialSetUp()
{
/*Creates the model Factory*/
BioPAXFactory biopaxFactory = BioPAXLevel.L3.getDefaultFactory();
@@ -479,7 +480,7 @@
SBMLModel sbfcSBMLModel = InteractionTests.read_biopaxFile(owlFile);
org.sbml.jsbml.Model sbmlModel = sbfcSBMLModel.getModel();
-
+// InteractionTests.printSBMLModel(sbfcSBMLModel);
Assert.assertTrue(sbmlModel.getNumSpecies() == 5);
Species protein = sbmlModel.getSpecies("Protein_5");
@@ -562,8 +563,6 @@
SBMLModel sbfcSBMLModel = InteractionTests.read_biopaxFile(owlFile);
org.sbml.jsbml.Model sbmlModel = sbfcSBMLModel.getModel();
- InteractionTests.printSBMLModel(sbfcSBMLModel);
-
Species dna = sbmlModel.getSpecies("Dna_a5ec6c1f6963079541d8d9290eb25948");
Assert.assertTrue(dna.getId().equals("Dna_a5ec6c1f6963079541d8d9290eb25948"));
Assert.assertTrue(dna.getName().equals("HMGCS1 gene"));
@@ -888,4 +887,13 @@
}
+
+ @Test
+ public void testFile()
+ {
+ String owlFile = InteractionTests.fileDirectory + "AKT_Signaling_Pathway.owl";
+ SBMLModel sbfcSBMLModel = InteractionTests.read_biopaxFile(owlFile);
+ InteractionTests.printSBMLModel(sbfcSBMLModel);
+ }
+
}
Modified: trunk/test/org/sbfc/test/sbml2biopax/ReadingSBMLFileTests.java
===================================================================
--- trunk/test/org/sbfc/test/sbml2biopax/ReadingSBMLFileTests.java 2016-07-25 06:08:42 UTC (rev 681)
+++ trunk/test/org/sbfc/test/sbml2biopax/ReadingSBMLFileTests.java 2016-07-26 05:32:40 UTC (rev 682)
@@ -9,6 +9,7 @@
import org.biopax.paxtools.model.level3.Interaction;
import org.biopax.paxtools.model.level3.Pathway;
import org.biopax.paxtools.model.level3.PhysicalEntity;
+import org.biopax.paxtools.model.level3.Protein;
import org.biopax.paxtools.model.level3.PublicationXref;
import org.biopax.paxtools.model.level3.UnificationXref;
import org.biopax.paxtools.model.level3.Xref;
@@ -226,7 +227,29 @@
@Test public void test_ProteinFile()
{
- String xmlFile = fileDirectory + "biopax3-phosphorylation-reaction.xmls";
+ String xmlFile = fileDirectory + "biopax3-phosphorylation-reaction.xml";
+ org.biopax.paxtools.model.Model bioModel = readSBMLFiles(xmlFile);
+ printBioPAXModel(bioModel);
+ Assert.assertTrue(bioModel.getObjects(Protein.class).size() == 3);
+ for (Protein protein : bioModel.getObjects(Protein.class))
+ {
+ if(protein.getRDFId().equals(XMLBase + "Protein_5"))
+ {
+ Assert.assertTrue(protein.getDisplayName().equals("CHK2"));
+ }
+ else if(protein.getRDFId().equals(XMLBase + "Protein_16"))
+ {
+ Assert.assertTrue(protein.getDisplayName().equals("CHK2"));
+ }
+ else if(protein.getRDFId().equals(XMLBase + "Protein_27"))
+ {
+ Assert.assertTrue(protein.getDisplayName().equals("ATM"));
+ }
+ else
+ {
+ Assert.assertTrue(false);
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|