Ensured that biomodel is observed when needed.

This commit is contained in:
leandrohw 2018-01-10 14:06:53 -07:00
parent 7b630d3253
commit fcec8f6b69
20 changed files with 94 additions and 63 deletions

View file

@ -369,7 +369,7 @@ public class Analysis implements BioObserver
new File(properties.getDirectory()).mkdir();
}
/* Flattening happens here */
BioModel biomodel = new BioModel(root);
BioModel biomodel = BioModel.createBioModel(root, this);
biomodel.addObserver(this);
biomodel.load(root + File.separator + modelSource + "_");
SBMLDocument flatten = biomodel.flattenModel(true);

View file

@ -47,6 +47,7 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.SBMLutilities;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility;
import edu.utah.ece.async.ibiosim.dataModels.util.Executables;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.Message;
import edu.utah.ece.async.ibiosim.dataModels.util.MutableString;
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.BioSimException;
@ -290,8 +291,7 @@ public class Run extends CoreObservable implements ActionListener
ArrayList<Object[]> conLevel = new ArrayList<Object[]>();
retrieveSpeciesAndConLevels(specs, conLevel);
BioModel bioModel = new BioModel(properties.getRoot());
bioModel.addObservable(this);
BioModel bioModel = BioModel.createBioModel(properties.getRoot(), this);
bioModel.load(root + File.separator + filename);
if (bioModel.flattenModel(true) != null)
{
@ -351,7 +351,7 @@ public class Run extends CoreObservable implements ActionListener
}
else
{
BioModel gcm = new BioModel(root);
BioModel gcm = BioModel.createBioModel(root, this);
gcm.load(root + File.separator + filename);
ArrayList<Property> propList = new ArrayList<Property>();
if (prop == null)
@ -445,7 +445,7 @@ public class Run extends CoreObservable implements ActionListener
ArrayList<String> specs = new ArrayList<String>();
ArrayList<Object[]> conLevel = new ArrayList<Object[]>();
retrieveSpeciesAndConLevels(specs, conLevel);
BioModel bioModel = new BioModel(root);
BioModel bioModel = BioModel.createBioModel(properties.getRoot(), this);
//TODO: check
bioModel.load(root + File.separator + modelFile);
String prop = null;
@ -624,7 +624,7 @@ public class Run extends CoreObservable implements ActionListener
ArrayList<String> specs = new ArrayList<String>();
ArrayList<Object[]> conLevel = new ArrayList<Object[]>();
retrieveSpeciesAndConLevels(specs, conLevel);
BioModel bioModel = new BioModel(root);
BioModel bioModel = BioModel.createBioModel(properties.getRoot(), this);
bioModel.load(root + File.separator + properties.getFilename());
if (bioModel.flattenModel(true) != null)
{
@ -899,7 +899,7 @@ public class Run extends CoreObservable implements ActionListener
ArrayList<Object[]> conLevel = new ArrayList<Object[]>();
String directory = properties.getDirectory();
retrieveSpeciesAndConLevels(specs, conLevel);
BioModel bioModel = new BioModel(root);
BioModel bioModel = BioModel.createBioModel(properties.getRoot(), this);
bioModel.load(root + File.separator + properties.getModelFile());
if (bioModel.flattenModel(true) != null)

View file

@ -127,7 +127,7 @@ public class GeneticNetwork extends CoreObservable
public void buildTemplate(HashMap<String, SpeciesInterface> species,
HashMap<String, Promoter> promoters, String gcm, String filename) throws XMLStreamException, IOException {
BioModel file = new BioModel(currentRoot);
BioModel file = BioModel.createBioModel(currentRoot, this);
file.load(currentRoot+gcm);
AbstractPrintVisitor.setGCMFile(file);
setSpecies(species);

View file

@ -95,6 +95,8 @@ import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.Message;
import edu.utah.ece.async.ibiosim.dataModels.util.SEDMLutilities;
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.BioSimException;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.BioObservable;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.BioObserver;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.CoreObservable;
@ -110,10 +112,34 @@ public class BioModel extends CoreObservable{
private String filename = null;
private Message message = new Message();
private final Message message = new Message();
private GridTable gridTable;
public static BioModel createBioModel(String path, BioObservable observable)
{
BioModel biomodel = new BioModel(path);
if(observable != null)
{
biomodel.addObservable(observable);
}
return biomodel;
}
public static BioModel createBioModel(String path, BioObserver observer)
{
BioModel biomodel = new BioModel(path);
if(observer != null)
{
biomodel.addObserver(observer);
}
return biomodel;
}
public BioModel(String path) {
this.path = path;
compartments = new HashMap<String, Properties>();
@ -5377,7 +5403,7 @@ public class BioModel extends CoreObservable{
//if (!this.isGridEnabled()) {
for (int i = 0; i < sbmlCompModel.getListOfSubmodels().size(); i++) {
Submodel submodel = sbmlCompModel.getListOfSubmodels().get(i);
BioModel subBioModel = new BioModel(path);
BioModel subBioModel = BioModel.createBioModel(path, this);
String extModelFile = sbmlComp.getListOfExternalModelDefinitions().get(submodel.getModelRef())
.getSource().replace("file://","").replace("file:","").replace(".gcm",".xml");
subBioModel.load(path + File.separator + extModelFile);
@ -5826,7 +5852,7 @@ public class BioModel extends CoreObservable{
document.enablePackage(org.sbml.libsbml.CompExtension.getXmlnsL3V1V1(), "comp", !removeComp);
org.sbml.libsbml.SBMLWriter writer = new org.sbml.libsbml.SBMLWriter();
writer.writeSBMLToFile(document, tempFile);
BioModel bioModel = new BioModel(path);
BioModel bioModel = BioModel.createBioModel(path, this);
bioModel.load(tempFile);
new File(tempFile).delete();
SBMLDocument doc = bioModel.getSBMLDocument();
@ -5855,7 +5881,7 @@ public class BioModel extends CoreObservable{
String tempFile = filename.replace(".gcm","").replace(".xml","")+"_temp.xml";
save(tempFile);
BioModel model = new BioModel(path);
BioModel model = BioModel.createBioModel(path, this);
model.load(tempFile);
model.getSBMLDocument().getModel().unsetExtension(LayoutConstants.namespaceURI);
model.getSBMLDocument().disablePackage(LayoutConstants.namespaceURI);
@ -5902,7 +5928,7 @@ public class BioModel extends CoreObservable{
// loop through the list of submodels
for (String subModelId : comps) {
BioModel subModel = new BioModel(path);
BioModel subModel = BioModel.createBioModel(path, this);
String extModelFile = model.getExtModelFileName(subModelId);
subModel.load(path + File.separator + extModelFile);
ArrayList<String> modelListCopy = copyArray(modelList);
@ -5975,7 +6001,7 @@ public class BioModel extends CoreObservable{
// loop through the list of submodels
for (String subModelId : comps) {
BioModel subModel = new BioModel(path);
BioModel subModel = BioModel.createBioModel(path, this);
String extModelFile = getExtModelFileName(subModelId);
subModel.load(path + File.separator + extModelFile);
ArrayList<String> modelListCopy = copyArray(modelList);
@ -6030,7 +6056,7 @@ public class BioModel extends CoreObservable{
}
for (String s : comps) {
BioModel subModel = new BioModel(path);
BioModel subModel = BioModel.createBioModel(path, this);
String extModel = model.getSBMLComp().getListOfExternalModelDefinitions().get(model.getSBMLCompModel().getListOfSubmodels().get(s)
.getModelRef()).getSource().replace("file://","").replace("file:","").replace(".gcm",".xml");
subModel.load(path + File.separator + extModel);
@ -6687,7 +6713,7 @@ public class BioModel extends CoreObservable{
*/
public boolean getGridEnabledFromFile(String filename) throws XMLStreamException, IOException {
BioModel subModel = new BioModel(path);
BioModel subModel = BioModel.createBioModel(path, this);
subModel.load(filename);
if ((subModel.gridTable.getNumRows() > 0) || (subModel.gridTable.getNumCols() > 0)) return true;
return false;

View file

@ -38,6 +38,7 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.network.Promoter;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.network.SpasticSpecies;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.network.SpeciesInterface;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.CoreObservable;
/**
* This class parses a genetic circuit model.
@ -47,12 +48,12 @@ import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class GCMParser {
public class GCMParser extends CoreObservable{
public GCMParser(String filename) throws XMLStreamException, IOException {
//this.debug = debug;
biomodel = new BioModel(filename.substring(0, filename.length()
- GlobalConstants.getFilename(filename).length()));
biomodel = BioModel.createBioModel(filename.substring(0, filename.length()
- GlobalConstants.getFilename(filename).length()), this);
biomodel.load(filename);
data = new StringBuffer();

View file

@ -6072,7 +6072,7 @@ public class SBMLutilities
String id = "";
if (sbaseRef.isSetSBaseRef())
{
BioModel subModel = new BioModel(root);
BioModel subModel = BioModel.createBioModel(root, bioModel);
Submodel submodel = bioModel.getSBMLCompModel().getListOfSubmodels().get(sbaseRef.getIdRef());
String extModel = bioModel.getSBMLComp().getListOfExternalModelDefinitions().get(submodel.getModelRef()).getSource()
.replace("file://", "").replace("file:", "").replace(".gcm", ".xml");

View file

@ -3635,7 +3635,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
"Invalid ID", JOptionPane.ERROR_MESSAGE);
} else {
if (overwrite(root + File.separator + modelId, modelId)) {
BioModel bioModel = new BioModel(root);
BioModel bioModel = BioModel.createBioModel(root, this);
bioModel.createSBMLDocument(modelId.replace(".xml", ""), grid, false);
bioModel.save(root + File.separator + modelId);
int i = getTab(modelId);
@ -3799,8 +3799,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
AnalysisProperties properties;
properties = new AnalysisProperties(analysisId, modelFileName, root, false);
properties.addObserver(this);
BioModel biomodel = new BioModel(root + File.separator);
biomodel.addObserver(this);
BioModel biomodel = BioModel.createBioModel(root + File.separator, this);
biomodel.load(root + File.separator + "_" + modelFileName);
SBMLDocument flatten = biomodel.flattenModel(true);
String newFilename = root + File.separator + analysisId + File.separator + modelFileName;
@ -6882,7 +6881,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
in.close();
out.close();
BioModel bioModel = new BioModel(root);
BioModel bioModel = BioModel.createBioModel(root, this);
try {
bioModel.load(root + File.separator + filename);
GCM2SBML gcm2sbml = new GCM2SBML(bioModel);
@ -8825,7 +8824,7 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
views.add(s);
}
} else if (s.endsWith(".xml") && filename.endsWith(".xml")) {
BioModel gcm = new BioModel(root);
BioModel gcm = BioModel.createBioModel(root, this);
try {
gcm.load(root + File.separator + s);
if (gcm.getSBMLComp() != null) {

View file

@ -6416,7 +6416,7 @@ public class Graph extends PanelObservable implements ActionListener, MouseListe
learnSpecs = new ArrayList<String>();
if (background != null) {
if (background.endsWith(".gcm")) {
BioModel gcm = new BioModel(gui.getRoot());
BioModel gcm = BioModel.createBioModel(gui.getRoot(), this);
gcm.load(background);
learnSpecs = gcm.getSpecies();
}

View file

@ -1153,7 +1153,7 @@ public class DataManager extends PanelObservable implements ActionListener, Tabl
if (background != null) {
if (background.contains(".gcm")) {
ArrayList<String> getSpecies = new ArrayList<String>();
BioModel gcm = new BioModel(biosim.getRoot());
BioModel gcm = BioModel.createBioModel(biosim.getRoot(), this);
try {
gcm.load(background);

View file

@ -34,6 +34,7 @@ import javax.xml.stream.XMLStreamException;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.PanelObservable;
import edu.utah.ece.async.ibiosim.gui.Gui;
import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.ModelEditor;
@ -43,7 +44,7 @@ import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.ModelEditor;
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class DropComponentPanel extends JPanel implements ActionListener {
public class DropComponentPanel extends PanelObservable implements ActionListener {
/**
*
@ -214,7 +215,7 @@ public class DropComponentPanel extends JPanel implements ActionListener {
//name of the component
String component = (String)componentChooser.getSelectedItem();
BioModel compGCM = new BioModel(bioModel.getPath());
BioModel compGCM = BioModel.createBioModel(bioModel.getPath(), this);
//don't allow dropping a grid component
try {
@ -292,7 +293,7 @@ public class DropComponentPanel extends JPanel implements ActionListener {
double width = grid.getComponentGeomWidth();
double height = grid.getComponentGeomHeight();
BioModel compGCMFile = new BioModel(bioModel.getPath());
BioModel compGCMFile = BioModel.createBioModel(bioModel.getPath(), this);
try {
compGCMFile.load(bioModel.getPath() + File.separator + component);
} catch (XMLStreamException e) {
@ -348,7 +349,7 @@ public class DropComponentPanel extends JPanel implements ActionListener {
//name of the component
String component = (String)componentCombo.getSelectedItem();
BioModel compGCM = new BioModel(bioModel.getPath());
BioModel compGCM = BioModel.createBioModel(bioModel.getPath(), this);
//don't allow grids within a grid
try {
@ -445,7 +446,7 @@ public class DropComponentPanel extends JPanel implements ActionListener {
//sets location(s) for all of the tiled component(s)
for(int row=0; row<rowCount; row++) {
for(int col=0; col<colCount; col++) {
BioModel compBioModel = new BioModel(bioModel.getPath());
BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), this);
try {
compBioModel.load(bioModel.getPath() + File.separator + comp);
} catch (XMLStreamException e) {

View file

@ -35,6 +35,7 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.GridTable;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.CoreObservable;
import edu.utah.ece.async.ibiosim.gui.Gui;
import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.BioGraph;
@ -49,7 +50,7 @@ import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.BioGraph;
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class Grid {
public class Grid extends CoreObservable{
//---------------
@ -1024,7 +1025,7 @@ public class Grid {
//don't put blank components onto the grid or model
if (!compGCM.equals("none")) {
BioModel compGCMFile = new BioModel(bioModel.getPath());
BioModel compGCMFile = BioModel.createBioModel(bioModel.getPath(), this);
try {
compGCMFile.load(bioModel.getPath() + File.separator + compGCM);
} catch (XMLStreamException e) {

View file

@ -31,6 +31,7 @@ import javax.xml.stream.XMLStreamException;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.PanelObservable;
import edu.utah.ece.async.ibiosim.gui.Gui;
import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.ModelEditor;
@ -41,7 +42,7 @@ import edu.utah.ece.async.ibiosim.gui.modelEditor.schematic.ModelEditor;
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class GridPanel extends JPanel implements ActionListener {
public class GridPanel extends PanelObservable implements ActionListener {
private static final long serialVersionUID = 1L;
private BioModel gcm;
@ -145,8 +146,7 @@ public class GridPanel extends JPanel implements ActionListener {
//name of the component
String component = (String)componentChooser.getSelectedItem();
BioModel compGCM = new BioModel(gcm.getPath());
BioModel compGCM = BioModel.createBioModel(gcm.getPath(), this);
//don't allow dropping a grid component
try {
if (component != "none" && compGCM.getGridEnabledFromFile(gcm.getPath() +
@ -273,8 +273,7 @@ public class GridPanel extends JPanel implements ActionListener {
//name of the component
String component = (String)componentChooser.getSelectedItem();
BioModel compGCM = new BioModel(gcm.getPath());
BioModel compGCM = BioModel.createBioModel(gcm.getPath(), this);
//don't allow dropping a grid component
try {
if (!component.equals("none") && compGCM.getGridEnabledFromFile(gcm.getPath() +

View file

@ -1338,7 +1338,8 @@ public class BioGraph extends mxGraph {
// map components edges
for (int i = 0; i < bioModel.getSBMLCompModel().getListOfSubmodels().size(); i++) {
String id = bioModel.getSBMLCompModel().getListOfSubmodels().get(i).getId();
BioModel compBioModel = new BioModel(bioModel.getPath());
//BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), this);
BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), modelEditor);
String modelFileName = bioModel.getModelFileName(id);
try {
compBioModel.load(bioModel.getPath() + File.separator + modelFileName);
@ -2287,7 +2288,7 @@ public class BioGraph extends mxGraph {
boolean needsPositioning = false;
//set the correct compartment status
BioModel compBioModel = new BioModel(bioModel.getPath());
BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), modelEditor);
boolean compart = false;
//String modelFileName = gcm.getModelFileName(id).replace(".xml", ".gcm");
String label = SBMLutilities.getArrayId(bioModel.getSBMLDocument(), id);

View file

@ -264,8 +264,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
parameterChanges = new ArrayList<String>();
filename = refFile;
}
biomodel = new BioModel(path);
biomodel.addObservable(this);
biomodel = BioModel.createBioModel(path, this);
if (filename != null) {
biomodel.load(path + File.separator + filename);
this.filename = filename;
@ -811,7 +810,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
try {
parser = new GCMParser(path + File.separator + modelId + ".xml");
GeneticNetwork network = null;
BioModel bioModel = new BioModel(path);
BioModel bioModel = BioModel.createBioModel(path, this);
bioModel.load(path + File.separator + modelId + ".xml");
SBMLDocument sbml = bioModel.flattenModel(true);
if (sbml == null)
@ -2460,7 +2459,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
public PromoterPanel launchPromoterPanel(String id) {
BioModel refGCM = null;
if (paramsOnly) {
refGCM = new BioModel(path);
refGCM = BioModel.createBioModel(path, this);
try {
refGCM.load(path + File.separator + refFile);
} catch (XMLStreamException e) {
@ -2498,7 +2497,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
BioModel refGCM = null;
if (paramsOnly) {
refGCM = new BioModel(path);
refGCM = BioModel.createBioModel(path, this);
try {
refGCM.load(path + File.separator + refFile);
} catch (XMLStreamException e) {
@ -2536,7 +2535,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
public InfluencePanel launchInfluencePanel(String id) {
BioModel refGCM = null;
if (paramsOnly) {
refGCM = new BioModel(path);
refGCM = BioModel.createBioModel(path, this);
try {
refGCM.load(path + File.separator + refFile);
} catch (XMLStreamException e) {
@ -2626,7 +2625,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
public boolean checkNoComponentLoop(String gcm, String checkFile) {
gcm = gcm.replace(".gcm", ".xml");
boolean check = true;
BioModel g = new BioModel(path);
BioModel g = BioModel.createBioModel(path, this);
try {
g.load(path + File.separator + checkFile);
} catch (XMLStreamException e) {
@ -2712,7 +2711,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
}
}
if (comp != null && !comp.equals("")) {
BioModel subBioModel = new BioModel(path);
BioModel subBioModel = BioModel.createBioModel(path, this);
try {
subBioModel.load(path + File.separator + comp);
subBioModel.flattenBioModel();
@ -3051,7 +3050,7 @@ public class ModelEditor extends PanelObservable implements ActionListener, Mous
*/
public boolean getGridEnabledFromFile(String filename) throws XMLStreamException, IOException {
BioModel subModel = new BioModel(path);
BioModel subModel = BioModel.createBioModel(path, this);
subModel.load(filename);
if ((biomodel.getGridTable().getNumRows() > 0) || (subModel.getGridTable().getNumCols() > 0))
return true;

View file

@ -104,6 +104,7 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.annotation.AnnotationUtili
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.SBMLutilities;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.PanelObservable;
import edu.utah.ece.async.ibiosim.gui.Gui;
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
import edu.utah.ece.async.ibiosim.gui.modelEditor.comp.DropComponentPanel;
@ -126,7 +127,7 @@ import edu.utah.ece.async.ibiosim.gui.modelEditor.sbmlcore.SpeciesPanel;
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class Schematic extends JPanel implements ActionListener {
public class Schematic extends PanelObservable implements ActionListener {
//CLASS VARIABLES
@ -2127,7 +2128,7 @@ public class Schematic extends JPanel implements ActionListener {
*/
public String connectComponentToSpecies(String compID, String specID) throws ListChooser.EmptyListException{
String fullPath = bioModel.getPath() + File.separator + bioModel.getModelFileName(compID);
BioModel compBioModel = new BioModel(bioModel.getPath());
BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), this);
try {
compBioModel.load(fullPath);
ArrayList<String> ports = compBioModel.getOutputPorts(GlobalConstants.SBMLSPECIES);
@ -2154,7 +2155,7 @@ public class Schematic extends JPanel implements ActionListener {
*/
public String connectSpeciesToComponent(String specID, String compID) throws ListChooser.EmptyListException{
String fullPath = bioModel.getPath() + File.separator + bioModel.getModelFileName(compID);
BioModel compBioModel = new BioModel(bioModel.getPath());
BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), this);
try {
compBioModel.load(fullPath);
ArrayList<String> ports = compBioModel.getInputPorts(GlobalConstants.SBMLSPECIES);
@ -2182,7 +2183,7 @@ public class Schematic extends JPanel implements ActionListener {
public String connectComponentToVariable(String compID, String varID) throws ListChooser.EmptyListException{
Parameter p = bioModel.getSBMLDocument().getModel().getParameter(varID);
String fullPath = bioModel.getPath() + File.separator + bioModel.getModelFileName(compID);
BioModel compBioModel = new BioModel(bioModel.getPath());
BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), this);
try {
compBioModel.load(fullPath);
ArrayList<String> ports;
@ -2217,7 +2218,7 @@ public class Schematic extends JPanel implements ActionListener {
public String connectVariableToComponent(String varID, String compID) throws ListChooser.EmptyListException{
Parameter p = bioModel.getSBMLDocument().getModel().getParameter(varID);
String fullPath = bioModel.getPath() + File.separator + bioModel.getModelFileName(compID);
BioModel compBioModel = new BioModel(bioModel.getPath());
BioModel compBioModel = BioModel.createBioModel(bioModel.getPath(), this);
try {
compBioModel.load(fullPath);
ArrayList<String> ports;
@ -2602,7 +2603,7 @@ public class Schematic extends JPanel implements ActionListener {
String s = bioModel.getSBMLCompModel().getListOfSubmodels().get(i).getId();
BioModel subModel = new BioModel(bioModel.getPath());
BioModel subModel = BioModel.createBioModel(bioModel.getPath(), this);
String extModel = bioModel.getSBMLComp().getListOfExternalModelDefinitions().get(bioModel.getSBMLCompModel().getListOfSubmodels().get(s)
.getModelRef()).getSource().replace("file://","").replace("file:","").replace(".gcm",".xml");
try {

View file

@ -32,6 +32,7 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.GCM2SBML;
import edu.utah.ece.async.ibiosim.dataModels.sbol.SBOLUtility;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.PanelObservable;
import edu.utah.ece.async.ibiosim.gui.Gui;
import edu.utah.ece.async.ibiosim.gui.ResourceManager;
@ -43,7 +44,7 @@ import edu.utah.ece.async.ibiosim.gui.ResourceManager;
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class FileTree extends JPanel implements MouseListener {
public class FileTree extends PanelObservable implements MouseListener {
private static final long serialVersionUID = -6799125543270861304L;
@ -341,7 +342,7 @@ public class FileTree extends JPanel implements MouseListener {
}
if (!async && thisObject.toString().endsWith(".gcm")) {
String sbmlFile = thisObject.replace(".gcm",".xml");
BioModel bioModel = new BioModel(curPath);
BioModel bioModel = BioModel.createBioModel(curPath, this);
try {
bioModel.load(curPath + File.separator + sbmlFile);
GCM2SBML gcm2sbml = new GCM2SBML(bioModel);

View file

@ -3102,7 +3102,7 @@ public class VerificationView extends PanelObservable implements ActionListener,
//e.printStackTrace();
}
} else if (sourceFile.endsWith(".xml")) {
BioModel bioModel = new BioModel(workDir);
BioModel bioModel = BioModel.createBioModel(workDir, this);
try {
bioModel.load(workDir + File.separator + sourceFile);
ModelEditor.saveLPN(bioModel, directory + File.separator + sourceFile.replace(".xml", ".lpn"));

View file

@ -472,7 +472,7 @@ public class Learn implements BioObserver
if(new File(learnFile).exists())
{
BioModel biomodel = new BioModel(directory);
BioModel biomodel = BioModel.createBioModel(directory, this);
biomodel.load(learnFile);
GCM2SBML gcm2sbml = new GCM2SBML(biomodel);
gcm2sbml.load(learnFile);

View file

@ -315,7 +315,8 @@ public class Synthesizer {
}
private static void createSubmodel(String submodelID, String sbmlFileID, BioModel biomodel) throws XMLStreamException, IOException {
BioModel subBiomodel = new BioModel(biomodel.getPath());
BioModel subBiomodel = BioModel.createBioModel(biomodel.getPath(), biomodel);
subBiomodel.addObservable(biomodel);
subBiomodel.load(biomodel.getPath() + File.separator + sbmlFileID);
String md5 = Utility.MD5(subBiomodel.getSBMLDocument());

View file

@ -47,6 +47,7 @@ import edu.utah.ece.async.ibiosim.dataModels.biomodel.util.SBMLutilities;
import edu.utah.ece.async.ibiosim.dataModels.sbol.SBOLFileManager;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.SBOLException;
import edu.utah.ece.async.ibiosim.dataModels.util.observe.CoreObservable;
/**
*
@ -57,7 +58,7 @@ import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.SBOLException;
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class AssemblyGraph2 {
public class AssemblyGraph2 extends CoreObservable{
private Set<AssemblyNode2> assemblyNodes;
private HashMap<AssemblyNode2, Set<AssemblyNode2>> assemblyEdges;
@ -160,7 +161,7 @@ public class AssemblyGraph2 {
} else {
assemblyNodes.remove(subModelNode);
String extSBMLFileID = compSBMLDoc.getListOfExternalModelDefinitions().get(sbmlSubModel.getModelRef()).getSource().replace("file://","").replace("file:","").replace(".gcm",".xml");
BioModel extBioModel = new BioModel(path);
BioModel extBioModel = BioModel.createBioModel(path, this);
extBioModel.load(extSBMLFileID);
Model extSBMLModel = extBioModel.getSBMLDocument().getModel();
AssemblyNode2 extModelNode = constructNode(extSBMLModel, extSBMLModel.getId());