|
From: <tra...@us...> - 2016-07-27 06:36:57
|
Revision: 684
http://sourceforge.net/p/sbfc/code/684
Author: tramy-nguyen
Date: 2016-07-27 06:36:54 +0000 (Wed, 27 Jul 2016)
Log Message:
-----------
- add validation to sbml document to only print errors rather than warnings.
- Implemented replacements from top level sbml model to sbml submodels for all species and reactions.
Modified Paths:
--------------
trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java
Modified: trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java
===================================================================
--- trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java 2016-07-26 13:52:08 UTC (rev 683)
+++ trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java 2016-07-27 06:36:54 UTC (rev 684)
@@ -97,6 +97,9 @@
import org.sbml.jsbml.ModifierSpeciesReference;
import org.sbml.jsbml.Reaction;
import org.sbml.jsbml.SBMLDocument;
+import org.sbml.jsbml.SBMLError;
+import org.sbml.jsbml.SBMLError.SEVERITY;
+import org.sbml.jsbml.SBMLErrorLog;
import org.sbml.jsbml.SBMLException;
import org.sbml.jsbml.SBO;
import org.sbml.jsbml.SBase;
@@ -106,8 +109,10 @@
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.CompSBasePlugin;
import org.sbml.jsbml.ext.comp.ExternalModelDefinition;
import org.sbml.jsbml.ext.comp.ModelDefinition;
+import org.sbml.jsbml.ext.comp.ReplacedElement;
import org.sbml.jsbml.ext.comp.Submodel;
import org.sbml.jsbml.ext.qual.QualModelPlugin;
import org.sbml.jsbml.xml.XMLAttributes;
@@ -139,7 +144,9 @@
private Map<String, String> biopaxId2sbmlId;
private Map<String, String> sbmlId2biopaxId;
- //map biopax entity RDFId to the sbml sbase object
+ /**
+ * map biopax entity RDFId to the sbml sbase object
+ */
private Map<String, SBase> mappedEntities;
//Counter for creating new SBML id
@@ -223,7 +230,7 @@
addSBMLHistory(sbmlModel, sbmlOrganization);
addSBMLNotes(sbmlModel, "This model has been automatically generated by BioPAX2SBML");
- //parseEntities(bioModel, sbmlModel);
+ //TODO: throw conversionException if invalid sbml file?
validateSBMLFile(sbmlDoc);
return biopaxSBMLModel;
@@ -231,7 +238,6 @@
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);
@@ -247,7 +253,12 @@
message += i + ":" + error + "\n";
i++;
}
- println(message);
+ SBMLErrorLog errorLogs = document.getErrorLog();
+ List<SBMLError> errors = errorLogs.getErrorsBySeverity(SEVERITY.ERROR);
+ for(SBMLError error : errors)
+ {
+ println(error.getMessage());
+ }
}
private void mappAllEntities(org.biopax.paxtools.model.Model bioModel) throws ConversionException
@@ -263,6 +274,7 @@
if(physicalEntity instanceof SimplePhysicalEntity)
{
/*
+ * Note:
* entityReference is annotated in sbml.
* This field is only found in Protein, Dna, DnaRegion, Rna, RnaRegion, and SmallMolecule
*/
@@ -294,8 +306,8 @@
}
/**
- * Convert a list of biopax pathways to its equivalent SBML Model. Each pathway model that gets created, will be represented in its own SBML file.
- * If there are no pathway found within the biopax model, then a default pathway will be created.
+ * Convert a list of biopax pathways to its equivalent SBML Model. Each pathway model that gets created, will be represented in its own submodel.
+ * If there are no pathway found within the biopax model, then a default pathway will be created and all entities within the biomodel will be parsed into the sbml document.
*
* @param bioModel - The biopax model that contains a set of pathways to convert to sbml models
* @param sbmlDoc - the top level sbml document that will store all the references of the sbml submodels that were converted from each biopax pathways.
@@ -314,17 +326,119 @@
}
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);
+
+ //Create a comp model to attach all sbml submodel to the sbml document
CompModelPlugin compModel= (CompModelPlugin) sbmlDoc.getModel().getPlugin(CompConstants.shortLabel);
+
for(Pathway pathway : pathways)
{
org.sbml.jsbml.Model subModel = parsePathway(pathway, sbmlDoc);
- Submodel s = compModel.createSubmodel("submodel__"+subModel.getId());
+ Submodel s = compModel.createSubmodel("submodel__" + subModel.getId());
s.setModelRef(subModel.getId());
}
+ //Add all species replacements and replacedby from submodels to toplevel_sbmlModel
+ for(PhysicalEntity physicalEntity : bioModel.getObjects(PhysicalEntity.class))
+ {
+ Species species = (Species) mappedEntities.get(physicalEntity.getRDFId());
+ //Keep track of how many times this species occur in the each submodel
+ int count = 0;
+ for(Submodel modelDef : compModel.getListOfSubmodels())
+ {
+ if(modelDef.getModel().getSpecies(species.getId()) != null)
+ {
+ count++;
+ }
+ }
+ if(count == 0)
+ {
+ /*
+ * Note:
+ * This physicalEntity did not occur anywhere in all submodels.
+ * Add this converted species to the top level sbml model
+ */
+ topModel.addSpecies(species);
+ topModel.addCompartment((Compartment) getSBaseFromSBMLId(species.getCompartment()));
+ }
+ else if(count == 1)
+ {
+ /*
+ * Note:
+ * This physicalEntity occured in one submodel.
+ * This indicates that it is a "floating" species in that one submodel.
+ * Don't add this converted species to the top level sbml model
+ */
+ continue;
+ }
+ else
+ {
+ topModel.addSpecies(species);
+ topModel.addCompartment((Compartment) getSBaseFromSBMLId(species.getCompartment()));
+ for(Submodel modelDef : compModel.getListOfSubmodels())
+ {
+ Species submodel_species = modelDef.getModel().getSpecies(species.getId());
+ if(submodel_species != null)
+ {
+ CompSBasePlugin replacementPlugin = (CompSBasePlugin) species.getPlugin(CompConstants.shortLabel);
+ ReplacedElement replacement = replacementPlugin.createReplacedElement();
+ replacement.setIdRef(submodel_species.getId());
+ replacement.setSubmodelRef(modelDef.getId());
+ }
+ }
+ }
+ }
+ for(Interaction interactionEntity : bioModel.getObjects(Interaction.class))
+ {
+ if(interactionEntity instanceof Control)
+ {
+ continue;
+ }
+ Reaction reaction = (Reaction) mappedEntities.get(interactionEntity.getRDFId());
+ //Keep track of how many times this reaction occur in the each submodel
+ int count = 0;
+ for(Submodel modelDef : compModel.getListOfSubmodels())
+ {
+ if(modelDef.getModel().getReaction(reaction.getId()) != null)
+ {
+ count++;
+ }
+ }
+ if(count == 0)
+ {
+ /*
+ * Note:
+ * This interactionEntity did not occur anywhere in all submodels.
+ * Add this converted reaction to the top level sbml model
+ */
+ topModel.addReaction(reaction);
+
+ }
+ else if(count == 1)
+ {
+ /*
+ * Note:
+ * This interactionEntity occurred in one submodel.
+ * This indicates that it is a "floating" reaction in that one submodel.
+ * Don't add this converted reaction to the top level sbml model
+ */
+ continue;
+ }
+ else
+ {
+ topModel.addReaction(reaction);
+ for(Submodel modelDef : compModel.getListOfSubmodels())
+ {
+ Reaction submodel_reaction = modelDef.getModel().getReaction(reaction.getId());
+ if(submodel_reaction != null)
+ {
+ CompSBasePlugin replacementPlugin = (CompSBasePlugin) reaction.getPlugin(CompConstants.shortLabel);
+ ReplacedElement replacement = replacementPlugin.createReplacedElement();
+ replacement.setIdRef(submodel_reaction.getId());
+ replacement.setSubmodelRef(modelDef.getId());
+ }
+ }
+ }
+ }
+
return sbmlDoc.getModel();
}
@@ -346,73 +460,12 @@
if(pathway.getPathwayComponent() != null && pathway.getPathwayComponent().size() > 0)
{
//Parse all entities related to this pathway
- Set<org.biopax.paxtools.model.level3.Process> entityList = pathway.getPathwayComponent();
-
- for(Entity entity : entityList)
- {
- if(entity instanceof Interaction)
- {
- if(entity instanceof Control)
- {
- continue;
- }
- if(mappedEntities.get(entity.getRDFId()) != null)
- {
- Reaction pathwayComponent = (Reaction) mappedEntities.get(entity.getRDFId());
- //TODO: How to get species object from mappedEntities for reactant, product, and modifiers?
- for(ModifierSpeciesReference modifier : pathwayComponent.getListOfModifiers())
- {
- Species species = (Species) getSBaseFromId(modifier.getSpecies());
- 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())
- {
- Species species = (Species) getSBaseFromId(reactant.getSpecies());
- 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())
- {
- Species species = (Species) getSBaseFromId(product.getSpecies());
- 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());
- }
- else
- {
- throw new ConversionException("Unable to locate entity: " + entity.getRDFId() + " from the provided biopax file");
- }
- }
- else if(entity instanceof Pathway)
- {
- //TODO: how to handle this?
- }
- }
+ parsePathwayComponent(pathway.getPathwayComponent(), sbmlModel);
}
+ if(pathway.getPathwayOrder() != null && pathway.getPathwayOrder().size() > 0)
+ {
+ parsePathwayStep(pathway.getPathwayOrder(), sbmlModel);
+ }
//Add SBML annotation for biopax pathway
if(pathway.getXref() != null && !pathway.getXref().isEmpty())
@@ -420,8 +473,9 @@
parseXref(pathway.getXref(), sbmlModel);
}
}
- else
+ else
{
+ //Pathway is empty in biopax file. Consider all entities within file as one model
for(SBase sbase : mappedEntities.values())
{
if(sbase instanceof Species)
@@ -441,10 +495,106 @@
return sbmlModel;
}
+
+ private void parsePathwayComponent(Set<org.biopax.paxtools.model.level3.Process> entityList, org.sbml.jsbml.Model sbmlModel) throws ConversionException
+ {
+ for(Entity entity : entityList)
+ {
+ if(entity instanceof Interaction)
+ {
+ /*
+ * Note:
+ * Since all Control are translated into modifiers, reactants, and products that are attached to a reaction,
+ * no need to parse control entities but rather only the interactions since control entities will already be parsed
+ * when parsing interactions.
+ */
+ if(entity instanceof Control)
+ {
+ continue;
+ }
+ if(mappedEntities.get(entity.getRDFId()) != null)
+ {
+ Reaction pathwayComponent = (Reaction) mappedEntities.get(entity.getRDFId());
+
+ for(ModifierSpeciesReference modifier : pathwayComponent.getListOfModifiers())
+ {
+ Species species = (Species) getSBaseFromSBMLId(modifier.getSpecies());
+ if(sbmlModel.getSpecies(species.getId()) == null)
+ {
+ sbmlModel.addSpecies(species.clone());
+ Compartment compartment = (Compartment) getSBaseFromSBMLId(species.getCompartment());
+ if(sbmlModel.getCompartment(compartment.getId()) == null)
+ {
+ sbmlModel.addCompartment(compartment);
+ }
+ }
+ }
+ for(SpeciesReference reactant : pathwayComponent.getListOfReactants())
+ {
+ Species species = (Species) getSBaseFromSBMLId(reactant.getSpecies());
+ if(sbmlModel.getSpecies(species.getId()) == null)
+ {
+ sbmlModel.addSpecies(species.clone());
+ Compartment compartment = (Compartment) getSBaseFromSBMLId(species.getCompartment());
+ if(sbmlModel.getCompartment(compartment.getId()) == null)
+ {
+ sbmlModel.addCompartment(compartment);
+ }
+ }
+ }
+ for(SpeciesReference product : pathwayComponent.getListOfProducts())
+ {
+ Species species = (Species) getSBaseFromSBMLId(product.getSpecies());
+ if(sbmlModel.getSpecies(species.getId()) == null)
+ {
+ sbmlModel.addSpecies(species.clone());
+ Compartment compartment = (Compartment) getSBaseFromSBMLId(species.getCompartment());
+ if(sbmlModel.getCompartment(compartment.getId()) == null)
+ {
+ sbmlModel.addCompartment(compartment);
+ }
+ }
+ }
+ sbmlModel.addReaction(pathwayComponent.clone());
+ }
+ else
+ {
+ throw new ConversionException("Unable to locate entity: " + entity.getRDFId() + " from the provided biopax file");
+ }
+ }
+ else if(entity instanceof Pathway)
+ {
+ //TODO: how to handle this?
+ }
+ }
+ }
+ private void parsePathwayStep(Set<PathwayStep> pathwayStepList, org.sbml.jsbml.Model sbmlModel) throws ConversionException
+ {
+ for(PathwayStep pathwayStep : pathwayStepList)
+ {
+ if(pathwayStep.getStepProcess() != null && pathwayStep.getStepProcess().size() > 0)
+ {
+ parsePathwayComponent(pathwayStep.getStepProcess(), sbmlModel);
+ }
+
+ if(pathwayStep.getNextStep() != null && pathwayStep.getNextStep().size() > 0)
+ {
+ parsePathwayStep(pathwayStep.getNextStep(), sbmlModel);
+ }
+ }
+ }
- private SBase getSBaseFromId(String id) throws ConversionException
+ /**
+ * Returns the SBase object based on the SBML id.
+ * If an SBase object can't be found based from the given id, then this method will throw a ConversionException.
+ *
+ * @param id - The SBase object id
+ * @return The SBase object
+ * @throws ConversionException
+ */
+ private SBase getSBaseFromSBMLId(String id) throws ConversionException
{
if(sbmlId2biopaxId.containsKey(id))
{
@@ -542,57 +692,6 @@
}
}
- /**
- * Takes the provided biomodel and converts all entities within the model to its corresponding SBML elements
- * The SBML elements are stored within the provided SBML model.
- *
- * @param bioModel - The biomodel to get all the entities from
- * @param sbmlModel - the SBML model to store all the SBML elements that are generated from the provided biomodel
- * @throws ConversionException
- */
- private void parseEntities(Model bioModel, org.sbml.jsbml.Model sbmlModel) throws ConversionException
- {
- for (Gene gene : bioModel.getObjects(Gene.class))
- {
- parseEntity(gene, sbmlModel);
- }
- for (PhysicalEntity physicalEntity : bioModel.getObjects(PhysicalEntity.class))
- {
- parseEntity(physicalEntity, sbmlModel);
- if(physicalEntity instanceof SimplePhysicalEntity)
- {
- /*
- * entityReference is annotated in sbml.
- * This field is only found in Protein, Dna, DnaRegion, Rna, RnaRegion, and SmallMolecule
- */
- SimplePhysicalEntity simplePhysicalEntity = (SimplePhysicalEntity) physicalEntity;
- if(simplePhysicalEntity.getEntityReference() != null)
- {
- //TODO: Implement EntityReference as SBML annotations by using SBML group
- //parseEntityReference(simplePhysicalEntity.getEntityReference(), species);
- }
- }
- }
-
- /*
- * Note: Collect all biopax interaction types to parse after iterating through all entities.
- * This will ensure that species are created first from PhysicalEntities and any Entites that
- * are not of type Interaction.
- */
-
- Set<Conversion> listOfConversions = bioModel.getObjects(Conversion.class);
-
- Set<Control> listOfControls = bioModel.getObjects(Control.class);
-
- List<Interaction> listOfInteractions = new ArrayList<Interaction>();
- listOfInteractions.addAll(bioModel.getObjects(GeneticInteraction.class));
- listOfInteractions.addAll(bioModel.getObjects(MolecularInteraction.class));
- listOfInteractions.addAll(bioModel.getObjects(TemplateReaction.class));
-
- parseInteractions(sbmlModel, listOfConversions, listOfControls, listOfInteractions);
- }
-
-
private String parseXref(Set<Xref> xrefList, SBase sbase)
{
List<CVTerm> cvtermList = new ArrayList<CVTerm>();
@@ -726,31 +825,6 @@
return cvterm;
}
- /**
- * Convert the provided Biopax entity to an SBML species.
- * The species generated will be stored in the provided SBML model.
- *
- * @param entity - The biopax entity to be converted to its corresponding species
- * @param sbmlModel - The SBML model to store the generated SBML elements
- * @return
- */
- private Species parseEntity(Entity entity, org.sbml.jsbml.Model sbmlModel)
- {
- Species sbmlSpecies = setSpecies(sbmlModel, entity);
-
- //Add SBO terms to species
- if (entity instanceof PhysicalEntity)
- {
- setPhysicalEntity_SBO((PhysicalEntity) entity, sbmlSpecies);
- }
- else
- {
- setEntity_SBO(entity, sbmlSpecies);
- }
-
- return sbmlSpecies;
- }
-
private Species parseEntity(Entity entity)
{
Species sbmlSpecies = createSpecies(entity);
@@ -934,56 +1008,7 @@
return result;
}
- /**
- * Convert the provided biopax entity into SBML species. The generated SBML species will be
- * stored within the provided SBML model. For the species that was created, it is assigned to its
- * corresponding SBML compartments based on the cellularLocaton retrieved form the given entity.
- *
- * @param sbmlModel - The SBML model to store the generated SBML species
- * @param speciesId - The id for the generated SBML species
- * @param entity - The biopax entity to convert to an SBML species.
- * @return The species created from the given entity
- */
- private Species setSpecies(org.sbml.jsbml.Model sbmlModel, Entity entity)
- {
- String speciesId = getValidSBMLId(entity);
- Species sbmlSpecies = sbmlModel.createSpecies(speciesId, createCompartment(sbmlModel, entity));
- //Since name is optional in SBML, don't set sbml name if getValidSBMLName returns null
- String speciesName = getValidSBMLName(entity);
- if(speciesName != null)
- {
- sbmlSpecies.setName(speciesName);
- }
-
- /* Default settings for sbml species required attributes
- * setHasOnlySubstanceUnits(true) :
- * Specify if species is an amount or a concentration.
- * Consider the species to be amount so true is set.
- * setBoundaryCondition(false) :
- * Specify if species will change depending on result of condition.
- * Assume that the species will never change so false is set
- * setConstant(false) :
- * Specify if species ever change.
- * Assume species is usually never change, true is set
- */
- sbmlSpecies.setHasOnlySubstanceUnits(true);
- sbmlSpecies.setBoundaryCondition(false);
- sbmlSpecies.setConstant(false);
-
- if(entity.getEvidence() != null)
- {
- //parseEvidence(entity.getEvidence(), sbmlSpecies);
- }
- if(entity.getXref() != null)
- {
- parseXref(entity.getXref(), sbmlSpecies);
-
- }
-
- return sbmlSpecies;
- }
-
private Species createSpecies(Entity entity)
{
String speciesId = getValidSBMLId(entity);
@@ -1065,100 +1090,6 @@
return notes;
}
- /**
- * Return an existing compartment from the given SBML model or create a new compartment if the given entity has a valid cellularLocation element.
- * If the entity does not have any cellularLocation or the cellularLocation property is not
- * valid SBML id to use, then a default compartment will be returned.
- *
- * @param sbmlModel - The SBML model to store the SBML compartment to
- * @param entity - the entity to create the SBML compartment
- * @return The compartment created from the given entity
- */
- private Compartment createCompartment(org.sbml.jsbml.Model sbmlModel, Entity entity)
- {
- org.sbml.jsbml.Compartment finalCompartment = null;
- /*
- * Note: Only PhysicalEntity contains cellularLocation.
- * Since Gene is the only Entity type that is not a PhysicalEntity, the compartment for
- * gene will be stored in default compartment
- */
- if (entity instanceof PhysicalEntity)
- {
- PhysicalEntity physicalEntity = (PhysicalEntity) entity;
- CellularLocationVocabulary cellularLocVocab = physicalEntity.getCellularLocation();
- boolean isContainedXref = false;
- // Check if the compartment already exist in the sbml model
- if (cellularLocVocab != null)
- {
- if (org.sbml.jsbml.validator.SyntaxChecker.isValidId(cellularLocVocab.getRDFId(), sbmlLevel, sbmlVer))
- {
- if (sbmlModel.containsCompartment(physicalEntity.getCellularLocation().getRDFId()))
- {
- finalCompartment = sbmlModel.getCompartment(cellularLocVocab.getRDFId());
- }
- else
- {
- org.sbml.jsbml.Compartment compartment = sbmlModel.createCompartment((cellularLocVocab.getRDFId()));
- String compartmentName = getValidSBMLName(cellularLocVocab);
- if(compartmentName != null)
- {
- compartment.setName(compartmentName);
- }
- /*
- * Default settings for sbml compartment required attributes
- * setConstant(true) :
- * Specify if species has a fixed size
- * Since a compartment realistically changes size, for this
- * conversion and based on previous conversion, this is set
- * to true to indicate that the compartment will always stay
- * at the same constant size
- */
- compartment.setSBOTerm(SBO.getPhysicalCompartment());
- compartment.setConstant(true);
- finalCompartment = compartment;
- isContainedXref = true;
- }
- }
- else
- {
-
- //If there exist a cellularLocation but not valid sbml Id, generate new compartment id
- String compartmentId = getValidSBMLId(physicalEntity.getCellularLocation());
-
- org.sbml.jsbml.Compartment compartment = sbmlModel.getCompartment(compartmentId);
- //sbmlModel could not find compartment. Create new compartment
- if(compartment == null)
- {
- compartment = sbmlModel.createCompartment(compartmentId);
-
- compartment.setSBOTerm(SBO.getPhysicalCompartment());
- compartment.setConstant(true);
- isContainedXref = true;
- }
- finalCompartment = compartment;
- }
- if(isContainedXref)
- {
- if(entity.getEvidence() != null)
- {
- parseEvidence(entity.getEvidence(), finalCompartment);
- }
- if(cellularLocVocab.getXref() != null)
- {
- parseXref(cellularLocVocab.getXref(), finalCompartment);
- }
- }
- }
- }
-
- if(finalCompartment == null)
- {
- finalCompartment = getDefaultCompartment(sbmlModel);
- }
-
- return finalCompartment;
- }
-
private Compartment createCompartment(Entity entity)
{
org.sbml.jsbml.Compartment finalCompartment = null;
@@ -1275,20 +1206,6 @@
return compartmentId;
}
- private Compartment getDefaultCompartment(org.sbml.jsbml.Model sbmlModel)
- {
- // Get default compartment if it already exist in sbml model
- if (sbmlModel.getCompartment("defaultCompartment") != null)
- {
- return sbmlModel.getCompartment("defaultCompartment");
- }
-
- org.sbml.jsbml.Compartment defaultCompartment = sbmlModel.createCompartment("defaultCompartment");
- defaultCompartment.setSBOTerm(SBO.getCompartment());
- defaultCompartment.setConstant(true);
- return defaultCompartment;
- }
-
private Compartment getDefaultCompartment()
{
org.sbml.jsbml.Compartment defaultCompartment = new Compartment("defaultCompartment", sbmlLevel, sbmlVer);
@@ -1311,7 +1228,6 @@
}
else if (entity instanceof Protein)
{
- // sbmlSpecies.setSBOTerm(SBO.getProtein()); //252
sbmlSpecies.setSBOTerm(SBO.getGeneric());
}
else if (entity instanceof Dna)
@@ -1355,36 +1271,6 @@
}
}
- /**
- * Converts the provided biopax interactions into SBML reactions, reactant, particpants, SpeciesReference, and ModifierSpeciesReference.
- *
- * @param sbmlModel - The SBML model to store the reactions, reactant, particpants, SpeciesReference, and ModifierSpeciesReference to.
- * @param listOfConversions - Holds the list of all biopax conversion interaction to be converted to SBML reactions
- * @param listOfControls - Holds the list of all biopax control interactoin to be converted to SBLML ModifierSpeciesReference
- * @param listOfInteractions - Holds the list of all biopax interactions that are not of type conversion an control to be converted to SBML reactions
- * @throws ConversionException
- */
- private void parseInteractions(org.sbml.jsbml.Model sbmlModel, Set<Conversion> listOfConversions, Set<Control> listOfControls, List<Interaction> listOfInteractions) throws ConversionException
- {
- /*
- * Note: Interaction must be parsed in this order: Interaction, Conversion, then Control
- * This will ensure all reactions are created first before ModifierSpeciesReference are created.
- */
- for(Interaction interaction : listOfInteractions)
- {
- parsePhysicalInteraction(interaction, sbmlModel);
- }
- for(Conversion conversion : listOfConversions)
- {
- parseConversionInteraction(conversion, sbmlModel);
- }
- for(Control control : listOfControls)
- {
- parseControlInteraction(control, sbmlModel);
- }
-
- }
-
private void parseInteractions(Set<Conversion> listOfConversions, Set<Control> listOfControls, List<Interaction> listOfInteractions) throws ConversionException
{
/*
@@ -1406,30 +1292,6 @@
}
-
- private void parsePhysicalInteraction(Interaction entity, org.sbml.jsbml.Model sbmlModel) throws ConversionException
- {
- Reaction reaction = setReaction(entity, sbmlModel);
- reaction.setReversible(false);
- reaction.setFast(false);
-
- if (entity instanceof TemplateReaction)
- {
- parseTemplateReaction((TemplateReaction) entity, reaction);
- }
- else if (entity instanceof MolecularInteraction)
- {
- parseMolecularInteraction((MolecularInteraction) entity, reaction);
- }
- else if (entity instanceof GeneticInteraction)
- {
- parseGeneticInteraction((GeneticInteraction) entity, reaction);
- }
-
- setInteraction_SBO(entity, reaction);
-
- }
-
private void parsePhysicalInteraction(Interaction entity) throws ConversionException
{
Reaction reaction = createReaction(entity);
@@ -1462,7 +1324,7 @@
if(templateReaction.getTemplate() != null)
{
- ModifierSpeciesReference modifierSpeciesRef = getModifierSpeciesReference(templateReaction.getTemplate());
+ ModifierSpeciesReference modifierSpeciesRef = createModifierSpeciesReference(templateReaction.getTemplate());
reaction.addModifier(modifierSpeciesRef);
hasModifier = true;
}
@@ -1489,7 +1351,7 @@
//Parse for reactant/substrate and product
for(Entity p : participants)
{
- SpeciesReference reactant_product = getSpeciesReferences(p);
+ SpeciesReference reactant_product = createSpeciesReferences(p);
reactant_product.setSBOTerm(SBO.getMolecularInteraction());
reaction.addReactant(reactant_product.clone());
reaction.addProduct(reactant_product.clone());
@@ -1503,10 +1365,10 @@
{
if(p instanceof Gene)
{
- ModifierSpeciesReference modifierSpeciesRef = getModifierSpeciesReference(p);
+ ModifierSpeciesReference modifierSpeciesRef = createModifierSpeciesReference(p);
reaction.addModifier(modifierSpeciesRef);
}
- SpeciesReference reactant_product = getSpeciesReferences(p);
+ SpeciesReference reactant_product = createSpeciesReferences(p);
reactant_product.setSBOTerm(SBO.getGeneticInteraction());
reaction.addReactant(reactant_product.clone());
reaction.addProduct(reactant_product.clone());
@@ -1539,49 +1401,6 @@
}
}
- /**
- * Convert the provided biopax conversion interaction to the corresponding SBML reaction along with its reactants and products.
- * The reaction that is created is assigned with an SBO term corresponding to the given biopax conversion interaction.
- * The SBML reaction will then be stored in the provided SBML model
- *
- * @param conversion - The conversion interaction to be converted to an SBML reaction
- * @param sbmlModel - The SBML model that contains the generated reaction
- * @throws ConversionException
- */
- private void parseConversionInteraction(Conversion conversion, org.sbml.jsbml.Model sbmlModel) throws ConversionException
- {
- Reaction reaction = setReaction(conversion, sbmlModel);
- reaction.setFast(false);
-
- if( conversion.getConversionDirection() != null && (conversion.getConversionDirection().equals(ConversionDirectionType.LEFT_TO_RIGHT) ||
- conversion.getConversionDirection().equals(ConversionDirectionType.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);
- }
- else if( conversion.getConversionDirection() != null && (conversion.getConversionDirection().equals(ConversionDirectionType.RIGHT_TO_LEFT)))
- {
- reaction.setReversible(false);
-
- //Parse for reactant/substrate
- ListOf<SpeciesReference> reactants = getSpeciesReferences(conversion.getRight(), conversion.getParticipantStoichiometry());
- reaction.setListOfReactants(reactants);
-
- //Parse for product
- ListOf<SpeciesReference> products = getSpeciesReferences(conversion.getLeft(), conversion.getParticipantStoichiometry());
- reaction.setListOfProducts(products);
- }
-
- setConversion_SBO(conversion, reaction);
- }
-
private void parseConversionInteraction(Conversion conversion) throws ConversionException
{
Reaction reaction = createReaction(conversion);
@@ -1630,22 +1449,6 @@
setConversion_SBO(conversion, reaction);
}
- /**
- * Parses the Controlled and Controller Interaction from the given Control Interaction to generate the corresponding SBML ModifierSpeciesReference
- *
- * @param control - The control interaction to be parsed for SBML ModifierSpeciesReference
- * @param sbmlModel- The SBML model that contains the generated ModifierSpeciesReference
- * @throws ConversionException
- */
- private void parseControlInteraction(Control control, org.sbml.jsbml.Model sbmlModel) throws ConversionException
- {
- //parse controlled to create reactions. There must be 0 or more Controlled
- List<Reaction> controlledReactionList = parseControlledInteraction(control, sbmlModel);
-
- //parse controller to create ModifierSpeciesReference. There must be 0 or 1 Controller
- parseControllerInteraction(control, controlledReactionList);
- }
-
private void parseControlInteraction(Control control) throws ConversionException
{
//parse controlled to create reactions. There must be 0 or more Controlled
@@ -1675,7 +1478,7 @@
{
for(Controller controller : controllerList)
{
- ModifierSpeciesReference modifierSpecies = getModifierSpeciesReference(controller);
+ ModifierSpeciesReference modifierSpecies = createModifierSpeciesReference(controller);
if(modifierSpecies == null)
{
continue;
@@ -1703,7 +1506,7 @@
}
}
- private ModifierSpeciesReference getModifierSpeciesReference(Entity entity) throws ConversionException
+ private ModifierSpeciesReference createModifierSpeciesReference(Entity entity) throws ConversionException
{
ModifierSpeciesReference modifierSpecies = new ModifierSpeciesReference(sbmlLevel, sbmlVer);
@@ -1795,48 +1598,6 @@
}
}
- /**
- * Parse all Controlled Interaction found in the given Control Interaction to get the corresponding SBML controlled reactions
- *
- * @param control- The Control Interaction that holds the controlled interaction
- * @param sbmlModel - The SBML model that contains the controlled reactions
- * @return the list of SBML reactions that corresponds to given controlled interaction
- * @throws ConversionException
- */
- private List<Reaction> parseControlledInteraction(Control control, org.sbml.jsbml.Model sbmlModel) throws ConversionException
- {
- Set<org.biopax.paxtools.model.level3.Process> controlledList = control.getControlled();
- List<Reaction> controlledReactionList = new ArrayList<Reaction>();
- if (controlledList != null && controlledList.size() > 0)
- {
- for (org.biopax.paxtools.model.level3.Process process : controlledList)
- {
- if(process instanceof Control)
- {
- //Modulation
- controlledReactionList.addAll(parseControlledInteraction((Control) process, sbmlModel));
- }
- else
- {
- //Check if this process rdfId is contained within the hashmap table to see if sbml has this reaction id.
- // get that equivalent sbml reaction and add the list of modifier reaction
- if(biopaxId2sbmlId.containsKey(process.getRDFId()))
- {
- Reaction controlledReaction = sbmlModel.getReaction(biopaxId2sbmlId.get(process.getRDFId()));
- controlledReactionList.add(controlledReaction);
- }
- 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.");
- }
- }
-
- }
- }
-
- return controlledReactionList;
- }
-
private List<Reaction> parseControlledInteraction(Control control) throws ConversionException
{
Set<org.biopax.paxtools.model.level3.Process> controlledList = control.getControlled();
@@ -1880,7 +1641,7 @@
for(PhysicalEntity p : participants)
{
- SpeciesReference speciesRef = getSpeciesReferences(p);
+ SpeciesReference speciesRef = createSpeciesReferences(p);
if(stoichiometrySet != null)
{
setSpeciesStochiometry(speciesRef, stoichiometrySet, p);
@@ -1891,7 +1652,7 @@
}
- private org.sbml.jsbml.SpeciesReference getSpeciesReferences(Entity participant) throws ConversionException
+ private org.sbml.jsbml.SpeciesReference createSpeciesReferences(Entity participant) throws ConversionException
{
SpeciesReference speciesReference = new SpeciesReference(sbmlLevel, sbmlVer);
@@ -1958,40 +1719,6 @@
return (stoichiometry > 0 && stoichiometry < Double.MAX_VALUE);
}
- /**
- * Create an SBML reaction from the given entity Interaction.
- * The generated SBML reaction will be stored in the given SBML model.
- *
- * @param entity - The Interaction to be converted to the corresponding SBMl reaction
- * @param sbmlModel - The SBML model to store the generated reaction
- * @return The reaction that was created
- */
- private Reaction setReaction(Interaction entity, org.sbml.jsbml.Model sbmlModel)
- {
- Reaction reaction = sbmlModel.createReaction(getValidSBMLId(entity));
- String reactionName = getValidSBMLName(entity);
- if(reactionName != null)
- {
- reaction.setName(reactionName);
- }
- /* Default settings for sbml reaction required attributes
- * setFast(false) :
- * Indicate fast reaction
- * Assume reaction is not fast so set to false
- */
- reaction.setFast(false);
-
- if(entity.getEvidence() != null)
- {
- //parseEvidence(entity.getEvidence(), reaction);
- }
- if(entity.getXref() != null)
- {
- parseXref(entity.getXref(), reaction);
- }
- return reaction;
- }
-
private Reaction createReaction(Interaction entity)
{
Reaction reaction = new Reaction(getValidSBMLId(entity), sbmlLevel, sbmlVer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|