|
From: <tra...@us...> - 2016-07-02 07:01:22
|
Revision: 664
http://sourceforge.net/p/sbfc/code/664
Author: tramy-nguyen
Date: 2016-07-02 07:01:20 +0000 (Sat, 02 Jul 2016)
Log Message:
-----------
Completed javadoc to all methods in BiopAX2SBML.java
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-01 07:48:30 UTC (rev 663)
+++ trunk/src/org/sbfc/converter/biopax2sbml/BioPAX2SBML.java 2016-07-02 07:01:20 UTC (rev 664)
@@ -91,7 +91,7 @@
public class BioPAX2SBML extends GeneralConverter {
-
+ //Format how SBML notes are set
protected final static String notesStartString = "<notes><body xmlns=\"http://www.w3.org/1999/xhtml\">";
protected final static String notesEndString = "</body></notes>";
@@ -100,6 +100,7 @@
public static boolean isLetter(char c) { return ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)); }
public static boolean isDigit(char c) { return ((c >= 48) && (c <= 57)); }
+ //Indicate which SBML level and version to generate
protected final static int sbmlLevel = 3;
protected final static int sbmlVer = 1;
@@ -125,6 +126,25 @@
super();
}
+ /**
+ * Perform conversion between the provided BioPAXModel to an SBML Model. If the provided BioPAX model is a level
+ * 1 or 2 model, the model will be translated to level 3 before starting the conversion from BioPAX to SBML. The
+ * SBML file produced will be in SBML level 3 version 1.
+ *
+ * During the course of the conversion from BioPAX to SBML, all BioPAX PhysicalEntities are mapped to SBML Species.
+ * All BioPAX Control Interactions are mapped to SBML ModifierSpeciesReference
+ * All BioPAX Conversion Interactions and other Interactions that are not classified as Control or Conversion
+ * Interactions will be mapped to SBML Reactions with its corresponding SBML Reactants, Products and SpeciesReference.
+ *
+ * To retain the different types of PhysicalEntities and Interactions, these BioPAX entities are assigned to its
+ * corresponding SBO terms when creating the different SBML elements.
+ *
+ * @param biopaxmodel - The BioPAX model to be converted to an SBML model
+ * @return The SBML model generated from the conversion of the biopax model
+ * @throws SBMLException
+ * @throws ConversionException
+ * @throws ReadModelException
+ */
public SBMLModel sbmlExport(BioPAXModel biopaxmodel) throws SBMLException, ConversionException, ReadModelException {
//Keep track of the mapping between biopax RDFId to SBML id;
biopax2sbmlId = new HashMap<String, String>();
@@ -151,7 +171,7 @@
* first before parsing other biopax entities.
*/
org.sbml.jsbml.Model sbmlModel = parsePathways(bioModel, sbmlDoc);
- addSBMLHistory(sbmlModel);
+ addSBMLHistory(sbmlModel, sbmlOrganization);
addSBMLNotes(sbmlModel, "This model has been automatically generated by BioPAX2SBML");
parseEntities(bioModel, sbmlModel);
@@ -161,11 +181,11 @@
/**
* Create an SBML Model within the specified SBMLDocument from the given biopaxModel pathway.
- * If no pathway exist within the biopax model, a default sbml model will be created.
+ * If no pathway exist within the BioPAX model, a default SBML model will be created.
*
- * @param bioModel - The biomodel to get convert any existing pathway to an sbml model
- * @param sbmlDoc - The SBMLDocument to create the sbml model into.
- * @return The sbml model that was converted from a biopax pathway
+ * @param bioModel - The biomodel that contain pathway(s) to be converted to an SBML model
+ * @param sbmlDoc - The SBMLDocument to create the SBML model into.
+ * @return The SBML model that was converted from a BioPAX pathway
*/
private org.sbml.jsbml.Model parsePathways(org.biopax.paxtools.model.Model bioModel, SBMLDocument sbmlDoc)
{
@@ -193,8 +213,8 @@
}
/**
- * Converts the given Pathway to an sbml model within the given SBMLDocument.
- * If no pathway exist and the pathway parameter is set to null, then a default sbml model is created
+ * Converts the given Pathway to an SBML model within the given SBMLDocument.
+ * If no pathway exist and the pathway parameter is null, then a default SBML model is created
*
* @param pathway - The pathway to be converted to an SBML model
* @param sbmlDoc - The SBMLDocument to store the SBML model
@@ -237,11 +257,17 @@
return sbmlModel;
}
- private void addSBMLHistory(org.sbml.jsbml.Model sbmlModel)
+ /**
+ * Inserts the history of where or whom this SBML model is generated from
+ *
+ * @param sbmlModel - The SBMLModel to add the SBML history in
+ * @param organization - The name of the organization that generated this SBML model
+ */
+ private void addSBMLHistory(org.sbml.jsbml.Model sbmlModel, String organization)
{
History hist = new History();
Creator creator = new Creator();
- creator.setOrganisation(sbmlOrganization);
+ creator.setOrganisation(organization);
hist.addCreator(creator);
setAnnotation(sbmlModel);
@@ -249,6 +275,10 @@
sbmlModel.setHistory(hist);
}
+ /**
+ * TODO:
+ * @param sbmlModel
+ */
private void setAnnotation(org.sbml.jsbml.Model sbmlModel)
{
//TODO: this is only creating an annotation but not adding any information to the annotation
@@ -256,6 +286,12 @@
sbmlModel.setAnnotation(annot);
}
+ /**
+ * Add the provided notes to the provided SBML model
+ *
+ * @param sbmlModel - The SBML model to add the notes to
+ * @param sbmlNotes - The notes to be added to the SBML model
+ */
private void addSBMLNotes(org.sbml.jsbml.Model sbmlModel, String sbmlNotes)
{
StringBuffer notes = new StringBuffer(notesStartString);
@@ -272,6 +308,14 @@
}
}
+ /**
+ * 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
{
/*
@@ -297,6 +341,13 @@
parseInteractions(sbmlModel, listOfConversions, listOfControls, listOfInteractions);
}
+ /**
+ * 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
+ */
private void parseEntity(Entity entity, org.sbml.jsbml.Model sbmlModel)
{
String speciesId = getValidSBMLId(entity);
@@ -310,10 +361,18 @@
{
setEntity_SBO(entity, sbmlSpecies);
}
-
-
}
+ /**
+ * Generate a valid SBML name if the given biopax entity contains a valid display name.
+ * If the entity does not contain a display name, this method will then check if the provided entity contains a name
+ * or RDFId to use.
+ *
+ * If the entity does not contain a display name, name or RDFId, then null will be returned.
+ *
+ * @param entity - the biopax entity where the SBML name is retrieved from
+ * @return
+ */
private String getValidSBMLName(BioPAXElement entity)
{
if(entity instanceof org.biopax.paxtools.model.level3.Named)
@@ -337,6 +396,11 @@
return null;
}
+ /**
+ * Return a valid SBML id from the provided biopax entity.
+ * @param entity - the biopax entity where the valid SBML id is be retrieved from
+ * @return
+ */
private String getValidSBMLId(BioPAXElement entity)
{
String RDFId = entity.getRDFId();
@@ -362,6 +426,15 @@
return newSBMLId;
}
+ /**
+ * Replace any invalid char in the given string with valid SBML char id. Specifically,
+ * all invalid char will be replaced with an underscore char '_'. If the newly generated
+ * id is already in use in the conversion for the SBML document, then a constant integer is
+ * appended to the end of the generated id until a valid SBML id can used for the conversion.
+ *
+ * @param id - The invalid SBML id to be replaced
+ * @return
+ */
private String replaceInvalidSBMLcharId(String id)
{
String result = id;
@@ -392,7 +465,16 @@
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
+ */
private Species setSpecies(org.sbml.jsbml.Model sbmlModel, String speciesId, Entity entity)
{
Species sbmlSpecies = sbmlModel.createSpecies(speciesId, setCompartment(sbmlModel, entity));
@@ -439,6 +521,15 @@
return true;
}
+ /**
+ * 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
+ */
private Compartment setCompartment(org.sbml.jsbml.Model sbmlModel, Entity entity)
{
/*
@@ -503,7 +594,12 @@
return defaultCompartment;
}
-
+ /**
+ * Set the provided SBML species with its corresponding SBO term based on the given PhysicalEntity.
+ *
+ * @param entity - The physical entity used to assign the SBO terms
+ * @param sbmlSpecies - The SBML species where the SBO term will be assigned to
+ */
private void setPhysicalEntity_SBO(PhysicalEntity entity, org.sbml.jsbml.Species sbmlSpecies)
{
if (entity instanceof Complex)
@@ -541,6 +637,12 @@
}
}
+ /**
+ * Set the provided SBML species with its corresponding SBO term based on the given Entity.
+ *
+ * @param entity - The entity used to assign the SBO terms
+ * @param sbmlSpecies - The SBML species where the SBO term will be assigned to
+ */
private void setEntity_SBO(Entity entity, org.sbml.jsbml.Species sbmlSpecies)
{
if (entity instanceof Gene)
@@ -553,6 +655,15 @@
}
}
+ /**
+ * 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
{
/*
@@ -574,13 +685,26 @@
}
-
+ /**
+ * Convert the provided interaction to a SBML reaction.
+ * The reaction that is created is assigned with an SBO term corresponding to the given biopax interaction.
+ * The SBML reaction will then be stored in the provided SBML model
+ *
+ * @param entity - The interaction to be converted to an SBML reaction
+ * @param sbmlModel - The SBML model that contains the generated reaction
+ */
private void parsePhysicalInteraction(Interaction entity, org.sbml.jsbml.Model sbmlModel)
{
Reaction reaction = setReaction(entity, sbmlModel);
setInteraction_SBO(entity, reaction);
}
+ /**
+ * Assign the given SBML reaction with its corresponding SBO terms determined by the given biopax interaction
+ *
+ * @param entity - the interaction to assign the reaction SBO terms
+ * @param reaction - the reaction where the SBO term will be assigned to
+ */
private void setInteraction_SBO(Interaction entity, Reaction reaction)
{
if (entity instanceof TemplateReaction)
@@ -601,6 +725,15 @@
}
}
+ /**
+ * 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);
@@ -611,11 +744,11 @@
reaction.setReversible(true);
//Parse for reactant/substrate
- ListOf<SpeciesReference> reactants = getSpeciesReferences(conversion.getLeft(), conversion.getParticipantStoichiometry(), sbmlModel);
+ ListOf<SpeciesReference> reactants = getSpeciesReferences(conversion.getLeft(), conversion.getParticipantStoichiometry());
reaction.setListOfReactants(reactants);
//Parse for product
- ListOf<SpeciesReference> products = getSpeciesReferences(conversion.getRight(), conversion.getParticipantStoichiometry(), sbmlModel);
+ ListOf<SpeciesReference> products = getSpeciesReferences(conversion.getRight(), conversion.getParticipantStoichiometry());
reaction.setListOfProducts(products);
}
else if( conversion.getConversionDirection() != null && (conversion.getConversionDirection().equals(ConversionDirectionType.RIGHT_TO_LEFT)))
@@ -623,17 +756,24 @@
reaction.setReversible(false);
//Parse for reactant/substrate
- ListOf<SpeciesReference> reactants = getSpeciesReferences(conversion.getRight(), conversion.getParticipantStoichiometry(), sbmlModel);
+ ListOf<SpeciesReference> reactants = getSpeciesReferences(conversion.getRight(), conversion.getParticipantStoichiometry());
reaction.setListOfReactants(reactants);
//Parse for product
- ListOf<SpeciesReference> products = getSpeciesReferences(conversion.getLeft(), conversion.getParticipantStoichiometry(), sbmlModel);
+ ListOf<SpeciesReference> products = getSpeciesReferences(conversion.getLeft(), conversion.getParticipantStoichiometry());
reaction.setListOfProducts(products);
}
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
@@ -643,6 +783,16 @@
parseControllerInteraction(control, controlledReactionList);
}
+ /**
+ * Create ModifierSpeciesReference from the controller interactions found within the given control interaction.
+ * The ModifierSpeciesReference created are stored within the given list of reactions.
+ * For each ModifierSpeciesReference that are created, SBO terms are associated based on the controlType found
+ * within the given control interaction.
+ *
+ * @param control - The Control Interaction that holds the controller interaction parsed for the SBML ModifierSpeciesReference
+ * @param controlledReactionList - Holds the list of reactions to add the ModifierSpeciesReference to
+ * @throws ConversionException
+ */
private void parseControllerInteraction(Control control, List<Reaction> controlledReactionList) throws ConversionException
{
Set<Controller> controllerList = control.getController();
@@ -673,6 +823,12 @@
}
}
+ /**
+ * Assign the given SBML ModifierSpeciesReference with its corresponding SBO terms determined by the given biopax control interaction
+ *
+ * @param control - the control interaction to assign the SBO terms
+ * @param modifierSpecies - the reaction where the SBO term will be assigned to
+ */
private void setControl_SBO(Control control, ModifierSpeciesReference modifierSpecies)
{
if (Catalysis.class.isAssignableFrom(control.getClass()))
@@ -692,6 +848,12 @@
}
}
+ /**
+ * Assign the given SBML ModifierSpeciesReference with its corresponding SBO terms determined by the given biopax controlType interaction
+ *
+ * @param controlType - the ControlType to assign the SBO terms
+ * @param modifierSpecies - the reaction where the SBO term will be assigned to
+ */
private void setControlType_SBO(ControlType controlType, ModifierSpeciesReference modifierSpecies)
{
if(controlType.equals(ControlType.ACTIVATION))
@@ -736,6 +898,14 @@
}
}
+ /**
+ * 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
+ * @throws ConversionException
+ */
private List<Reaction> parseControlledInteraction(Control control,
org.sbml.jsbml.Model sbmlModel) throws ConversionException
{
@@ -762,9 +932,17 @@
return controlledReactionList;
}
-
+ /**
+ * Returns a list of SpeciesReference created for each given PhysicalEntity if it does not already exist in the given SBML model.
+ * If a Stoichiometry value is found within the given PhysicalEntity, then the SBML species stoichiometry value is set to the corresponding SpeciesReference
+ *
+ * @param participants - The list of PhysicalEntity to translate into SpeciesReference
+ * @param stoichiometrySet - The list of stoichiometry values that the SpeciesReference could be set to.
+ * @return
+ * @throws ConversionException
+ */
private ListOf<org.sbml.jsbml.SpeciesReference> getSpeciesReferences(Set<PhysicalEntity> participants,
- Set<Stoichiometry> stoichiometrySet, org.sbml.jsbml.Model sbmlModel) throws ConversionException
+ Set<Stoichiometry> stoichiometrySet) throws ConversionException
{
ListOf<SpeciesReference> speciesReferencesList = new ListOf<SpeciesReference>();
@@ -800,6 +978,14 @@
return speciesReferencesList;
}
+ /**
+ * Returns the correct Stoichiometry value related to the given PhysicalEntity
+ * The value zero will be returned to indicate that no stoichiometry value exists for the given PhysicalEntity
+ *
+ * @param stoichiometrySet - The set of Stoichiometry values to search through
+ * @param entity - The entity that the Stoichiometry should match to
+ * @return
+ */
private double getSpeciesStochiometry(Set<Stoichiometry> stoichiometrySet, PhysicalEntity entity)
{
for (Stoichiometry stoichiometry : stoichiometrySet)
@@ -817,12 +1003,27 @@
return 0;
}
+ /**
+ * Return true if the given stoichiometry value is within range to represent the stoichiometry values for the conversion.
+ * Since the stoichiometry is respresented as a Double value, the stoichiometry value parsed should not exceed this range.
+ * Return false, if the stoichiometry is out of bound of the conversion representation for stoichiometry values
+ *
+ * @param stoichiometry - The stoichiometry value to be checked.
+ * @return
+ */
private boolean isValidStoichiometry(double stoichiometry)
{
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
+ */
private Reaction setReaction(Interaction entity, org.sbml.jsbml.Model sbmlModel)
{
Reaction reaction = sbmlModel.createReaction(getValidSBMLId(entity));
@@ -843,7 +1044,12 @@
return reaction;
}
-
+ /**
+ * Assign the given SBML Reaction with its corresponding SBO terms determined by the given biopax Conversion Interaction
+ *
+ * @param entity - The Conversion interaction to assign the SBO terms
+ * @param reaction - The reaction where the SBO term will be assigned to
+ */
private void setConversion_SBO(Conversion entity, Reaction reaction)
{
if (entity instanceof ComplexAssembly)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|