Bound/Unbound option is now available and works

This commit is contained in:
LukasBuecherl 2022-07-20 09:26:09 -06:00
parent b8cad2fe48
commit 927062edeb
2 changed files with 391 additions and 201 deletions

View file

@ -106,7 +106,6 @@ public class Converter {
System.err.println("\t -env <SBML environment file> is the complete directory path of the environmental file to instantiate to your model. This only works when VPR model generator is used");
System.err.println("\t-Cello This option is for dynamic modeling of Cello parts and parametrization");
System.err.println("\t-tmID Set the ID of the top SBML model");
System.err.println("\t-prism SBOL to PRISM converter");
System.exit(1);
}
@ -140,6 +139,7 @@ public class Converter {
boolean isValidation = false; //indicate if only validate SBOL files
boolean topEnvir = false; // determines if there is a topEnvironment model to be instantiated
boolean CelloModel = false; // determines if Cello-based modeling should be done
boolean PrismUnbound = true; // determines if the prism model should be bound or unbound
String compFileResult = ""; //-cf
String compareFile = ""; //-e
@ -191,6 +191,9 @@ public class Converter {
case "-t":
typesInURI = true;
break;
case "-bound":
PrismUnbound = false;
break;
case "-s":
if(index+1 >= args.length || args[index+1].equals("-"))
{
@ -427,7 +430,7 @@ public class Converter {
try
{
inputSBMLDoc = SBMLutilities.readSBML(fullInputFileName, null, null);
SBML2PRISM.convertSBML2PRISM(inputSBMLDoc, fullInputFileName);
SBML2PRISM.convertSBML2PRISM(inputSBMLDoc, fullInputFileName, PrismUnbound);
}
catch (XMLStreamException e)
{

View file

@ -68,256 +68,443 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.SBMLutilities;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
/**
* Perform conversion from SBML to PRISM.
* Perform conversion from SBML to PRISM.
*
* @author Lukas Buecherl
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim
* Contributors </a>
* @version %I%
*/
public class SBML2PRISM {
/*
* Convert SBML to Prism
* Input: SBMLDocument, File
* Output: void
* Convert SBML to Prism Input: SBMLDocument, File Output: void
*
* Function takes in a SBML document and writes the prism conversion of the file in the same directory. The function also translates the constraint into
* a properties file that is written in the same directory in a separate file. The original filename is used for the prism and property file. The SBMML
* file ends in .xml, the prism file in .sm, and the properties file in .props.
* Function takes in a SBML document and writes the prism conversion of the file
* in the same directory. The function also translates the constraint into a
* properties file that is written in the same directory in a separate file. The
* original filename is used for the prism and property file. The SBMML file
* ends in .xml, the prism file in .sm, and the properties file in .props.
*
* To run the converter use the following command:
* java -jar conversion/target/iBioSim-conversion-3.1.0-SNAPSHOT-jar-with-dependencies.jar -l PRISM YOURSBMLFILE.xml
* To run the converter use the following command: java -jar
* conversion/target/iBioSim-conversion-3.1.0-SNAPSHOT-jar-with-dependencies.jar
* -l PRISM YOURSBMLFILE.xml
*/
public static void convertSBML2PRISM(SBMLDocument sbmlDoc, String filename) throws IOException
{
public static void convertSBML2PRISM(SBMLDocument sbmlDoc, String filename, boolean unbound) throws IOException {
if (unbound) {
convertSBML2PRISMUnbound(sbmlDoc, filename);
} else {
convertSBML2PRISMbound(sbmlDoc, filename);
}
}
private static void convertSBML2PRISMUnbound(SBMLDocument sbmlDoc, String filename) throws IOException {
Model model = sbmlDoc.getModel();
File file = new File(filename.replace(".xml", ".sm"));
// Opening and writing preamble to the file
FileWriter out = new FileWriter(file);
out.write("// File generated by SBML-to-PRISM converter\n");
out.write("// Original file: " + filename + "\n");
out.write("// @GeneticLogicLab\n");
out.write("\n");
out.write("ctmc\n");
out.write("\n");
out.write("// const int MAX_AMOUNT = ADD VALUE \n");
out.write("\n");
// Identify compartments and their size
out.write("// Compartment size\n");
for (int i = 0; i < model.getCompartmentCount(); i++)
{
Compartment compartment = model.getCompartment(i);
out.write("const double " + checkReservedKeywordPrism(compartment.getId()) + " = " + compartment.getSize() + ";\n");
}
out.write("\n");
// Identify model parameters
out.write("// Model parameters\n");
for (int i = 0; i < model.getParameterCount(); i++)
{
Parameter parameter = model.getParameter(i);
out.write("const double "+ checkReservedKeywordPrism(parameter.getId()) + " = " + parameter.getValue() +"; // " + parameter.getName() + "\n"); // if not null name
}
out.write("\n");
// Identify model species
for (int i = 0; i < model.getSpeciesCount(); i++)
{
// Write out syntax
// For function checkReservedKeywordPrism see below
Species species = model.getSpecies(i);
out.write("// Species " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("// const int " + checkReservedKeywordPrism(species.getId()) + "_MAX = MAX_AMOUNT;\n");
out.write("module "+ checkReservedKeywordPrism(species.getId()) + "\n");
out.write("\n");
out.write(" // "+ checkReservedKeywordPrism(species.getId()) +" : " + "[0.." + checkReservedKeywordPrism(species.getId()) + "_MAX] init "+ (int) species.getInitialAmount() + ";\n");
out.write(" "+ checkReservedKeywordPrism(species.getId()) + " : " + "int init " + (int) (species.getInitialAmount()) + ";\n");
out.write("\n");
// Iterate over reactions
for (int j = 0; j < model.getReactionCount(); j++)
{
Reaction reaction = model.getReaction(j);
// Identify reactants and products
SpeciesReference reactant = reaction.getReactantForSpecies(species.getId());
SpeciesReference product = reaction.getProductForSpecies(species.getId());
if(reactant != null)
{
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + "\n");
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] " + checkReservedKeywordPrism(species.getId()) + " > " + (int) (reactant.getStoichiometry() - 1) + " -> (" + checkReservedKeywordPrism(species.getId()) + "\'=" + checkReservedKeywordPrism(species.getId()) + "-" + (int) reactant.getStoichiometry() + ");\n");
} else if (product != null)
{
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + "\n");
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] " + checkReservedKeywordPrism(species.getId()) + " >= " + "0 -> (" + checkReservedKeywordPrism(species.getId()) + "\'=" + checkReservedKeywordPrism(species.getId()) + "+" + (int) product.getStoichiometry() + ");\n");
}
}
out.write("\n");
out.write("endmodule\n");
out.write("\n");
}
// Identify reaction rate
out.write("// Reaction rates\n");
out.write("module reaction_rates\n");
// Opening and writing preamble to the file
FileWriter out = new FileWriter(file);
out.write("// File generated by SBML-to-PRISM converter\n");
out.write("// Original file: " + filename + "\n");
out.write("// @GeneticLogicLab\n");
out.write("\n");
out.write("ctmc\n");
out.write("\n");
out.write("// const int MAX_AMOUNT = ADD VALUE \n");
out.write("\n");
// Identify compartments and their size
out.write("// Compartment size\n");
for (int i = 0; i < model.getCompartmentCount(); i++) {
Compartment compartment = model.getCompartment(i);
out.write("const double " + checkReservedKeywordPrism(compartment.getId()) + " = " + compartment.getSize()
+ ";\n");
}
out.write("\n");
// Identify model parameters
out.write("// Model parameters\n");
for (int i = 0; i < model.getParameterCount(); i++) {
Parameter parameter = model.getParameter(i);
out.write("const double " + checkReservedKeywordPrism(parameter.getId()) + " = " + parameter.getValue()
+ "; // " + parameter.getName() + "\n"); // if not null name
}
out.write("\n");
// Identify model species
for (int i = 0; i < model.getSpeciesCount(); i++) {
// Write out syntax
// For function checkReservedKeywordPrism see below
Species species = model.getSpecies(i);
out.write("// Species " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("// const int " + checkReservedKeywordPrism(species.getId()) + "_MAX = MAX_AMOUNT;\n");
out.write("module " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("\n");
for (int i = 0; i < model.getReactionCount(); i++)
{
Reaction reaction = model.getReaction(i);
// Write state transitions
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + ": -> ");
for(int j = 0; j < reaction.getProductCount(); j++)
{
out.write(checkReservedKeywordPrism(reaction.getProduct(j).getSpecies()) + " ");
out.write(" // " + checkReservedKeywordPrism(species.getId()) + " : " + "[0.."
+ checkReservedKeywordPrism(species.getId()) + "_MAX] init " + (int) species.getInitialAmount()
+ ";\n");
out.write(" " + checkReservedKeywordPrism(species.getId()) + " : " + "int init "
+ (int) (species.getInitialAmount()) + ";\n");
out.write("\n");
// Iterate over reactions
for (int j = 0; j < model.getReactionCount(); j++) {
Reaction reaction = model.getReaction(j);
// Identify reactants and products
SpeciesReference reactant = reaction.getReactantForSpecies(species.getId());
SpeciesReference product = reaction.getProductForSpecies(species.getId());
if (reactant != null) {
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + "\n");
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] "
+ checkReservedKeywordPrism(species.getId()) + " > "
+ (int) (reactant.getStoichiometry() - 1) + " -> ("
+ checkReservedKeywordPrism(species.getId()) + "\'="
+ checkReservedKeywordPrism(species.getId()) + "-" + (int) reactant.getStoichiometry()
+ ");\n");
} else if (product != null) {
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + "\n");
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] "
+ checkReservedKeywordPrism(species.getId()) + " >= " + "0 -> ("
+ checkReservedKeywordPrism(species.getId()) + "\'="
+ checkReservedKeywordPrism(species.getId()) + "+" + (int) product.getStoichiometry()
+ ");\n");
}
out.write("\n");
// Get the math for the reaction rate
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] " + checkReserveKeywordMath(SBMLutilities.convertMath2PrismProperty(reaction.getKineticLaw().getMath()), model) + " > 0 -> " + "(" + checkReserveKeywordMath(SBMLutilities.convertMath2PrismProperty(reaction.getKineticLaw().getMath()), model) + ") : true;\n");
out.write("\n");
}
out.write("\n");
out.write("endmodule\n");
out.write("\n");
// Identify rewards
out.write("// Reward structures (one per species)");
out.write("\n");
for (int i = 0; i < model.getSpeciesCount(); i++)
{
Species species = model.getSpecies(i);
out.write("// Reward " + (i+1) + ": " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("rewards " + "\"" + checkReservedKeywordPrism(species.getId()) + "\" true : " + checkReservedKeywordPrism(species.getId()) + "; endrewards\n");
}
}
out.close();
// Write Properties File
File property = new File(filename.replace(".xml", ".props"));
FileWriter property_out = new FileWriter(property);
// Property preamble
property_out.write("// File generated by SBML-to-PRISM converter\n");
property_out.write("// Original file: " + filename + "\n");
property_out.write("// @GeneticLogicLab\n");
property_out.write("\n");
for (int i = 0; i < model.getConstraintCount(); i++)
{
// Get and write translation of constraint
property_out.write(checkReserveKeywordMath(SBMLutilities.convertMath2PrismProperty(model.getConstraint(i).getMath()), model));
// Identify reaction rate
out.write("// Reaction rates\n");
out.write("module reaction_rates\n");
out.write("\n");
for (int i = 0; i < model.getReactionCount(); i++) {
Reaction reaction = model.getReaction(i);
// Write state transitions
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + ": -> ");
for (int j = 0; j < reaction.getProductCount(); j++) {
out.write(checkReservedKeywordPrism(reaction.getProduct(j).getSpecies()) + " ");
}
property_out.close();
out.write("\n");
// Get the math for the reaction rate
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] "
+ checkReserveKeywordMath(
SBMLutilities.convertMath2PrismProperty(reaction.getKineticLaw().getMath()), model)
+ " > 0 -> " + "("
+ checkReserveKeywordMath(
SBMLutilities.convertMath2PrismProperty(reaction.getKineticLaw().getMath()), model)
+ ") : true;\n");
out.write("\n");
}
out.write("endmodule\n");
out.write("\n");
// Identify rewards
out.write("// Reward structures (one per species)");
out.write("\n");
for (int i = 0; i < model.getSpeciesCount(); i++) {
Species species = model.getSpecies(i);
out.write("// Reward " + (i + 1) + ": " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("rewards " + "\"" + checkReservedKeywordPrism(species.getId()) + "\" true : "
+ checkReservedKeywordPrism(species.getId()) + "; endrewards\n");
}
out.close();
// Write Properties File
File property = new File(filename.replace(".xml", ".props"));
FileWriter property_out = new FileWriter(property);
// Property preamble
property_out.write("// File generated by SBML-to-PRISM converter\n");
property_out.write("// Original file: " + filename + "\n");
property_out.write("// @GeneticLogicLab\n");
property_out.write("\n");
for (int i = 0; i < model.getConstraintCount(); i++) {
// Get and write translation of constraint
property_out.write(checkReserveKeywordMath(
SBMLutilities.convertMath2PrismProperty(model.getConstraint(i).getMath()), model));
}
property_out.close();
}
private static void convertSBML2PRISMbound(SBMLDocument sbmlDoc, String filename) throws IOException {
Model model = sbmlDoc.getModel();
File file = new File(filename.replace(".xml", ".sm"));
// Opening and writing preamble to the file
FileWriter out = new FileWriter(file);
out.write("// File generated by SBML-to-PRISM converter\n");
out.write("// Original file: " + filename + "\n");
out.write("// @GeneticLogicLab\n");
out.write("\n");
out.write("ctmc\n");
out.write("\n");
double maxAmount = 0.0;
for (int i = 0; i < model.getSpeciesCount(); i++) {
Species species = model.getSpecies(i);
if (species.getInitialAmount() > maxAmount) {
maxAmount = species.getInitialAmount();
}
}
out.write(" const int MAX_AMOUNT = " + (int) maxAmount + ";\n");
out.write("\n");
// Identify compartments and their size
out.write("// Compartment size\n");
for (int i = 0; i < model.getCompartmentCount(); i++) {
Compartment compartment = model.getCompartment(i);
out.write("const double " + checkReservedKeywordPrism(compartment.getId()) + " = " + compartment.getSize()
+ ";\n");
}
out.write("\n");
// Identify model parameters
out.write("// Model parameters\n");
for (int i = 0; i < model.getParameterCount(); i++) {
Parameter parameter = model.getParameter(i);
out.write("const double " + checkReservedKeywordPrism(parameter.getId()) + " = " + parameter.getValue()
+ "; // " + parameter.getName() + "\n"); // if not null name
}
out.write("\n");
// Identify model species
for (int i = 0; i < model.getSpeciesCount(); i++) {
// Write out syntax
// For function checkReservedKeywordPrism see below
Species species = model.getSpecies(i);
out.write("// Species " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("const int " + checkReservedKeywordPrism(species.getId()) + "_MAX = MAX_AMOUNT;\n");
out.write("module " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("\n");
out.write(" " + checkReservedKeywordPrism(species.getId()) + " : " + "[0.."
+ checkReservedKeywordPrism(species.getId()) + "_MAX] init " + (int) species.getInitialAmount()
+ ";\n");
out.write(" // " + checkReservedKeywordPrism(species.getId()) + " : " + "int init "
+ (int) (species.getInitialAmount()) + ";\n");
out.write("\n");
// Iterate over reactions
for (int j = 0; j < model.getReactionCount(); j++) {
Reaction reaction = model.getReaction(j);
// Identify reactants and products
SpeciesReference reactant = reaction.getReactantForSpecies(species.getId());
SpeciesReference product = reaction.getProductForSpecies(species.getId());
if (reactant != null) {
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + "\n");
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] "
+ checkReservedKeywordPrism(species.getId()) + " > "
+ (int) (reactant.getStoichiometry() - 1) + " -> ("
+ checkReservedKeywordPrism(species.getId()) + "\'="
+ checkReservedKeywordPrism(species.getId()) + "-" + (int) reactant.getStoichiometry()
+ ");\n");
} else if (product != null) {
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + "\n");
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] "
+ checkReservedKeywordPrism(species.getId()) + " <= " + checkReservedKeywordPrism(species.getId()) + "_MAX-"
+ (int) product.getStoichiometry() + " -> ("
+ checkReservedKeywordPrism(species.getId()) + "\'="
+ checkReservedKeywordPrism(species.getId()) + "+" + (int) product.getStoichiometry()
+ ");\n");
}
}
out.write("\n");
out.write("endmodule\n");
out.write("\n");
}
// Identify reaction rate
out.write("// Reaction rates\n");
out.write("module reaction_rates\n");
out.write("\n");
for (int i = 0; i < model.getReactionCount(); i++) {
Reaction reaction = model.getReaction(i);
// Write state transitions
out.write(" // " + checkReservedKeywordPrism(reaction.getId()) + ": -> ");
for (int j = 0; j < reaction.getProductCount(); j++) {
out.write(checkReservedKeywordPrism(reaction.getProduct(j).getSpecies()) + " ");
}
out.write("\n");
// Get the math for the reaction rate
out.write(" [" + checkReservedKeywordPrism(reaction.getId()) + "] "
+ checkReserveKeywordMath(
SBMLutilities.convertMath2PrismProperty(reaction.getKineticLaw().getMath()), model)
+ " > 0 -> " + "("
+ checkReserveKeywordMath(
SBMLutilities.convertMath2PrismProperty(reaction.getKineticLaw().getMath()), model)
+ ") : true;\n");
out.write("\n");
}
out.write("endmodule\n");
out.write("\n");
// Identify rewards
out.write("// Reward structures (one per species)");
out.write("\n");
for (int i = 0; i < model.getSpeciesCount(); i++) {
Species species = model.getSpecies(i);
out.write("// Reward " + (i + 1) + ": " + checkReservedKeywordPrism(species.getId()) + "\n");
out.write("rewards " + "\"" + checkReservedKeywordPrism(species.getId()) + "\" true : "
+ checkReservedKeywordPrism(species.getId()) + "; endrewards\n");
}
out.close();
// Write Properties File
File property = new File(filename.replace(".xml", ".props"));
FileWriter property_out = new FileWriter(property);
// Property preamble
property_out.write("// File generated by SBML-to-PRISM converter\n");
property_out.write("// Original file: " + filename + "\n");
property_out.write("// @GeneticLogicLab\n");
property_out.write("\n");
for (int i = 0; i < model.getConstraintCount(); i++) {
// Get and write translation of constraint
property_out.write(checkReserveKeywordMath(
SBMLutilities.convertMath2PrismProperty(model.getConstraint(i).getMath()), model));
}
property_out.close();
}
/*
* Check for reserved keywords as species names
* Input: (String) NameOfSpecies
* Check for reserved keywords as species names Input: (String) NameOfSpecies
* Output: (String) _NameOfSpecies
*
* Function checks if the name of a species is also a reserved keyword in the prism language. If that is the case, the species name is replaced
* by the species name lead by an underscore.
* Function checks if the name of a species is also a reserved keyword in the
* prism language. If that is the case, the species name is replaced by the
* species name lead by an underscore.
*/
private static String checkReservedKeywordPrism(String speciesname)
{
// List of reserved keywords in the prism language
List<String> keywords = Arrays.asList("A", "bool", "clock", "const", "ctmc", "C", "double", "dtmc", "E", "endinit", "endinvariant", "endmodule",
"endobservables", "endrewards", "endsystem", "false", "formula", "filter", "func", "F", "global", "G", "init", "invariant", "I", "int", "label",
"max", "mdp", "min", "module", "X", "nondeterministic", "observable", "observables", "of", "Pmax", "Pmin", "P", "pomdp", "popta", "probabilistic",
"prob", "pta", "rate", "rewards", "Rmax", "Rmin", "R", "S", "stochastic", "system", "true", "U", "W");
private static String checkReservedKeywordPrism(String speciesname) {
// List of reserved keywords in the prism language
List<String> keywords = Arrays.asList("A", "bool", "clock", "const", "ctmc", "C", "double", "dtmc", "E",
"endinit", "endinvariant", "endmodule", "endobservables", "endrewards", "endsystem", "false", "formula",
"filter", "func", "F", "global", "G", "init", "invariant", "I", "int", "label", "max", "mdp", "min",
"module", "X", "nondeterministic", "observable", "observables", "of", "Pmax", "Pmin", "P", "pomdp",
"popta", "probabilistic", "prob", "pta", "rate", "rewards", "Rmax", "Rmin", "R", "S", "stochastic",
"system", "true", "U", "W");
// Check if species name is in the list
if (keywords.contains(speciesname))
{
if (keywords.contains(speciesname)) {
return "_" + speciesname;
}else {
} else {
return speciesname;
}
}
/*
* Check for reserved keywords as species names in math properties
* Input: (String) NameOfSpecies, model sbmlDoc.getModel();
* Output: (String) _NameOfSpecies
* Check for reserved keywords as species names in math properties Input:
* (String) NameOfSpecies, model sbmlDoc.getModel(); Output: (String)
* _NameOfSpecies
*
* Function checks if the name of a species in a math function is also a reserved keyword in the prism language. If that is the case, the species name in the
* function is replaced by the species name lead by an underscore.
* Function checks if the name of a species in a math function is also a
* reserved keyword in the prism language. If that is the case, the species name
* in the function is replaced by the species name lead by an underscore.
*/
private static String checkReserveKeywordMath(String math, Model model) {
// List of reserved keywords in the prism language
List<String> keywords = Arrays.asList("A", "bool", "clock", "const", "ctmc", "C", "double", "dtmc", "E", "endinit", "endinvariant", "endmodule",
"endobservables", "endrewards", "endsystem", "false", "formula", "filter", "func", "F", "global", "G", "init", "invariant", "I", "int", "label",
"max", "mdp", "min", "module", "X", "nondeterministic", "observable", "observables", "of", "Pmax", "Pmin", "P", "pomdp", "popta", "probabilistic",
"prob", "pta", "rate", "rewards", "Rmax", "Rmin", "R", "S", "stochastic", "system", "true", "U", "W");
// Declaration of new string list
// List of reserved keywords in the prism language
List<String> keywords = Arrays.asList("A", "bool", "clock", "const", "ctmc", "C", "double", "dtmc", "E",
"endinit", "endinvariant", "endmodule", "endobservables", "endrewards", "endsystem", "false", "formula",
"filter", "func", "F", "global", "G", "init", "invariant", "I", "int", "label", "max", "mdp", "min",
"module", "X", "nondeterministic", "observable", "observables", "of", "Pmax", "Pmin", "P", "pomdp",
"popta", "probabilistic", "prob", "pta", "rate", "rewards", "Rmax", "Rmin", "R", "S", "stochastic",
"system", "true", "U", "W");
// Declaration of new string list
ArrayList<String> speciesString = new ArrayList<String>();
// Iterating over species, if species name is a reserved keyword add it to list speciesString
for (int i = 0; i < model.getSpeciesCount(); i++)
{
// Iterating over species, if species name is a reserved keyword add it to list
// speciesString
for (int i = 0; i < model.getSpeciesCount(); i++) {
Species species = model.getSpecies(i);
if(keywords.contains(species.getId()))
{
if (keywords.contains(species.getId())) {
speciesString.add(species.getId());
}
}
//System.err.println(speciesString);
// Iterate over list and replace species name
for(int i = 0; i < keywords.size(); i++)
{
if(speciesString.contains(keywords.get(i)))
{
// System.err.println(speciesString);
// Iterate over list and replace species name
for (int i = 0; i < keywords.size(); i++) {
if (speciesString.contains(keywords.get(i))) {
// Replace species in math equations
// In equations species names are lead by a space
String Target = " " + keywords.get(i);
//System.err.println(Target);
// System.err.println(Target);
math = math.replace(Target, "_" + keywords.get(i));
//System.err.println(math);
// System.err.println(math);
// Replace species names in property files
// In property files species names are lead by a (
// In property files species names are lead by a (
String TargetProperty = "(" + keywords.get(i);
math = math.replace(TargetProperty, "(_" + keywords.get(i));
}
}
}
return math;
}
}
/*
BioModel bioModel = BioModel.createBioModel(properties.getDirectory(), this);
bioModel.load(filename);
if (bioModel.flattenModel(true) != null) {}
bioModel.getSBMLDocument()
*/