|
From: <tra...@us...> - 2016-08-01 06:39:52
|
Revision: 686
http://sourceforge.net/p/sbfc/code/686
Author: tramy-nguyen
Date: 2016-08-01 06:39:50 +0000 (Mon, 01 Aug 2016)
Log Message:
-----------
- generated new jsbml jar to use sbo terms for enthalpy change, entropy change, Gibbs free energy change, and equilibrium constant.
- modified parsing of templateReaction in BioPAX2SBML to reaction.setReversible() based on templateReactions.getTemplateReaction().
- Inserted reaction.setFast() from conversion.getSpontaneous() when parsing conversion interaction in BioPAX2SBML.
- Initiated implementation of converting Catalysis Interactions if the catalysisDirection conflicts with the catalysis controlled reactions conversionDirection
- implemented conversion of DeltaG, DeltaS, DeltaH, and KEQ for BiochemicalReaction and TransportWithBiochemicalReaction in BioPAX2SBML and SBML2BioPAX.
- Modified parsing of SBML modifiers to take in Modulation and TemplateReaction
- expanded createSpecies() in SBML2BioPAX to create Entities, PhysicalEntities, and SimplePhysicalEntities
- Expanded convertReaction() in SBML2BioPAX to convert TemplateReaction with its properties
Modified Paths:
--------------
trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java
trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXConverter.java
trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java
trunk/test/org/sbfc/test/biopax2sbml/PhysicalEntityTests.java
trunk/test/org/sbfc/test/sbml2biopax/ReadingSBMLFileTests.java
Added Paths:
-----------
trunk/lib/jsbml-1.2-SNAPSHOT-with-dependencies.jar
Removed Paths:
-------------
trunk/lib/jsbml-1.2-SNAPSHOT-20160726-with-dependencies.jar
Deleted: trunk/lib/jsbml-1.2-SNAPSHOT-20160726-with-dependencies.jar
===================================================================
(Binary files differ)
Added: trunk/lib/jsbml-1.2-SNAPSHOT-with-dependencies.jar
===================================================================
(Binary files differ)
Index: trunk/lib/jsbml-1.2-SNAPSHOT-with-dependencies.jar
===================================================================
--- trunk/lib/jsbml-1.2-SNAPSHOT-with-dependencies.jar 2016-07-29 06:43:50 UTC (rev 685)
+++ trunk/lib/jsbml-1.2-SNAPSHOT-with-dependencies.jar 2016-08-01 06:39:50 UTC (rev 686)
Property changes on: trunk/lib/jsbml-1.2-SNAPSHOT-with-dependencies.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java
===================================================================
--- trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java 2016-07-29 06:43:50 UTC (rev 685)
+++ trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java 2016-08-01 06:39:50 UTC (rev 686)
@@ -77,6 +77,7 @@
import org.biopax.paxtools.model.level3.SimplePhysicalEntity;
import org.biopax.paxtools.model.level3.SmallMolecule;
import org.biopax.paxtools.model.level3.Stoichiometry;
+import org.biopax.paxtools.model.level3.TemplateDirectionType;
import org.biopax.paxtools.model.level3.TemplateReaction;
import org.biopax.paxtools.model.level3.Transport;
import org.biopax.paxtools.model.level3.TransportWithBiochemicalReaction;
@@ -150,10 +151,11 @@
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;
+
+ /** Map the biopax RDFId to the list of Reactions that were split (i.e. A catalysis direction that did not match its controlled interaction direction)*/
+ private Map<String, List<SBase>> mappedSplitReactions;
//Counter for creating new SBML id
private int globalSBMLId;
@@ -211,7 +213,8 @@
//Store the mapping between biopax enties rdfId to the sbml object created for the corresponding biopax entity
mappedEntities = new HashMap<String, SBase>();
-
+ mappedSplitReactions = new HashMap<String, List<SBase>>();
+
SBMLDocument sbmlDoc = new SBMLDocument(sbmlLevel, sbmlVer);
SBMLModel biopaxSBMLModel = new SBMLModel(sbmlDoc);
@@ -223,6 +226,7 @@
org.biopax.paxtools.model.Model bioModel = biopaxModelLv3.getModel();
biopaxPrefixID = bioModel.getXmlBase(); //The URL prefix for biopax RDFId
+ //Create sbml objects for all biopax entities found in the given biomodel
mappAllEntities(bioModel);
/*
@@ -233,6 +237,7 @@
* 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");
@@ -298,7 +303,6 @@
* 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);
@@ -346,7 +350,7 @@
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
+ //Keep track of how many times this species occur in each submodel
int count = 0;
for(Submodel modelDef : compModel.getListOfSubmodels())
{
@@ -369,9 +373,9 @@
{
/*
* Note:
- * This physicalEntity occured in one submodel.
+ * This physicalEntity occurred 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
+ * Therefore, don't add this converted species to the top level sbml model
*/
continue;
}
@@ -424,7 +428,7 @@
* 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
+ * Therefore, don't add this converted reaction to the top level sbml model
*/
continue;
}
@@ -1306,7 +1310,7 @@
if (entity instanceof TemplateReaction)
{
parseTemplateReaction((TemplateReaction) entity, reaction);
- reaction.setReversible(false);
+
}
else if (entity instanceof MolecularInteraction)
{
@@ -1326,8 +1330,21 @@
private void parseTemplateReaction(TemplateReaction templateReaction, Reaction reaction) throws ConversionException
{
boolean hasModifier = false;
- boolean hasProduct = false;
-
+ boolean hasProduct = false; templateReaction.getTemplateDirection();
+
+ if(templateReaction.getTemplateDirection() == TemplateDirectionType.FORWARD)
+ {
+ reaction.setReversible(false);
+ }
+ else if (templateReaction.getTemplateDirection() == TemplateDirectionType.REVERSE)
+ {
+ reaction.setReversible(true);
+ }
+ else
+ {
+ reaction.setReversible(false);
+ }
+
if(templateReaction.getTemplate() != null)
{
ModifierSpeciesReference modifierSpeciesRef = createModifierSpeciesReference(templateReaction.getTemplate());
@@ -1410,7 +1427,14 @@
private void parseConversionInteraction(Conversion conversion) throws ConversionException
{
Reaction reaction = createReaction(conversion);
- reaction.setFast(conversion.getSpontaneous());
+ if(conversion.getSpontaneous() != null)
+ {
+ reaction.setFast(conversion.getSpontaneous());
+ }
+ else
+ {
+ reaction.setFast(false);
+ }
if( conversion.getConversionDirection() != null && (conversion.getConversionDirection().equals(ConversionDirectionType.LEFT_TO_RIGHT) ||
conversion.getConversionDirection().equals(ConversionDirectionType.REVERSIBLE)))
@@ -1512,10 +1536,55 @@
for(org.biopax.paxtools.model.level3.Process catalysisControlled : catalysis.getControlled())
{
Conversion controlled = (Conversion) catalysisControlled;
+
+ /*
+ * Note:
+ * Special case when the catalysisDirection and the controlledReaction is not the same, perform the following:
+ * Quoted from Chris Myers,
+ * "In this case, the Catalyst modifier should only be put in the forward reaction and not the reverse reaction.
+ * Split the Reversible reaction for this interaction into two irreversible reactions
+ * and the Catalyst would appear as a Modifier in only the reaction that matches the CatalysisDirection."
+ */
if(controlled.getConversionDirection() == ConversionDirectionType.LEFT_TO_RIGHT &&
catalysis.getCatalysisDirection() != CatalysisDirectionType.LEFT_TO_RIGHT)
{
- //TODO:
+ //TODO:
+ String reaction_prefixId = controlledReaction.getId();
+ List<SBase> splitReactions = new ArrayList<SBase>();
+
+ Reaction forwardReaction = controlledReaction.clone();
+ forwardReaction.setId(reaction_prefixId + "_forwardReaction");
+ forwardReaction.setReversible(false);
+ splitReactions.add(forwardReaction);
+
+ Reaction reverseReaction = controlledReaction.clone();
+ reverseReaction.setId(reaction_prefixId + "_reverseReaction");
+ reverseReaction.setReversible(false);
+ reverseReaction.addModifier(modifierSpecies);
+ splitReactions.add(reverseReaction);
+
+ mappedSplitReactions.put(catalysis.getRDFId(), splitReactions);
+
+ ListOf<SpeciesReference> reactants = controlledReaction.getListOfProducts();
+ ListOf<SpeciesReference> products = controlledReaction.getListOfReactants();
+
+ for(int index = 0; index < controlledReaction.getNumReactants(); index++)
+ {
+ controlledReaction.removeReactant(index);
+ }
+ for(int index = 0; index < controlledReaction.getNumProducts(); index++)
+ {
+ controlledReaction.removeProduct(index);
+ }
+
+ for(SpeciesReference r : reactants)
+ {
+ controlledReaction.addReactant(r);
+ }
+ for(SpeciesReference p : products)
+ {
+ controlledReaction.addProduct(p);
+ }
}
else if(controlled.getConversionDirection() == ConversionDirectionType.RIGHT_TO_LEFT &&
catalysis.getCatalysisDirection() != CatalysisDirectionType.RIGHT_TO_LEFT)
@@ -1529,7 +1598,7 @@
}
}
- catalysis.getCatalysisDirection();
+ catalysis.getCatalysisDirection(); //TODO: need to find real file cases on how this works
}
setControl_SBO(control, modifierSpecies);
@@ -1553,39 +1622,49 @@
private void parseBiochemicalReaction(BiochemicalReaction biochemReaction, Reaction controlledReaction)
{
KineticLaw kineticLaw = controlledReaction.createKineticLaw();
+ kineticLaw.setMath(new ASTNode(Double.NaN));
int count = 0;
for(DeltaG deltaG : biochemReaction.getDeltaG())
{
String prefix = getValidSBMLId(deltaG) + "_";
- addLocalParameter(prefix + "deltaGPrime0", kineticLaw, deltaG.getDeltaGPrime0());
- addLocalParameter(prefix + "deltaGIonicStrength", kineticLaw, deltaG.getIonicStrength());
- addLocalParameter(prefix + "deltaGPh", kineticLaw, deltaG.getPh());
- addLocalParameter(prefix + "deltaGPMg", kineticLaw, deltaG.getPMg());
- addLocalParameter(prefix + "deltaGTemperature", kineticLaw, deltaG.getTemperature());
+ addLocalParameter(prefix + "deltaGPrime0", kineticLaw, deltaG.getDeltaGPrime0(), SBO.getGibbsFreeEnergyChange());
+ addLocalParameter(prefix + "deltaGIonicStrength", kineticLaw, deltaG.getIonicStrength(), SBO.getGibbsFreeEnergyChange());
+ addLocalParameter(prefix + "deltaGPh", kineticLaw, deltaG.getPh(), SBO.getGibbsFreeEnergyChange());
+ addLocalParameter(prefix + "deltaGPMg", kineticLaw, deltaG.getPMg(), SBO.getGibbsFreeEnergyChange());
+ addLocalParameter(prefix + "deltaGTemperature", kineticLaw, deltaG.getTemperature(), SBO.getGibbsFreeEnergyChange());
}
for(Float deltaH : biochemReaction.getDeltaH())
{
- addLocalParameter("deltaH_" + count++, kineticLaw, deltaH);
+ addLocalParameter("deltaH_" + count++, kineticLaw, deltaH, SBO.getEnthalpyChange());
}
for(Float deltaS : biochemReaction.getDeltaS())
{
- addLocalParameter("deltaS_" + count++, kineticLaw, deltaS);
+ addLocalParameter("deltaS_" + count++, kineticLaw, deltaS, SBO.getEntropyChange());
}
for(KPrime kprime : biochemReaction.getKEQ())
{
String prefix = getValidSBMLId(kprime) + "_";
- addLocalParameter(prefix + "KPrime", kineticLaw, kprime.getKPrime());
- addLocalParameter(prefix + "KPrimeIonicStrength", kineticLaw, kprime.getIonicStrength());
- addLocalParameter(prefix + "KPrimePh", kineticLaw, kprime.getPh());
- addLocalParameter(prefix + "KPrimeMg", kineticLaw, kprime.getPMg());
- addLocalParameter(prefix + "KPrimeTemperature", kineticLaw, kprime.getTemperature());
+ addLocalParameter(prefix + "KPrime", kineticLaw, kprime.getKPrime(), SBO.getEquilibriumConstant());
+ addLocalParameter(prefix + "KPrimeIonicStrength", kineticLaw, kprime.getIonicStrength(), SBO.getEquilibriumConstant());
+ addLocalParameter(prefix + "KPrimePh", kineticLaw, kprime.getPh(), SBO.getEquilibriumConstant());
+ addLocalParameter(prefix + "KPrimeMg", kineticLaw, kprime.getPMg(), SBO.getEquilibriumConstant());
+ addLocalParameter(prefix + "KPrimeTemperature", kineticLaw, kprime.getTemperature(), SBO.getEquilibriumConstant());
}
}
- private LocalParameter addLocalParameter(String id, KineticLaw kineticLaw, double value)
+ /**
+ * Creates a LocalParameter to attach to a KineticLaw
+ *
+ * @param id - The id of the LocalParameter
+ * @param kineticLaw - The KineticLaw that the LocalParameter will be added on
+ * @param value - The value to set the LocalParameter to
+ * @param SBOvalue - The SBO value the LocalParameter should be set to
+ * @return
+ */
+ private LocalParameter addLocalParameter(String id, KineticLaw kineticLaw, double value, int SBOvalue)
{
LocalParameter localParam = kineticLaw.createLocalParameter(id);
- localParam.setSBOTerm("SBO:xxxxxxx"); //TODO: TBD
+ localParam.setSBOTerm(SBOvalue);
localParam.setValue(value);
return localParam;
}
@@ -1778,7 +1857,6 @@
if(isValidStoichiometry(stoichiometry.getStoichiometricCoefficient()))
{
speciesReference.setStoichiometry(stoichiometry.getStoichiometricCoefficient());
-
}
speciesReference.setId(getValidSBMLId(stoichiometry));
String speciesRefName = getValidSBMLName(stoichiometry);
Modified: trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXConverter.java
===================================================================
--- trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXConverter.java 2016-07-29 06:43:50 UTC (rev 685)
+++ trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXConverter.java 2016-08-01 06:39:50 UTC (rev 686)
@@ -3,9 +3,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.biopax.paxtools.impl.level3.StoichiometryImpl;
import org.biopax.paxtools.model.Model;
+import org.biopax.paxtools.model.level3.Catalysis;
import org.biopax.paxtools.model.level3.Complex;
import org.biopax.paxtools.model.level3.Control;
+import org.biopax.paxtools.model.level3.ControlType;
import org.biopax.paxtools.model.level3.Controller;
import org.biopax.paxtools.model.level3.Conversion;
import org.biopax.paxtools.model.level3.Dna;
@@ -15,13 +18,18 @@
import org.biopax.paxtools.model.level3.GeneticInteraction;
import org.biopax.paxtools.model.level3.Interaction;
import org.biopax.paxtools.model.level3.MolecularInteraction;
+import org.biopax.paxtools.model.level3.NucleicAcid;
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.Rna;
import org.biopax.paxtools.model.level3.RnaRegion;
+import org.biopax.paxtools.model.level3.SimplePhysicalEntity;
import org.biopax.paxtools.model.level3.SmallMolecule;
+import org.biopax.paxtools.model.level3.Stoichiometry;
+import org.biopax.paxtools.model.level3.TemplateDirectionType;
import org.biopax.paxtools.model.level3.TemplateReaction;
+import org.biopax.paxtools.model.level3.UnificationXref;
import org.sbml.jsbml.ListOf;
import org.sbml.jsbml.ModifierSpeciesReference;
import org.sbml.jsbml.Reaction;
@@ -157,7 +165,7 @@
log.trace("Working on reaction conversion: " + reaction.getName());
Interaction interaction = sbml2BioPAXUtilities.convertReaction(bpModel, reaction);
pathway.addPathwayComponent(interaction);
-
+
// Modifiers -> Control reactions [start]
log.trace(
"- There are " + reaction.getNumModifiers() + " modifiers to this reaction. " +
@@ -168,13 +176,14 @@
// Reactants -> Left Participants [start]
log.trace("- There are " + reaction.getNumReactants() + " reactants to this reaction. " +
"Adding them to the reaction as left participants.");
- parseSpeciesReference(sbmlModel, reaction.getListOfReactants(), bpModel, interaction, false);
+
+ parseSpeciesReference(sbmlModel, reaction.getListOfReactants(), bpModel, interaction, reaction);
// Reactants -> Left Participants [end]
// Products -> Right Participants [start]
log.trace("- There are " + reaction.getNumProducts() + " products to this reaction. " +
"Adding them to the reaction as right participants.");
- parseSpeciesReference(sbmlModel, reaction.getListOfProducts(), bpModel, interaction, true);
+ parseSpeciesReference(sbmlModel, reaction.getListOfProducts(), bpModel, interaction, reaction);
// Products -> Right Participants [end]
}
// Reactions -> Conversions [end]
@@ -189,19 +198,36 @@
if(interaction instanceof GeneticInteraction)
{
Species species = sbmlModel.getSpecies(modifier.getSpecies());
- Gene gene = sbml2BioPAXUtilities.convertGeneFromSpecies(bpModel, species);
+ Gene gene = sbml2BioPAXUtilities.convertSpeciesToE(bpModel, Gene.class, UnificationXref.class, species);
interaction.addParticipant(gene);
}
else if(interaction instanceof TemplateReaction)
{
+ TemplateReaction templateReaction = (TemplateReaction) interaction;
Species species = sbmlModel.getSpecies(modifier.getSpecies());
- PhysicalEntity physicalEntity = (PhysicalEntity) sbml2BioPAXUtilities.convertSpecies(bpModel, species);
- if(physicalEntity instanceof Dna || physicalEntity instanceof Rna || physicalEntity instanceof Protein)
+ Entity entity = (Entity) sbml2BioPAXUtilities.convertSpecies(bpModel, species);
+ if(entity instanceof Dna || entity instanceof DnaRegion
+ || entity instanceof Rna || entity instanceof RnaRegion)
{
- interaction.addParticipant(physicalEntity);
+ NucleicAcid templateEntity = (NucleicAcid) entity;
+ templateReaction.setTemplate(templateEntity);
}
}
- else {
+ else if(interaction instanceof Catalysis)
+ {
+ Catalysis catalysis = (Catalysis) interaction;
+ if(modifier.getSBOTerm() == SBO.getCatalyticActivator())
+ {
+ Species species = sbmlModel.getSpecies(modifier.getSpecies());
+ PhysicalEntity cofactorEntity = (PhysicalEntity) sbml2BioPAXUtilities.convertSpecies(bpModel, species);
+ catalysis.addCofactor(cofactorEntity);
+ }
+ else if(modifier.getSBOTerm() == SBO.getCatalyst())
+ {
+ catalysis.setControlType(ControlType.ACTIVATION);
+ }
+ }
+ else {//This could be Modulation, TemplateReactionRegulation, or any other Control Interaction
Control control = sbml2BioPAXUtilities.convertModifier(bpModel, modifier);
pathway.addPathwayComponent(control);
control.addControlled(interaction);
@@ -214,7 +240,7 @@
}
private void parseSpeciesReference(org.sbml.jsbml.Model sbmlModel, ListOf<SpeciesReference> listOfSpeciesReferences,
- Model bpModel, Interaction interaction, boolean isProduct)
+ Model bpModel, Interaction interaction, Reaction reaction)
{
// Reactants -> Left Participants [start]
@@ -223,15 +249,25 @@
Entity entity = sbml2BioPAXUtilities.convertSpecies(bpModel, species);
if(interaction instanceof Conversion){
Conversion conversion = (Conversion) interaction;
- if(isProduct)
+ if(reaction.getReversible())
{
- conversion.addRight((PhysicalEntity) entity);
- }
+ conversion.addLeft((PhysicalEntity) entity);
+ }
else
{
- conversion.addLeft((PhysicalEntity) entity);
+ conversion.addRight((PhysicalEntity) entity);
}
+ if(!Double.isNaN(speciesRef.getStoichiometry()))
+ {
+ Stoichiometry conversionStoich = new StoichiometryImpl();
+ conversionStoich.setStoichiometricCoefficient((float) speciesRef.getStoichiometry());
+ conversion.addParticipantStoichiometry(conversionStoich);
+ }
}
+ else if(interaction instanceof TemplateReaction)
+ {
+ ((TemplateReaction) interaction).addProduct((PhysicalEntity) entity);
+ }
else if(interaction instanceof GeneticInteraction || interaction instanceof MolecularInteraction){
interaction.addParticipant(entity);
}
Modified: trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java
===================================================================
--- trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java 2016-07-29 06:43:50 UTC (rev 685)
+++ trunk/src/org/sbfc/converter/sbml2biopax/arman/SBML2BioPAXUtilities.java 2016-08-01 06:39:50 UTC (rev 686)
@@ -11,7 +11,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.biopax.paxtools.impl.level3.DeltaGImpl;
import org.biopax.paxtools.impl.level3.EntityReferenceImpl;
+import org.biopax.paxtools.impl.level3.KPrimeImpl;
import org.biopax.paxtools.model.BioPAXElement;
import org.biopax.paxtools.model.BioPAXFactory;
import org.biopax.paxtools.model.BioPAXLevel;
@@ -26,6 +28,7 @@
import org.biopax.paxtools.model.level3.Conversion;
import org.biopax.paxtools.model.level3.ConversionDirectionType;
import org.biopax.paxtools.model.level3.Degradation;
+import org.biopax.paxtools.model.level3.DeltaG;
import org.biopax.paxtools.model.level3.Dna;
import org.biopax.paxtools.model.level3.DnaReference;
import org.biopax.paxtools.model.level3.DnaRegion;
@@ -35,6 +38,8 @@
import org.biopax.paxtools.model.level3.Gene;
import org.biopax.paxtools.model.level3.GeneticInteraction;
import org.biopax.paxtools.model.level3.Interaction;
+import org.biopax.paxtools.model.level3.KPrime;
+import org.biopax.paxtools.model.level3.Modulation;
import org.biopax.paxtools.model.level3.MolecularInteraction;
import org.biopax.paxtools.model.level3.Named;
import org.biopax.paxtools.model.level3.Pathway;
@@ -50,7 +55,9 @@
import org.biopax.paxtools.model.level3.SimplePhysicalEntity;
import org.biopax.paxtools.model.level3.SmallMolecule;
import org.biopax.paxtools.model.level3.SmallMoleculeReference;
+import org.biopax.paxtools.model.level3.TemplateDirectionType;
import org.biopax.paxtools.model.level3.TemplateReaction;
+import org.biopax.paxtools.model.level3.TemplateReactionRegulation;
import org.biopax.paxtools.model.level3.Transport;
import org.biopax.paxtools.model.level3.TransportWithBiochemicalReaction;
import org.biopax.paxtools.model.level3.UnificationXref;
@@ -65,556 +72,719 @@
import org.sbml.jsbml.Annotation;
import org.sbml.jsbml.CVTerm;
import org.sbml.jsbml.Compartment;
+import org.sbml.jsbml.KineticLaw;
+import org.sbml.jsbml.LocalParameter;
import org.sbml.jsbml.ModifierSpeciesReference;
import org.sbml.jsbml.Reaction;
import org.sbml.jsbml.SBO;
import org.sbml.jsbml.Species;
+import org.sbml.jsbml.CVTerm.Qualifier;
public class SBML2BioPAXUtilities {
- private static Log log = LogFactory.getLog(SBML2BioPAXUtilities.class);
+ private static Log log = LogFactory.getLog(SBML2BioPAXUtilities.class);
- private BioPAXFactory bioPAXFactory = BioPAXLevel.L3.getDefaultFactory();
+ private BioPAXFactory bioPAXFactory = BioPAXLevel.L3.getDefaultFactory();
- public BioPAXFactory getBioPAXFactory() {
- return bioPAXFactory;
- }
+ public BioPAXFactory getBioPAXFactory() {
+ return bioPAXFactory;
+ }
- public void setBioPAXFactory(BioPAXFactory bioPAXFactory) {
- this.bioPAXFactory = bioPAXFactory;
- }
+ public void setBioPAXFactory(BioPAXFactory bioPAXFactory) {
+ this.bioPAXFactory = bioPAXFactory;
+ }
- private String XMLBase = "http://www.humanmetabolism.org/#";
+ private String XMLBase = "http://www.humanmetabolism.org/#";
- public String getXMLBase() {
- return XMLBase;
- }
+ public String getXMLBase() {
+ return XMLBase;
+ }
- public void setXMLBase(String XMLBase) {
- this.XMLBase = XMLBase;
- }
+ public void setXMLBase(String XMLBase) {
+ this.XMLBase = XMLBase;
+ }
- public String completeId(String partialId) {
- return getXMLBase() + partialId;
- }
+ public String completeId(String partialId) {
+ return getXMLBase() + partialId;
+ }
- /**
- * Convert an SBML model to a biopax pathway.
- *
- * @param bpModel - The biopax model to store the Pathway that was converted from the given SBML Model.
- * @param sbmlModel - The SBML Model to be converted to a BioPAX Interaction
- * @return
- */
- public Pathway convertPathway(Model bpModel, org.sbml.jsbml.Model sbmlModel) {
- Pathway pathway = createBPEfromSBMLE(bpModel, Pathway.class, sbmlModel);
- for (Xref xref : generateXrefsForSBase(bpModel, RelationshipXref.class, sbmlModel)) {
- pathway.addXref(xref);
- }
- return pathway;
- }
+ /**
+ * Convert an SBML model to a biopax pathway.
+ *
+ * @param bpModel - The biopax model to store the Pathway that was converted from the given SBML Model.
+ * @param sbmlModel - The SBML Model to be converted to a BioPAX Interaction
+ * @return
+ */
+ public Pathway convertPathway(Model bpModel, org.sbml.jsbml.Model sbmlModel) {
+ Pathway pathway = createBPEfromSBMLE(bpModel, Pathway.class, sbmlModel);
+ for (Xref xref : generateXrefsForSBase(bpModel, RelationshipXref.class, sbmlModel)) {
+ pathway.addXref(xref);
+ }
+ return pathway;
+ }
- public Model createModel() {
- Model model = bioPAXFactory.createModel();
- // This could change, would be great to make this configurable
- model.setXmlBase(getXMLBase());
- return model;
- }
+ public Model createModel() {
+ Model model = bioPAXFactory.createModel();
+ // This could change, would be great to make this configurable
+ model.setXmlBase(getXMLBase());
+ return model;
+ }
- /**
- * Convert a SBML reaction to a BioPAX interaction.
- *
- * @param bpModel - The BioPAX Model to store the Interaction that was converted from the given SBML Reaction.
- * @param reaction - The SBML Reaction to be converted to a BioPAX Interaction
- * @return The converted BioPAX Interaction
- */
- public Interaction convertReaction(Model bpModel, Reaction reaction) {
- Class<? extends Conversion> rxnClass = null;
-
- Class<? extends Interaction> reactionClass = null;
-
- boolean isConversionSet = false;
-
- // Extend this switch with further SBO terms as needed
- switch (reaction.getSBOTerm()) {
- case 589:
- reactionClass = TemplateReaction.class;
- break;
- case 343:
- reactionClass = GeneticInteraction.class;
- break;
- case 344:
- reactionClass = MolecularInteraction.class;
- break;
- case 231:
- reactionClass = Interaction.class;
- break;
- case 177: //Complex Assembly
- rxnClass = ComplexAssembly.class;
- isConversionSet = true;
- break;
- case 176: // Biochemical reaction
- rxnClass = BiochemicalReaction.class;
- isConversionSet = true;
- break;
- case 167: // Transport With Biochemical Reaction
- rxnClass = TransportWithBiochemicalReaction.class;
- isConversionSet = true;
- break;
- case 185: // Transport reaction
- rxnClass = Transport.class;
- isConversionSet = true;
- break;
- case 179: // Degradation
- rxnClass = Degradation.class;
- isConversionSet = true;
- break;
- case 182: // Conversion
- rxnClass = Conversion.class;
- isConversionSet = true;
- break;
- default:
- reactionClass = Interaction.class;
- break;
- }
+ /**
+ * Convert a SBML reaction to a BioPAX interaction.
+ *
+ * @param bpModel - The BioPAX Model to store the Interaction that was converted from the given SBML Reaction.
+ * @param reaction - The SBML Reaction to be converted to a BioPAX Interaction
+ * @return The converted BioPAX Interaction
+ */
+ public Interaction convertReaction(Model bpModel, Reaction reaction) {
+ Class<? extends Conversion> rxnClass = null;
- if(isConversionSet)
- {
- Conversion conversion = createBPEfromSBMLE(bpModel, rxnClass, reaction);
- conversion.setConversionDirection(
- reaction.getReversible()
- ? ConversionDirectionType.REVERSIBLE
- : ConversionDirectionType.LEFT_TO_RIGHT
- );
- return setXref(bpModel, reaction, conversion);
- }
+ Class<? extends Interaction> reactionClass = null;
- Interaction interaction = createBPEfromSBMLE(bpModel, reactionClass, reaction);
- return setXref(bpModel, reaction, interaction);
- }
+ boolean isConversionSet = false;
- /**
- * Set xref to the BioPAX Interaction in the BioPAX Model based on the SBML Reaction.
- *
- * @param bpModel - The BioPAX Model to set the xref information
- * @param reaction - The SBML reaction to retrieve xref information
- * @param interaction - The BioPAX Interaction to add the xref information to
- * @return The BioPAX Interaction that xref was added to
- */
- public Interaction setXref(Model bpModel, Reaction reaction, Interaction interaction)
- {
- for (Xref xref : generateXrefsForSBase(bpModel, RelationshipXref.class, reaction)) {
- interaction.addXref(xref);
- }
- return interaction;
- }
-
- /**
- * Provide the SBML SBase element with a given name
- *
- * @param namedSBase - The SBML SBase element to get the name
- * @param named - The biopax object to set entity name
- */
- public void setNames(AbstractNamedSBase namedSBase, Named named) {
- String name = namedSBase.getName();
- if(name == null || name.toLowerCase().equals("null")) {
- name = "N/A";
- }
- /*
- * TODO: modify standardName and once SBML files finds the location where this value is stored
- */
-// named.setStandardName(name);
- named.setDisplayName(name);
- named.getName().add(name);
- }
+ // Extend this switch with further SBO terms as needed
+ switch (reaction.getSBOTerm()) {
+ case 589:
+ reactionClass = TemplateReaction.class;
+ break;
+ case 343:
+ reactionClass = GeneticInteraction.class;
+ break;
+ case 344:
+ reactionClass = MolecularInteraction.class;
+ break;
+ case 231:
+ reactionClass = Interaction.class;
+ break;
+ case 177: //Complex Assembly
+ rxnClass = ComplexAssembly.class;
+ isConversionSet = true;
+ break;
+ case 176: // Biochemical reaction
+ rxnClass = BiochemicalReaction.class;
+ isConversionSet = true;
+ break;
+ case 167: // Transport With Biochemical Reaction
+ rxnClass = TransportWithBiochemicalReaction.class;
+ isConversionSet = true;
+ break;
+ case 185: // Transport reaction
+ rxnClass = Transport.class;
+ isConversionSet = true;
+ break;
+ case 179: // Degradation
+ rxnClass = Degradation.class;
+ isConversionSet = true;
+ break;
+ case 182: // Conversion
+ rxnClass = Conversion.class;
+ isConversionSet = true;
+ break;
+ default:
+ reactionClass = Interaction.class;
+ break;
+ }
- /**
- * Convert a SBML ModifierSpeciesReference to a BioPAX Control Interaction.
- *
- * @param bpModel - The BioPAX Model to store the Control Interaction that was converted from the given SBML ModifierSpeciesReference.
- * @param modifierSpeciesReference - The SBML ModifierSpeciesReference to be converted to a BioPAX Control Interaction
- * @return The converted BioPAX Control Interaction
- */
- public Control convertModifier(Model bpModel, ModifierSpeciesReference modifierSpeciesReference) {
- // Interesting enough, these reference objects don't have an ID associated with them
- // That is why we are using hashcodes to generate unique BioPAX ID.
- String id = completeId("control_" + modifierSpeciesReference.getId());
- Control control = createBPEfromSBMLE(bpModel, Control.class, modifierSpeciesReference, id);
-
- //TODO: add terms for Inhibition irreversible, Inhibition allosteric
- switch (modifierSpeciesReference.getSBOTerm()) {
- case 21:
- control.setControlType(ControlType.ACTIVATION);
- break;
- case 636:
- control.setControlType(ControlType.ACTIVATION_ALLOSTERIC);
- break;
- case 637:
- control.setControlType(ControlType.ACTIVATION_NONALLOSTERIC);
- break;
- case 20:
- control.setControlType(ControlType.INHIBITION);
- break;
- case 207:
- control.setControlType(ControlType.INHIBITION_NONCOMPETITIVE);
- break;
- case 206:
- control.setControlType(ControlType.INHIBITION_COMPETITIVE);
- break;
- case 638:
- control.setControlType(ControlType.INHIBITION_IRREVERSIBLE);
- break;
- case 639:
- control.setControlType(ControlType.INHIBITION_ALLOSTERIC);
- break;
-// case 20:
-// control.setControlType(ControlType.INHIBITION_OTHER);
-// break;
- case 640:
- control.setControlType(ControlType.INHIBITION_UNCOMPETITIVE);
- break;
- default:
- control.setControlType(ControlType.ACTIVATION);
- break;
- }
-
- return control;
- }
+ if(isConversionSet)
+ {
+ Conversion conversion = createBPEfromSBMLE(bpModel, rxnClass, reaction);
+ conversion.setConversionDirection(
+ reaction.getReversible()
+ ? ConversionDirectionType.REVERSIBLE
+ : ConversionDirectionType.RIGHT_TO_LEFT
+ );
- public <T extends SimplePhysicalEntity, S extends EntityReference> T convertSpeciesToSPE(Model bpModel, Class<T> entityClass, Class<S> refClass, Species species) {
- Set<Xref> xrefs = generateXrefsForSBase(bpModel, UnificationXref.class, species);
- HashSet<XReferrable> ers = new HashSet<XReferrable>();
- for (Xref xref : xrefs) {
- for (XReferrable xReferrable : xref.getXrefOf()) {
- // Only add the entity references
- if(xReferrable instanceof EntityReference) {
- ers.add(xReferrable);
- }
- }
- }
+ conversion.setSpontaneous(reaction.getFast() ? true : false);
- S reference;
- if(ers.isEmpty()) {
- reference = createBPEfromSBMLE(bpModel, refClass, species, completeId("ref_" + species.getId()));
- for (Xref xref : xrefs) {
- reference.addXref(xref);
- }
- } else if(ers.size() == 1) { // There shouldn't be more than one
- reference = (S) ers.iterator().next();
- } else {
- log.warn(
- "There are more than one EntityReferences that match with the same unification xref for species: "
- + species.getName()
- + ". Picking the first one: "
- + ers.iterator().next().getRDFId()
- );
+ if(rxnClass.equals(TransportWithBiochemicalReaction.class) || rxnClass.equals(BiochemicalReaction.class))
+ {
+ BiochemicalReaction biochemicalReaction = (BiochemicalReaction) conversion;
+ parseKineticLaw(reaction, biochemicalReaction);
+ }
- reference = (S) ers.iterator().next();
- }
+ return setXref(bpModel, reaction, conversion);
+ }
+ if(reactionClass.equals(TemplateReaction.class))
+ {
+ TemplateReaction templateReaction = (TemplateReaction) createBPEfromSBMLE(bpModel, reactionClass, reaction);
+ templateReaction.setTemplateDirection(
+ reaction.getReversible()
+ ? TemplateDirectionType.FORWARD
+ : TemplateDirectionType.REVERSE
+ );
+ return setXref(bpModel, reaction, templateReaction);
+ }
+ Interaction interaction = createBPEfromSBMLE(bpModel, reactionClass, reaction);
+ return setXref(bpModel, reaction, interaction);
+ }
- T entity = createBPEfromSBMLE(bpModel, entityClass, species);
- entity.setEntityReference(reference);
+ private void parseKineticLaw(Reaction reaction, BiochemicalReaction biochemicalReaction)
+ {
+ KineticLaw reactionKL = reaction.getKineticLaw();
+ if(reactionKL != null)
+ {
+ for(LocalParameter localParam : reactionKL.getListOfLocalParameters())
+ {
+ String localParamId = localParam.getId();
- // Clean-up non-used xrefs
- for (Xref xref : xrefs) {
- if(xref.getXrefOf().isEmpty()) {
- bpModel.remove(xref);
- }
- }
+ if(localParam.getSBOTerm() == SBO.getGibbsFreeEnergyChange())
+ {
+ //Create deltaG
+ DeltaG deltaG = new DeltaGImpl();
- return entity;
- }
+ //TODO: how to set rdfId for deltaG?
+ String suffix = "";
+ int index = localParamId.length() - 1;
+ while(localParamId.charAt(index) != '_')
+ {
+ suffix = localParamId.charAt(index--) + suffix ;
+ }
+ String rdfId = localParamId.substring(0, index);
- private <T extends Xref> T resourceToXref(Class<T> xrefClass, String xrefId, String resource) {
- // using the miriam common library to get the id and database String regardless of the form of the URI.
-
- T xref = bioPAXFactory.create(xrefClass, xrefId);
- 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);
+ if(localParamId.endsWith("_deltaGPrime0"))
+ {
+ deltaG.setDeltaGPrime0((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_deltaGIonicStrength"))
+ {
+ deltaG.setIonicStrength((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_deltaGPh"))
+ {
+ deltaG.setPh((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_deltaGPMg"))
+ {
+ deltaG.setPMg((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_deltaGTemperature"))
+ {
+ deltaG.setTemperature((float) localParam.getValue());
+ }
+ biochemicalReaction.addDeltaG(deltaG);
+ }
+ else if(localParam.getSBOTerm() == SBO.getEnthalpyChange())
+ {
+ //deltaH
+ biochemicalReaction.addDeltaH((float) localParam.getValue());
+ }
+ else if(localParam.getSBOTerm() == SBO.getEntropyChange())
+ {
+ //deltaS
+ biochemicalReaction.addDeltaS((float) localParam.getValue());
+ }
+ else if(localParam.getSBOTerm() == SBO.getEquilibriumConstant())
+ {
+ //KEQ
+ KPrime kprime = new KPrimeImpl();
+ if(localParamId.endsWith("_KPrime"))
+ {
+ kprime.setKPrime((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_KPrimeIonicStrength"))
+ {
+ kprime.setIonicStrength((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_KPrimePh"))
+ {
+ kprime.setPh((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_KPrimeMg"))
+ {
+ kprime.setPMg((float) localParam.getValue());
+ }
+ else if(localParamId.endsWith("_KPrimeTemperature"))
+ {
+ kprime.setTemperature((float) localParam.getValue());
+ }
+ }
+ }
+ }
+ }
- return xref;
- }
+ /**
+ * Set xref to the BioPAX Interaction in the BioPAX Model based on the SBML Reaction.
+ *
+ * @param bpModel - The BioPAX Model to set the xref information
+ * @param reaction - The SBML reaction to retrieve xref information
+ * @param interaction - The BioPAX Interaction to add the xref information to
+ * @return The BioPAX Interaction that xref was added to
+ */
+ public Interaction setXref(Model bpModel, Reaction reaction, Interaction interaction)
+ {
+ for (Xref xref : generateXrefsForSBase(bpModel, RelationshipXref.class, reaction)) {
+ interaction.addXref(xref);
+ }
+ return interaction;
+ }
- public <T extends Named> T createBPEfromSBMLE(Model bpModel, Class<T> aClass, AbstractNamedSBase abstractNamedSBase) {
- return createBPEfromSBMLE(bpModel, aClass, abstractNamedSBase, completeId(abstractNamedSBase.getId()));
- }
+ /**
+ * Provide the SBML SBase element with a given name
+ *
+ * @param namedSBase - The SBML SBase element to get the name
+ * @param named - The biopax object to set entity name
+ */
+ public void setNames(AbstractNamedSBase namedSBase, Named named) {
+ String name = namedSBase.getName();
+ if(name == null || name.isEmpty()) {
+ name = "N/A";
+ }
+ /*
+ * TODO: TBD - modify standardName
+ */
+ // named.setStandardName(name);
+ named.setDisplayName(name);
+ named.getName().add(name);
+ }
+ /**
+ * Convert a SBML ModifierSpeciesReference to a BioPAX Control Interaction.
+ *
+ * @param bpModel - The BioPAX Model to store the Control Interaction that was converted from the given SBML ModifierSpeciesReference.
+ * @param modifierSpeciesReference - The SBML ModifierSpeciesReference to be converted to a BioPAX Control Interaction
+ * @return The converted BioPAX Control Interaction
+ */
+ public Control convertModifier(Model bpModel, ModifierSpeciesReference modifierSpeciesReference) {
+ // Interesting enough, these reference objects don't have an ID associated with them
+ // That is why we are using hashcodes to generate unique BioPAX ID.
+ String id = completeId(modifierSpeciesReference.getId());
+
+ Control control = null;
+
+ //Check what type of control is this modifier
+ String controlName = modifierSpeciesReference.getName();
+ if(controlName != null && !controlName.isEmpty())
+ {
+ if(controlName.contains("Modulation"))
+ {
+ control = createBPEfromSBMLE(bpModel, Modulation.class, modifierSpeciesReference, id);
+ }
+ else if(controlName.contains("TemplateReactionRegulation"))
+ {
+ control = createBPEfromSBMLE(bpModel, TemplateReactionRegulation.class, modifierSpeciesReference, id);
+ }
+ else
+ {
+ control = createBPEfromSBMLE(bpModel, Control.class, modifierSpeciesReference, id);
+ }
+ }
+ else
+ {
+ control = createBPEfromSBMLE(bpModel, Control.class, modifierSpeciesReference, id);
+ }
+
+ switch (modifierSpeciesReference.getSBOTerm()) {
+ case 21:
+ control.setControlType(ControlType.ACTIVATION);
+ break;
+ case 636:
+ control.setControlType(ControlType.ACTIVATION_ALLOSTERIC);
+ break;
+ case 637:
+ control.setControlType(ControlType.ACTIVATION_NONALLOSTERIC);
+ break;
+ case 20:
+ control.setControlType(ControlType.INHIBITION);
+ break;
+ case 207:
+ control.setControlType(ControlType.INHIBITION_NONCOMPETITIVE);
+ break;
+ case 206:
+ control.setControlType(ControlType.INHIBITION_COMPETITIVE);
+ break;
+ case 638:
+ control.setControlType(ControlType.INHIBITION_IRREVERSIBLE);
+ break;
+ case 639:
+ control.setControlType(ControlType.INHIBITION_ALLOSTERIC);
+ break;
+ // case 20:
+ // control.setControlType(ControlType.INHIBITION_OTHER);
+ // break;
+ case 640:
+ control.setControlType(ControlType.INHIBITION_UNCOMPETITIVE);
+ break;
+ default:
+ control.setControlType(ControlType.ACTIVATION);
+ break;
+ }
- public <T extends Named> T createBPEfromSBMLE(Model bpModel, Class<T> aClass, AbstractNamedSBase abstractNamedSBase, String bpId) {
- T entity = (T) bpModel.getByID(bpId);
- if(entity == null) {
- entity = bioPAXFactory.create(aClass, bpId);
- setNames(abstractNamedSBase, entity);
- //TODO: future implementation for setting entity.comment(). Currently not supported in BioPAX2SBML
-// setComments(abstractNamedSBase, entity);
- bpModel.add(entity);
- }
+ return control;
+ }
- return entity;
- }
+ public <T extends SimplePhysicalEntity, S extends EntityReference> T convertSpeciesToSPE(Model bpModel, Class<T> entityClass, Class<S> refClass, Species species) {
+ Set<Xref> xrefs = generateXrefsForSBase(bpModel, UnificationXref.class, species);
+ HashSet<XReferrable> ers = new HashSet<XReferrable>();
+ for (Xref xref : xrefs) {
+ for (XReferrable xReferrable : xref.getXrefOf()) {
+ // Only add the entity references
+ if(xReferrable instanceof EntityReference) {
+ ers.add(xReferrable);
+ }
+ }
+ }
- private <T extends Named> void setComments(AbstractNamedSBase abstractNamedSBase, T entity) {
- try {
- // Strip out html tags
- entity.addComment(abstractNamedSBase.getNotesString().replaceAll("\\<[^>]*>",""));
- } catch (XMLStreamException e) {
- log.warn("Problem parsing the notes XML: " + e.getLocalizedMessage());
- }
- }
+ S reference;
+ if(ers.isEmpty()) {
+ reference = createBPEfromSBMLE(bpModel, refClass, species, completeId("ref_" + species.getId()));
+ for (Xref xref : xrefs) {
+ reference.addXref(xref);
+ }
+ } else if(ers.size() == 1) { // There shouldn't be more than one
+ reference = (S) ers.iterator().next();
+ } else {
+ log.warn(
+ "There are more than one EntityReferences that match with the same unification xref for species: "
+ + species.getName()
+ + ". Picking the first one: "
+ + ers.iterator().next().getRDFId()
+ );
- /**
- * Convert SBML Species to BioPAX Entity
- *
- * @param bpModel - The BioPAX Model to store the Entity that was converted from the given SBML Species.
- * @param species - The SBML Species to be converted to a BioPAX Physical Entities
- * @return The converted BioPAX Physical Entity
- */
- public Entity convertSpecies(Model bpModel, Species species) {
- PhysicalEntity physicalEntity = null;
- Entity entity = null;
- boolean isPhysicalEntity = true;
-
- switch (species.getSBOTerm()) {
- case 243: //Gene
- entity = convertGeneFromSpecies(bpModel, species);
- isPhysicalEntity = false;
- break;
- case 253: // Complex
- physicalEntity = createComplexFromSpecies(bpModel, species);
- break;
- case 252: // Protein
- physicalEntity = convertSpeciesToSPE(bpModel, Protein.class, ProteinReference.class, species);
- break;
- case 251: // DNA
- physicalEntity = convertSpeciesToSPE(bpModel, Dna.class, DnaReference.class, species);
- break;
- case 634: // DNA Region
- physicalEntity = convertSpeciesToSPE(bpModel, DnaRegion.class, DnaRegionReference.class, species);
- break;
- case 250: // RNA
- physicalEntity = convertSpeciesToSPE(bpModel, Rna.class, RnaReference.class, species);
- break;
- case 635: // RNA Region
- physicalEntity = convertSpeciesToSPE(bpModel, Rna.class, RnaReference.class, species);
- break;
- case 247: // Small Molecule
- physicalEntity = convertSpeciesToSPE(bpModel, SmallMolecule.class, SmallMoleculeReference.class, species);
- break;
- default: // Physical Entity TODO: how to default to physical entity?
- physicalEntity = convertSpeciesToSPE(bpModel, SimplePhysicalEntity.class, EntityReference.class, species);
- break;
- }
-
- if(!isPhysicalEntity){
- return entity;
- }
-
- CellularLocationVocabulary cellularLocationVocabulary = createCompartment(bpModel, species.getCompartmentInstance());
- physicalEntity.setCellularLocation(cellularLocationVocabulary);
-
-
- return physicalEntity;
- }
+ reference = (S) ers.iterator().next();
+ }
- /**
- * Convert SBML Compartment to BioPAX CellularLocationVocabulary
- *
- * @param bpModel - The BioPAX Model to store the CellularLocationVocabulary that was converted from the given SBML Compartments.
- * @param compartment - The SBML Compartment to be converted to a BioPAX CellularLocationVocabulary
- * @return The converted BioPAX CellularLocationVocabulary
- */
- public CellularLocationVocabulary createCompartment(Model bpModel, Compartment compartment) {
- String id = completeId(compartment.getId());
- CellularLocationVocabulary cellularLocationVocabulary = (CellularLocationVocabulary) bpModel.getByID(id);
- if(cellularLocationVocabulary == null) {
- cellularLocationVocabulary = bioPAXFactory.create(CellularLocationVocabulary.class, id);
- cellularLocationVocabulary.addTerm(compartment.getName());
- for (Xref xref : generateXrefsForSBase(bpModel, UnificationXref.class, compartment)) {
- cellularLocationVocabulary.addXref(xref);
- }
- bpModel.add(cellularLocationVocabulary);
- }
+ T entity = createBPEfromSBMLE(bpModel, entityClass, species);
+ entity.setEntityReference(reference);
- return cellularLocationVocabulary;
- }
+ // Clean-up non-used xrefs
+ for (Xref xref : xrefs) {
+ if(xref.getXrefOf().isEmpty()) {
+ bpModel.remove(xref);
+ }
+ }
- /**
- * Convert SBML Species to BioPAX Complex Physical Entity
- *
- * @param bpModel - The BioPAX Model to store the Complex Physical Entity that was converted from the given SBML Species.
- * @param species - The SBML Species to be converted to a BioPAX Complex Physical Entities
- * @return The converted BioPAX Complex Physical Entity
- */
- private Complex createComplexFromSpecies(Model bpModel, Species species) {
- Complex complex = createBPEfromSBMLE(bpModel, Complex.class, species);
- for (Xref xref : generateXrefsForSBase(bpModel, RelationshipXref.class, species)) {
- complex.addXref(xref);
- }
+ return entity;
+ }
- return complex;
- }
+ private <T extends Xref> T resourceToXref(Class<T> xrefClass, String xrefId, String resource) {
+ // using the miriam common library to get the id and database String regardless of the form of the URI.
- /**
- * Convert SBML Species to BioPAX Gene Physical Entity
- *
- * @param bpModel - The BioPAX Model to store the Gene that was converted from the given SBML Species.
- * @param species - The SBML Species to be converted to a BioPAX Gene Entity
- * @return The converted BioPAX Gene
- */
- public Gene convertGeneFromSpecies(Model bpModel, Species species) {
- Gene gene = createBPEfromSBMLE(bpModel, Gene.class, species);
- for (Xref xref : generateXrefsForSBase(bpModel, UnificationXref.class, species)) {
- gene.addXref(xref);
- }
+ T xref = bioPAXFactory.create(xrefClass, xrefId);
+ String idToken = RegistryUtilities.getElementPart(resource);
+ String dataBase = RegistryUtilities.getDataPart(resource);
+ DataType datatype = RegistryUtilities.getDataType(dataBase);
- return gene;
- }
-
- private <T extends Xref> Set<Xref> generateXrefsForSBase(Model bpModel, Class<T> xrefClass, AbstractSBase sBase) {
- Annotation annotation = sBase.getAnnotation();
- HashSet<Xref> xrefs = new HashSet<Xref>();
+ if (datatype != null) {
+ dataBase = datatype.getName();
+ } else {
+ log.warn("Cannnot get Datatype for: " + resource);
+ }
- for (CVTerm cvTerm : annotation.getListOfCVTerms()) {
- for (String resource : cvTerm.getResources()) {
- String xrefId = completeId(xrefClass.getSimpleName().toLowerCase() + "_" + cvTerm.hashCode());
- // Let's not replicate xrefs if possible
- Xref xref = (Xref) bpModel.getByID(xrefId);
- if(xref == null) {
- if(resource.toLowerCase().contains("pubmed")) {
- xref = resourceToXref(PublicationXref.class, xrefId, resource);
- } else {
- xref = resourceToXref(xrefClass, xrefId, resource);
- }
- bpModel.add(xref);
- }
- xrefs.add(xref);
- }
- }
+ xref.setDb(dataBase);
+ xref.setId(idToken);
- return xrefs;
- }
+ return xref;
+ }
- public void fillComplexes(Model bpModel, org.sbml.jsbml.Model sbmlModel) {
- HashMap<String, ProteinReference> xrefToProtein = new HashMap<String, ProteinReference>();
- // Now let's use xrefs to find the complex components
- // First, find the proteinrefs and map them with their xrefs
- for (ProteinReference proteinRef : bpModel.getObjects(ProteinReference.class)) {
- for (Xref xref : proteinRef.getXref()) {
- xrefToProtein.put(xref.toString(), proteinRef);
- }
- }
+ public <T extends Named> T createBPEfromSBMLE(Model bpModel, Class<T> aClass, AbstractNamedSBase abstractNamedSBase) {
+ return createBPEfromSBMLE(bpModel, aClass, abstractNamedSBase, completeId(abstractNamedSBase.getId()));
+ }
- // We have to work with a map not to create concurrency problems
- // This will hold all new entities
- HashMap<String, BioPAXElement> newBPEs = new HashMap<String, BioPAXElement>();
- // Now let's go to the complexes and see what xrefs they have
- Set<Complex> complexes = new HashSet<Complex>(bpModel.getObjects(Complex.class));
- for (Complex complex : complexes) {
- HashSet<String> names = new HashSet<String>(Arrays.asList(complex.getDisplayName().split(":")));
+ public <T extends Named> T createBPEfromSBMLE(Model bpModel, Class<T> aClass, AbstractNamedSBase abstractNamedSBase, String bpId) {
+ T entity = (T) bpModel.getByID(bpId);
+ if(entity == null) {
+ entity = bioPAXFactory.create(aClass, bpId);
+ setNames(abstractNamedSBase, entity);
+ //TODO: future implementation for setting entity.comment(). Currently not supported in BioPAX2SBML
+ // setComments(abstractNamedSBase, entity);
+ bpModel.add(entity);
+ }
- // Let's try to capture proteins from the model first
- HashSet<Protein> components = new HashSet<Protein>();
- for (Xref xref : complex.getXref()) {
- ProteinReference proteinRef = xrefToProtein.get(xref.toString());
- if(proteinRef != null) {
- String cProteinId = completeId(complex.getRDFId() + "_" + proteinRef.getRDFId());
- Protein protein = bioPAXFactory.create(Protein.class, cProteinId);
- protein.setDisplayName(proteinRef.getDisplayName());
- protein.setStandardName(proteinRef.getStandardName());
- protein.setEntityReference(proteinRef);
- if(!bpModel.containsID(protein.getRDFId())) {
- components.add(protein);
- bpModel.add(protein);
- }
- names.remove(protein.getDisplayName());
- }
- }
+ return entity;
+ }
- // These are the ones we were not able to capture from the model
- // Let's create proteins for them
- for (String name : names) {
- String nameBasedURI = completeId("protein_" + name);
- Protein protein = bioPAXFactory.create(Protein.class, nameBasedURI);
- protein.setDisplayName(name);
- protein.setStandardName(name);
- newBPEs.put(nameBasedURI, protein);
+ private <T extends Named> void setComments(AbstractNamedSBase abstractNamedSBase, T entity) {
+ try {
+ // Strip out html tags
+ entity.addComment(abstractNamedSBase.getNotesString().replaceAll("\\<[^>]*>",""));
+ } catch (XMLStreamException e) {
+ log.warn("Problem parsing the notes XML: " + e.getLocalizedMessage());
+ }
+ }
- String refId = completeId("ref_" + nameBasedURI);
- ProteinReference proteinReference = (ProteinReference) newBPEs.get(refId);
- if(proteinReference == null) {
- proteinReference = bioPAXFactory.create(ProteinReference.class, refId);
- proteinReference.setDisplayName(name);
- proteinReference.setStandardName(name);
- newBPEs.put(refId, proteinReference);
- }
+ /**
+ * Convert SBML Species to BioPAX Entity
+ *
+ * @param bpModel - The BioPAX Model to store the Entity that was converted from the given SBML Species.
+ * @param species - The SBML Species to be converted to a BioPAX Physical Entities
+ * @return The converted BioPAX Physical Entity
+ */
+ public Entity convertSpecies(Model bpModel, Species species) {
+ PhysicalEntity physicalEntity = null;
+ Entity entity = null;
+ boolean isPhysicalEntity = true;
- String xrefId = completeId("symbol_" + name);
- UnificationXref unificationXref = (UnificationXref) newBPEs.get(xrefId);
- if(unificationXref == null) {
- unificationXref = bioPAXFactory.create(UnificationXref.class, xrefId);
- unificationXref.setDb("HGNC Symbol");
- unificationXref.setId(name);
- newBPEs.put(xrefId, unificationXref);
- }
+ switch (species.getSBOTerm()) {
+ case 243: //Gene
+ entity = convertSpeciesToE(bpModel, Gene.class, UnificationXref.class, species);
+ isPhysicalEntity = false;
+ break;
+ case 253: // Complex
+ physicalEntity = convertSpeciesToPE(bpModel, Complex.class, UnificationXref.class, species);
+ break;
+ case 252: // Protein
+ physicalEntity = convertSpeciesToSPE(bpModel, Protein.class, ProteinReference.class, species);
+ break;
+ case 251: // DNA
+ physicalEntity = convertSpeciesToSPE(bpModel, Dna.class, DnaReference.class, species);
+ break;
+ case 634: // DNA Region
+ physicalEntity = convertSpeciesToSPE(bpModel, DnaRegion.class, DnaRegionReference.class, species);
+ break;
+ case 250: // RNA
+ physicalEntity = convertSpeciesToSPE(bpModel, Rna.class, RnaReference.class, species);
+ break;
+ case 635: // RNA Region
+ physicalEntity = convertSpeciesToSPE(bpModel, Rna.class, RnaReference.class, species);
+ break;
+ case 247: // Small Molecule
+ physicalEntity = convertSpeciesToSPE(bpModel, SmallMolecule.class, SmallMoleculeReference.class, species);
+ break;
+ default: // Physical Entity
+ physicalEntity = convertSpeciesToPE(bpModel, PhysicalEntity.class, UnificationXref.clas...
[truncated message content] |