diff --git a/conversion/pom.xml b/conversion/pom.xml
index 355f2027b..39eaa18c4 100644
--- a/conversion/pom.xml
+++ b/conversion/pom.xml
@@ -71,7 +71,7 @@
org.virtualparts
virtualparts-data
- 2.0.10-SNAPSHOT
+ 2.0.12-SNAPSHOT
diff --git a/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/Converter.java b/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/Converter.java
index 86dba3c80..5e98960d8 100644
--- a/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/Converter.java
+++ b/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/Converter.java
@@ -17,6 +17,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -443,7 +444,7 @@ public class Converter {
if(!topLevelURIStr.isEmpty())
{
ModuleDefinition topModuleDef = sbolDoc.getModuleDefinition(URI.create(topLevelURIStr));
- List models = SBOL2SBML.generateModel(outputDir, topModuleDef, sbolDoc);
+ HashMap models = SBOL2SBML.generateModel(outputDir, topModuleDef, sbolDoc);
SBMLutilities.exportSBMLModels(models, outputDir, outputFileName, noOutput, sbmlOut, singleSBMLOutput);
}
else
@@ -451,7 +452,7 @@ public class Converter {
//No ModuleDefinition URI provided so loop over all rootModuleDefinition
for (ModuleDefinition moduleDef : sbolDoc.getRootModuleDefinitions())
{
- List models = SBOL2SBML.generateModel(outputDir, moduleDef, sbolDoc);
+ HashMap models = SBOL2SBML.generateModel(outputDir, moduleDef, sbolDoc);
SBMLutilities.exportSBMLModels(models, outputDir, outputFileName, noOutput, sbmlOut, singleSBMLOutput);
}
}
diff --git a/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/SBOL2SBML.java b/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/SBOL2SBML.java
index e1e57aff1..2b08b4246 100644
--- a/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/SBOL2SBML.java
+++ b/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/SBOL2SBML.java
@@ -105,23 +105,26 @@ public class SBOL2SBML {
* @throws BioSimException - if something is wrong with the SBML model.
* @throws SBOLValidationException
*/
- public static List generateModel(String projectDirectory, ModuleDefinition moduleDef, SBOLDocument sbolDoc) throws XMLStreamException, IOException, BioSimException, SBOLValidationException {
+ public static HashMap generateModel(String projectDirectory, ModuleDefinition moduleDef, SBOLDocument sbolDoc) throws XMLStreamException, IOException, BioSimException, SBOLValidationException {
- List models = new LinkedList();
+ HashMap models = new HashMap();
BioModel targetModel = new BioModel(projectDirectory);
targetModel.createSBMLDocument(getDisplayID(moduleDef), false, false);
- org.sbolstandard.core2.Model sbolModel = sbolDoc.createModel(getDisplayID(moduleDef)+"_model", "1",
- URI.create("file:" + getDisplayID(moduleDef) + ".xml"),
- EDAMOntology.SBML, SystemsBiologyOntology.DISCRETE_FRAMEWORK);
- moduleDef.addModel(sbolModel);
-
+ if (sbolDoc.getModel(getDisplayID(moduleDef)+"_model", "1")==null) {
+ org.sbolstandard.core2.Model sbolModel = sbolDoc.createModel(getDisplayID(moduleDef)+"_model", "1",
+ URI.create("file:" + getDisplayID(moduleDef) + ".xml"),
+ EDAMOntology.SBML, SystemsBiologyOntology.DISCRETE_FRAMEWORK);
+ moduleDef.addModel(sbolModel);
+ }
+
// Annotate SBML model with SBOL module definition
Model sbmlModel = targetModel.getSBMLDocument().getModel();
SBOLAnnotation modelAnno = new SBOLAnnotation(sbmlModel.getMetaId(),
moduleDef.getClass().getSimpleName(), moduleDef.getIdentity());
AnnotationUtility.setSBOLAnnotation(sbmlModel, modelAnno);
+ // TODO: add moduleDef flattening here
for (FunctionalComponent comp : moduleDef.getFunctionalComponents()) {
if (isSpeciesComponent(comp, sbolDoc)) {
generateSpecies(comp, sbolDoc, targetModel);
@@ -130,7 +133,7 @@ public class SBOL2SBML {
} else if (isOutputComponent(comp)){
generateOutputPort(comp, targetModel);
}
- } else if (isPromoterComponent(comp, sbolDoc)) {
+ } else if (isPromoterComponent(moduleDef, comp, sbolDoc)) {
generatePromoterSpecies(comp, sbolDoc, targetModel);
if (isInputComponent(comp)) {
generateInputPort(comp, targetModel);
@@ -242,7 +245,7 @@ public class SBOL2SBML {
}
for (FunctionalComponent promoter : moduleDef.getFunctionalComponents()) {
- if (isPromoterComponent(promoter, sbolDoc)) {
+ if (isPromoterComponent(moduleDef, promoter, sbolDoc)) {
if (!promoterToActivators.containsKey(promoter))
promoterToActivators.put(promoter, new LinkedList());
if (!promoterToRepressors.containsKey(promoter))
@@ -270,14 +273,18 @@ public class SBOL2SBML {
BioModel subTargetModel = new BioModel(projectDirectory);
if (subTargetModel.load(projectDirectory + File.separator + getDisplayID(subModuleDef) + ".xml")) {
generateSubModel(projectDirectory, subModule, moduleDef, sbolDoc, subTargetModel, targetModel);
+ } if ((subTargetModel=models.get(getDisplayID(subModuleDef)))!=null) {
+ generateSubModel(projectDirectory, subModule, moduleDef, sbolDoc, subTargetModel, targetModel);
} else {
- List subModels = generateSubModel(projectDirectory, subModule, moduleDef, sbolDoc, targetModel);
- models.addAll(subModels);
+ HashMap subModels = generateSubModel(projectDirectory, subModule, moduleDef, sbolDoc, targetModel);
+ for (String key : subModels.keySet()) {
+ models.put(key,subModels.get(key));
+ }
}
}
- models.add(targetModel);
+ models.put(getDisplayID(moduleDef),targetModel);
return models;
}
@@ -330,12 +337,12 @@ public class SBOL2SBML {
* @throws BioSimException - if something is wrong the with SBML model.
* @throws SBOLValidationException
*/
- private static List generateSubModel(String projectDirectory, Module subModule, ModuleDefinition moduleDef, SBOLDocument sbolDoc,
+ private static HashMap generateSubModel(String projectDirectory, Module subModule, ModuleDefinition moduleDef, SBOLDocument sbolDoc,
BioModel targetModel) throws XMLStreamException, IOException, BioSimException, SBOLValidationException {
ModuleDefinition subModuleDef = sbolDoc.getModuleDefinition(subModule.getDefinitionURI());
//convert each submodules into its own SBML model stored in their own .xml file.
- List subModels = generateModel(projectDirectory, subModuleDef, sbolDoc);
- BioModel subTargetModel = subModels.get(subModels.size()-1);
+ HashMap subModels = generateModel(projectDirectory, subModuleDef, sbolDoc);
+ BioModel subTargetModel = subModels.get(getDisplayID(subModuleDef));
//Perform replacement and replacedBy with each subModules to its referenced ModuleDefinition.
generateSubModel(projectDirectory, subModule, moduleDef, sbolDoc, subTargetModel, targetModel);
@@ -461,14 +468,15 @@ public class SBOL2SBML {
* @param targetModel - The SBML model to store the SBML promoter species created from the conversion.
*/
private static void generatePromoterSpecies(FunctionalComponent promoter, SBOLDocument sbolDoc, BioModel targetModel) {
-
+
// Count promoters
int promoterCnt = 0;
if (promoter.getDefinition() != null) {
ComponentDefinition tuCD = promoter.getDefinition();
for (Component comp : tuCD.getComponents()) {
if (comp.getDefinition() != null) {
- if (comp.getDefinition().getRoles().contains(SequenceOntology.PROMOTER)) {
+ if (comp.getDefinition().getRoles().contains(SequenceOntology.PROMOTER)||
+ comp.getDefinition().getRoles().contains(SequenceOntology.OPERATOR)) {
promoterCnt++;
}
}
@@ -499,9 +507,11 @@ public class SBOL2SBML {
}
}
- targetModel.createPromoter(promoterId, -1, -1, true, false, null);
+ if (targetModel.getSBMLDocument().getModel().getSpecies(promoterId)==null) {
+ targetModel.createPromoter(promoterId, -1, -1, true, false, null);
+ }
Species sbmlPromoter = targetModel.getSBMLDocument().getModel().getSpecies(promoterId);
-
+
// Annotate SBML promoter species with SBOL component and component definition
ComponentDefinition compDef = sbolDoc.getComponentDefinition(promoter.getDefinitionURI());
if (compDef!=null) {
@@ -601,7 +611,7 @@ public class SBOL2SBML {
boolean onPort = (complexSpecies.getDirection().equals(DirectionType.IN)
|| complexSpecies.getDirection().equals(DirectionType.OUT));
Reaction complexFormationRxn = targetModel.createComplexReaction(getDisplayID(complexSpecies), null, onPort);
- complexFormationRxn.setId(getDisplayID(complexFormation));
+ //complexFormationRxn.setId(getDisplayID(complexFormation));
SBMLutilities.setDefaultMetaID(targetModel.getSBMLDocument(), complexFormationRxn, 1);
// Annotate SBML complex formation reaction with SBOL interaction
@@ -665,7 +675,8 @@ public class SBOL2SBML {
ComponentDefinition tuCD = promoter.getDefinition();
for (Component comp : tuCD.getComponents()) {
if (comp.getDefinition() != null) {
- if (comp.getDefinition().getRoles().contains(SequenceOntology.PROMOTER)) {
+ if (comp.getDefinition().getRoles().contains(SequenceOntology.PROMOTER)||
+ comp.getDefinition().getRoles().contains(SequenceOntology.OPERATOR)) {
promoterCnt++;
}
}
@@ -1014,6 +1025,8 @@ public class SBOL2SBML {
* @return True if the given FunctionalComponent is a valid output SBML component. False otherwise.
*/
private static boolean isOutputComponent(FunctionalComponent comp) {
+ // TODO: hack to avoid mapping promoters
+ if (comp.getDefinition().getTypes().contains(ComponentDefinition.DNA)) return false;
return comp.getDirection().equals(DirectionType.OUT) || comp.getDirection().equals(DirectionType.INOUT);
}
@@ -1093,10 +1106,25 @@ public class SBOL2SBML {
* @param sbolDoc - The SBOL Document to check if the given FunctionalComponent exist.
* @return True if the given FunctionalComponent is a valid promoter. False otherwise.
*/
- private static boolean isPromoterComponent(FunctionalComponent comp, SBOLDocument sbolDoc) {
+ private static boolean isPromoterComponent(ModuleDefinition moduleDef,
+ FunctionalComponent comp, SBOLDocument sbolDoc) {
ComponentDefinition compDef = sbolDoc.getComponentDefinition(comp.getDefinitionURI());
if (compDef==null) return false;
- return isPromoterDefinition(compDef);
+
+ // TODO: hack to avoid adding promoters with no interactions
+ if (isPromoterDefinition(compDef)) {
+ boolean foundParticipation = false;
+ for (Interaction interaction : moduleDef.getInteractions()) {
+ for (Participation participation : interaction.getParticipations()) {
+ if (participation.getParticipant().equals(comp)) {
+ foundParticipation = true;
+ break;
+ }
+ }
+ }
+ return foundParticipation;
+ }
+ return false;
}
/**
@@ -1292,7 +1320,7 @@ public class SBOL2SBML {
for (Participation partici : interact.getParticipations()) {
FunctionalComponent comp = moduleDef.getFunctionalComponent(partici.getParticipantURI());
if ((partici.containsRole(SystemsBiologyOntology.PROMOTER)||
- partici.containsRole(SystemsBiologyOntology.TEMPLATE)) && isPromoterComponent(comp, sbolDoc))
+ partici.containsRole(SystemsBiologyOntology.TEMPLATE)) && isPromoterComponent(moduleDef, comp, sbolDoc))
hasPromoter = true;
else if (partici.containsRole(SystemsBiologyOntology.PRODUCT) &&
(isProteinComponent(comp, sbolDoc)||isRNAComponent(comp, sbolDoc)))
@@ -1325,7 +1353,7 @@ public class SBOL2SBML {
for (Participation partici : interact.getParticipations()) {
FunctionalComponent comp = moduleDef.getFunctionalComponent(partici.getParticipantURI());
if ((partici.containsRole(SystemsBiologyOntology.PROMOTER)||
- partici.containsRole(SystemsBiologyOntology.STIMULATED)) && isPromoterComponent(comp, sbolDoc))
+ partici.containsRole(SystemsBiologyOntology.STIMULATED)) && isPromoterComponent(moduleDef, comp, sbolDoc))
hasActivated = true;
else if (partici.containsRole(SystemsBiologyOntology.STIMULATOR) /*&& isTFComponent(comp, sbolDoc)*/)
hasActivator = true;
@@ -1354,7 +1382,7 @@ public class SBOL2SBML {
for (Participation partici : interact.getParticipations()) {
FunctionalComponent comp = moduleDef.getFunctionalComponent(partici.getParticipantURI());
if ((partici.containsRole(SystemsBiologyOntology.PROMOTER) ||
- partici.containsRole(SystemsBiologyOntology.INHIBITED)) && isPromoterComponent(comp, sbolDoc))
+ partici.containsRole(SystemsBiologyOntology.INHIBITED)) && isPromoterComponent(moduleDef, comp, sbolDoc))
hasRepressed = true;
else if (partici.containsRole(SystemsBiologyOntology.INHIBITOR) )
hasRepressor = true;
@@ -1439,8 +1467,8 @@ public class SBOL2SBML {
if(uri!=null){
ModuleDefinition topModuleDef= sbolDoc.getModuleDefinition(URI.create(uri));
- List models = SBOL2SBML.generateModel(outputDir, topModuleDef, sbolDoc);
- for (BioModel model : models)
+ HashMap models = SBOL2SBML.generateModel(outputDir, topModuleDef, sbolDoc);
+ for (BioModel model : models.values())
{
model.save(outputDir + File.separator + model.getSBMLDocument().getModel().getId() + ".xml");
}
@@ -1449,8 +1477,8 @@ public class SBOL2SBML {
//No ModuleDefinition URI provided so loop over all rootModuleDefinition
for (ModuleDefinition moduleDef : sbolDoc.getRootModuleDefinitions())
{
- List models = SBOL2SBML.generateModel(outputDir, moduleDef, sbolDoc);
- for (BioModel model : models)
+ HashMap models = SBOL2SBML.generateModel(outputDir, moduleDef, sbolDoc);
+ for (BioModel model : models.values())
{
model.save(outputDir + File.separator + model.getSBMLDocument().getModel().getId() + ".xml");
}
diff --git a/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/VPRModelGenerator.java b/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/VPRModelGenerator.java
index ce8b0009b..89ea66515 100644
--- a/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/VPRModelGenerator.java
+++ b/conversion/src/main/java/edu/utah/ece/async/ibiosim/conversion/VPRModelGenerator.java
@@ -67,7 +67,7 @@ public class VPRModelGenerator {
collectionURI = collectionURI.substring(0, collectionURI.lastIndexOf('/'));
String collectionId = collectionURI.substring(collectionURI.lastIndexOf('/')+1);
collectionURI = collectionURI + '/' + collectionId + "_collection/" + cd.getVersion();
- if (!collections.contains(collectionURI)) {
+ if (!collections.contains(URI.create(collectionURI))) {
collections.add(URI.create(collectionURI));
}
}
@@ -80,11 +80,11 @@ public class VPRModelGenerator {
if(!rootModuleID.isEmpty() && rootModuleID != null)
{
- interactionAdder = new SBOLInteractionAdder_GeneCentric(URI.create(endpoint), rootModuleID, params);
+ interactionAdder = new SBOLInteractionAdder_GeneCentric(URI.create(endpoint), rootModuleID, params, true);
}
else
{
- interactionAdder = new SBOLInteractionAdder_GeneCentric(URI.create(endpoint), "TopModule", params);
+ interactionAdder = new SBOLInteractionAdder_GeneCentric(URI.create(endpoint), "TopModule", params, true);
}
interactionAdder.addInteractions(generatedModel);
return generatedModel;
diff --git a/dataModels/src/main/java/edu/utah/ece/async/ibiosim/dataModels/biomodel/util/SBMLutilities.java b/dataModels/src/main/java/edu/utah/ece/async/ibiosim/dataModels/biomodel/util/SBMLutilities.java
index 4bc67337b..45a558779 100644
--- a/dataModels/src/main/java/edu/utah/ece/async/ibiosim/dataModels/biomodel/util/SBMLutilities.java
+++ b/dataModels/src/main/java/edu/utah/ece/async/ibiosim/dataModels/biomodel/util/SBMLutilities.java
@@ -145,7 +145,7 @@ public class SBMLutilities extends CoreObservable
* @throws IOException Unable to write file to SBML.
* @throws BioSimException - if sbml model is invalid.
*/
- public static void exportSBMLModels(List models, String outputDir, String outputFileName,
+ public static void exportSBMLModels(HashMap models, String outputDir, String outputFileName,
boolean noOutput, boolean sbmlOut, boolean singleSBMLOutput) throws SBMLException, XMLStreamException, IOException, BioSimException
{
// Note: Since SBOL2SBML converter encase the result of SBML model in BioModels, the last biomodel
@@ -216,11 +216,11 @@ public class SBMLutilities extends CoreObservable
* @throws IOException Unable to write file to SBML.
* @throws BioSimException - if sbml model is invalid.
*/
- public static ArrayList exportMultSBMLFile(List models, String outputDir) throws XMLStreamException, IOException, BioSimException
+ public static ArrayList exportMultSBMLFile(HashMap models, String outputDir) throws XMLStreamException, IOException, BioSimException
{
ArrayList submodels = new ArrayList();
//Multiple SBML output
- for (BioModel model : models)
+ for (BioModel model : models.values())
{
String filename = model.getSBMLDocument().getModel().getId() + ".xml";
model.save(outputDir + File.separator + filename);
diff --git a/gui/jcs_swap/.gitignore b/gui/jcs_swap/.gitignore
new file mode 100644
index 000000000..41e9b607b
--- /dev/null
+++ b/gui/jcs_swap/.gitignore
@@ -0,0 +1,4 @@
+/default.data
+/default.key
+/testCache1.data
+/testCache1.key
diff --git a/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/Gui.java b/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/Gui.java
index 74f9bc84e..2a848dee4 100644
--- a/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/Gui.java
+++ b/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/Gui.java
@@ -6177,10 +6177,10 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
try {
for (ModuleDefinition moduleDef : inputSBOLDoc.getRootModuleDefinitions()) {
if (moduleDef.getModels().size()==0) {
- List models;
+ HashMap models;
try {
models = SBOL2SBML.generateModel(root, moduleDef, inputSBOLDoc);
- for (BioModel model : models) {
+ for (BioModel model : models.values()) {
if (overwrite(root + File.separator + model.getSBMLDocument().getModel().getId() + ".xml",
model.getSBMLDocument().getModel().getId() + ".xml")) {
model.save(root + File.separator + model.getSBMLDocument().getModel().getId() + ".xml");
diff --git a/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/synthesisView/SynthesisView.java b/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/synthesisView/SynthesisView.java
index 7e1a167ec..21079322a 100644
--- a/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/synthesisView/SynthesisView.java
+++ b/gui/src/main/java/edu/utah/ece/async/ibiosim/gui/synthesisView/SynthesisView.java
@@ -586,7 +586,7 @@ public class SynthesisView extends JTabbedPane implements ActionListener, Runnab
List solutionFileIDs = new ArrayList();
for (ModuleDefinition moduleDef : solution.getRootModuleDefinitions())
{
- List models = SBOL2SBML.generateModel(solution_dir, moduleDef, solution);
+ HashMap models = SBOL2SBML.generateModel(solution_dir, moduleDef, solution);
solutionFileIDs.addAll(SBMLutilities.exportMultSBMLFile(models, solution_dir));
}
return solutionFileIDs;