Search in sources :

Example 61 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class BioModelEditor method setRightTopPanel.

private void setRightTopPanel(Object selectedObject, SimulationContext simulationContext) {
    JComponent newTopPanel = emptyPanel;
    // DEFAULT_DIVIDER_LOCATION;
    int dividerLocation = rightSplitPane.getDividerLocation();
    if (selectedObject instanceof Model) {
        newTopPanel = bioModelEditorModelPanel;
    } else if (selectedObject instanceof BioModel || selectedObject instanceof VCMetaData || selectedObject instanceof MiriamResource) {
        newTopPanel = bioModelPropertiesPanel;
        bioModelPropertiesPanel.setBioModel(bioModel);
    } else if (selectedObject instanceof SimulationContext) {
        newTopPanel = bioModelEditorApplicationPanel;
        bioModelEditorApplicationPanel.setSimulationContext(simulationContext);
    } else if (selectedObject instanceof DocumentEditorTreeFolderNode) {
        DocumentEditorTreeFolderNode folderNode = (DocumentEditorTreeFolderNode) selectedObject;
        DocumentEditorTreeFolderClass folderClass = folderNode.getFolderClass();
        if (folderClass == DocumentEditorTreeFolderClass.MODEL_NODE) {
            newTopPanel = bioModelEditorModelPanel;
        } else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE || folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE || folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE || folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE || folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE || folderClass == DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE) // || folderClass == DocumentEditorTreeFolderClass.STRUCTURE_DIAGRAM_NODE
        {
            newTopPanel = bioModelEditorModelPanel;
        } else if (folderClass == DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE || folderClass == DocumentEditorTreeFolderClass.PATHWAY_OBJECTS_NODE || folderClass == DocumentEditorTreeFolderClass.BIOPAX_SUMMARY_NODE || folderClass == DocumentEditorTreeFolderClass.BIOPAX_TREE_NODE) {
            newTopPanel = bioModelEditorPathwayDiagramPanel;
        } else if (folderClass == DocumentEditorTreeFolderClass.PATHWAY_NODE) {
            newTopPanel = getBioModelEditorPathwayDiagramPanel();
            getBioModelEditorPathwayDiagramPanel().setBioModel(bioModel);
        } else if (folderClass == DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE) {
            newTopPanel = bioModelParametersPanel;
        } else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
            newTopPanel = bioModelEditorApplicationsPanel;
        // } else if (folderClass == DocumentEditorTreeFolderClass.DATA_NODE) {
        // newTopPanel = dataSymbolsPanel;
        } else if (folderClass == DocumentEditorTreeFolderClass.SCRIPTING_NODE) {
            newTopPanel = getScriptingPanel();
        } else if (folderClass == DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE || folderClass == DocumentEditorTreeFolderClass.PROTOCOLS_NODE || folderClass == DocumentEditorTreeFolderClass.SIMULATIONS_NODE || folderClass == DocumentEditorTreeFolderClass.GEOMETRY_NODE || folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
            newTopPanel = bioModelEditorApplicationPanel;
            bioModelEditorApplicationPanel.setSimulationContext(simulationContext);
        }
    }
    Component rightTopComponent = rightSplitPane.getTopComponent();
    if (rightTopComponent != newTopPanel) {
        rightSplitPane.setTopComponent(newTopPanel);
    }
    rightSplitPane.setDividerLocation(dividerLocation);
    getSimulationConsolePanel().setSimulationContext(simulationContext);
    if (simulationContext == null) {
        rightBottomTabbedPane.remove(getSimulationConsolePanel());
    } else {
        // show the console only for bionetgen deterministic applications (flattened network)
        if (simulationContext.getApplicationType() == Application.RULE_BASED_STOCHASTIC) {
            // if(simulationContext.isRuleBased() || simulationContext.isStoch()) {
            // if(simulationContext.isStoch()) {
            rightBottomTabbedPane.remove(getSimulationConsolePanel());
            return;
        }
        boolean bHasRules = simulationContext.getModel().getRbmModelContainer().hasRules();
        if (!bHasRules) {
            rightBottomTabbedPane.remove(getSimulationConsolePanel());
            return;
        }
        // rightBottomTabbedPane.addTab("Network Console", new TabCloseIcon(), getSimulationConsolePanel());
        rightBottomTabbedPane.addTab("Network Generation Status", getSimulationConsolePanel());
    }
}
Also used : VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) BioModel(cbit.vcell.biomodel.BioModel) JComponent(javax.swing.JComponent) Model(cbit.vcell.model.Model) ListSelectionModel(javax.swing.ListSelectionModel) BioModel(cbit.vcell.biomodel.BioModel) DocumentEditorTreeFolderNode(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode) SimulationContext(cbit.vcell.mapping.SimulationContext) DocumentEditorTreeFolderClass(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Example 62 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class BioModelEditor method setRightBottomPanelOnSelection.

@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
    if (selections == null) {
        return;
    }
    JComponent bottomComponent = rightBottomEmptyPanel;
    int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
    boolean bShowInDatabaseProperties = false;
    boolean bShowPathway = false;
    if (selections.length == 1) {
        Object singleSelection = selections[0];
        if (singleSelection instanceof ReactionStep) {
            bottomComponent = getReactionPropertiesPanel();
        } else if (singleSelection instanceof ReactionRule) {
            bottomComponent = getReactionRulePropertiesPanel();
        } else if (singleSelection instanceof SpeciesContext) {
            bottomComponent = getSpeciesPropertiesPanel();
        } else if (singleSelection instanceof MolecularType) {
            bottomComponent = getMolecularTypePropertiesPanel();
        } else if (singleSelection instanceof RbmObservable) {
            bottomComponent = getObservablePropertiesPanel();
        } else if (singleSelection instanceof Structure) {
            bottomComponent = getStructurePropertiesPanel();
            getStructurePropertiesPanel().setModel(bioModel.getModel());
        } else if (singleSelection instanceof Parameter) {
            bottomComponent = getParameterPropertiesPanel();
        } else if (singleSelection instanceof SimulationContext) {
            bottomComponent = getApplicationPropertiesPanel();
        } else if (singleSelection instanceof ParameterEstimationTask) {
            bottomComponent = parameterEstimationTaskPropertiesPanel;
        } else if (singleSelection instanceof Product || singleSelection instanceof Reactant) {
            bottomComponent = getReactionParticipantPropertiesPanel();
        } else if (singleSelection instanceof BioModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = bioModelMetaDataPanel;
        } else if (singleSelection instanceof MathModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = mathModelMetaDataPanel;
        } else if (singleSelection instanceof GeometryInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = geometryMetaDataPanel;
        } else if (singleSelection instanceof SpeciesContextSpec) {
            bottomComponent = getSpeciesContextSpecPanel();
        } else if (singleSelection instanceof ReactionSpec) {
            bottomComponent = getKineticsTypeTemplatePanel();
        } else if (singleSelection instanceof ReactionRuleSpec) {
            // 
            bottomComponent = getReactionRuleSpecPropertiesPanel();
        } else if (singleSelection instanceof BioModelsNetModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = getBioModelsNetPropertiesPanel();
        } else if (singleSelection instanceof Simulation) {
            bottomComponent = getSimulationSummaryPanel();
        } else if (singleSelection instanceof DataSymbol) {
            bottomComponent = getDataSymbolsSpecPanel();
        } else if (singleSelection instanceof BioEvent) {
            bottomComponent = getEventPanel();
        } else if (singleSelection instanceof SpatialObject) {
            bottomComponent = getSpatialObjectPropertyPanel();
        } else if (singleSelection instanceof SpatialProcess) {
            bottomComponent = getSpatialProcessPropertyPanel();
        } else if (singleSelection instanceof BioPaxObject) {
            bottomComponent = bioPaxObjectPropertiesPanel;
        } else if (singleSelection instanceof BioModel || singleSelection instanceof VCMetaData) {
            bottomComponent = bioModelEditorAnnotationPanel;
        } else if (singleSelection instanceof PathwayData) {
            bShowPathway = true;
            bottomComponent = getBioModelEditorPathwayPanel();
        } else if (singleSelection instanceof Model) {
        } else if (singleSelection instanceof RuleParticipantSignature) {
            bottomComponent = getReactionRuleParticipantSignaturePropertiesPanel();
        } else if (singleSelection instanceof CSGObject) {
            bottomComponent = csgObjectPropertiesPanel;
            csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
        } else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
            DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) singleSelection).getFolderClass();
            if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && !(singleSelection instanceof ReactionRule)) {
                bottomComponent = getReactionPropertiesPanel();
            } else if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && (singleSelection instanceof ReactionRule)) {
                bottomComponent = getReactionRulePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
                bottomComponent = getStructurePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
                bottomComponent = getSpeciesPropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
                bottomComponent = getMolecularTypePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
                bottomComponent = getObservablePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
                bottomComponent = getApplicationsPropertiesPanel();
                getApplicationsPropertiesPanel().setBioModel(bioModel);
            } else if (folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
                bottomComponent = parameterEstimationTaskPropertiesPanel;
            }
        }
    }
    if (bShowPathway) {
        for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
            if (rightBottomTabbedPane.getComponentAt(destComponentIndex) == bottomComponent) {
                break;
            }
        }
        String tabTitle = "Pathway Preview";
        if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
            rightBottomTabbedPane.addTab(tabTitle, new TabCloseIcon(), bottomComponent);
        }
    } else if (bShowInDatabaseProperties) {
        for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
            Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
            if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel || c == getBioModelsNetPropertiesPanel()) {
                break;
            }
        }
        if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
            rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
        }
    }
    if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
        bottomComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
        rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
        rightSplitPane.repaint();
    }
    if (rightBottomTabbedPane.getSelectedComponent() != bottomComponent) {
        rightBottomTabbedPane.setSelectedComponent(bottomComponent);
    }
}
Also used : RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) BioPaxObject(org.vcell.pathway.BioPaxObject) Product(cbit.vcell.model.Product) PathwayData(cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayData) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) Reactant(cbit.vcell.model.Reactant) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) GeometryInfo(cbit.vcell.geometry.GeometryInfo) Structure(cbit.vcell.model.Structure) CSGObject(cbit.vcell.geometry.CSGObject) Component(java.awt.Component) JComponent(javax.swing.JComponent) ReactionRule(cbit.vcell.model.ReactionRule) ReactionSpec(cbit.vcell.mapping.ReactionSpec) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) RbmObservable(cbit.vcell.model.RbmObservable) JComponent(javax.swing.JComponent) BioModelInfo(org.vcell.util.document.BioModelInfo) DocumentEditorTreeFolderNode(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) DocumentEditorTreeFolderClass(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass) MolecularType(org.vcell.model.rbm.MolecularType) ParameterEstimationTask(cbit.vcell.modelopt.ParameterEstimationTask) DataSymbol(cbit.vcell.data.DataSymbol) Simulation(cbit.vcell.solver.Simulation) ReactionStep(cbit.vcell.model.ReactionStep) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) ListSelectionModel(javax.swing.ListSelectionModel) BioModel(cbit.vcell.biomodel.BioModel) Parameter(cbit.vcell.model.Parameter) BioPaxObject(org.vcell.pathway.BioPaxObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) CSGObject(cbit.vcell.geometry.CSGObject) BioEvent(cbit.vcell.mapping.BioEvent)

Example 63 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class BioModelEditor method createNewBiomodelFromApp.

private void createNewBiomodelFromApp() {
    SimulationContext simulationContext = getSelectedSimulationContext();
    if (simulationContext == null) {
        PopupGenerator.showErrorDialog(this, "Please select an application.");
        return;
    }
    // bioModel.getVCMetaData().cleanupMetadata();
    try {
        String newBMXML = XmlHelper.bioModelToXML(bioModel);
        BioModel newBioModel = XmlHelper.XMLToBioModel(new XMLSource(newBMXML));
        newBioModel.clearVersion();
        SimulationContext[] newBMSimcontexts = newBioModel.getSimulationContexts();
        for (int i = 0; i < newBMSimcontexts.length; i++) {
            if (!newBMSimcontexts[i].getName().equals(simulationContext.getName())) {
                // Remove sims before removing simcontext
                Simulation[] newBMSims = newBMSimcontexts[i].getSimulations();
                for (int j = 0; j < newBMSims.length; j++) {
                    newBMSimcontexts[i].removeSimulation(newBMSims[j]);
                }
                newBioModel.removeSimulationContext(newBMSimcontexts[i]);
            }
        }
        VCDocument.DocumentCreationInfo newBMDocCreateInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.BIOMODEL_DOC, VCDocument.BIO_OPTION_DEFAULT);
        newBMDocCreateInfo.setPreCreatedDocument(newBioModel);
        AsynchClientTask[] newBMTasks = getBioModelWindowManager().newDocument(newBMDocCreateInfo);
        ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), newBMTasks);
    } catch (Exception e) {
        e.printStackTrace();
        PopupGenerator.showErrorDialog(this, "Error creating new BioModel from Application '" + simulationContext.getName() + "'\n" + e.getMessage());
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCDocument(org.vcell.util.document.VCDocument) SimulationContext(cbit.vcell.mapping.SimulationContext) PropertyVetoException(java.beans.PropertyVetoException) UnsupportedOperationException(javax.help.UnsupportedOperationException) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) BioPaxObject(org.vcell.pathway.BioPaxObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) CSGObject(cbit.vcell.geometry.CSGObject) XMLSource(cbit.vcell.xml.XMLSource)

Example 64 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class BioModelEditorApplicationsPanel method compareButtonPressed.

private void compareButtonPressed() {
    int[] rows = table.getSelectedRows();
    if (rows == null || rows.length != 2) {
        return;
    }
    try {
        SimulationContext simContext1 = tableModel.getValueAt(rows[0]);
        SimulationContext simContext2 = tableModel.getValueAt(rows[1]);
        BioModel bioModel = simContext1.getBioModel();
        MathMappingCallback callback = new MathMappingCallback() {

            @Override
            public void setProgressFraction(float fractionDone) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: progress = " + (fractionDone * 100.0) + "% done");
            }

            @Override
            public void setMessage(String message) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: message = " + message);
            }

            @Override
            public boolean isInterrupted() {
                return false;
            }
        };
        simContext1.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        simContext2.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        Xmlproducer xmlProducer = new Xmlproducer(false);
        String simContext1XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext1, bioModel));
        String simContext2XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext2, bioModel));
        DiffConfiguration comparisonSetting = DiffConfiguration.COMPARE_DOCS_OTHER;
        XmlTreeDiff diffTree = XmlHelper.compareMerge(simContext1XML, simContext2XML, comparisonSetting, true);
        String baselineDesc = "application " + simContext1.getName();
        String modifiedDesc = "application " + simContext2.getName();
        TMLPanel comparePanel = new TMLPanel();
        comparePanel.setXmlTreeDiff(diffTree);
        comparePanel.setBaselineVersionDescription(baselineDesc);
        comparePanel.setModifiedVersionDescription(modifiedDesc);
        ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
        String title = "comparing application " + simContext1.getName() + " and " + simContext2.getName();
        ChildWindow childWindow = childWindowManager.addChildWindow(comparePanel, diffTree, title, true);
        childWindow.setSize(new Dimension(600, 600));
        childWindow.show();
    } catch (XmlParseException e) {
        e.printStackTrace();
        DialogUtils.showErrorDialog(this, "failed to compare applications: \n\n" + e.getMessage());
    }
}
Also used : DiffConfiguration(cbit.xml.merge.XmlTreeDiff.DiffConfiguration) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) Xmlproducer(cbit.vcell.xml.Xmlproducer) XmlTreeDiff(cbit.xml.merge.XmlTreeDiff) ChildWindowManager(cbit.vcell.client.ChildWindowManager) Dimension(java.awt.Dimension) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContext(cbit.vcell.mapping.SimulationContext) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) TMLPanel(cbit.xml.merge.gui.TMLPanel) BioModel(cbit.vcell.biomodel.BioModel)

Example 65 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class BioModelEditorApplicationsTableModel method bioModelChange.

@Override
protected void bioModelChange(PropertyChangeEvent evt) {
    super.bioModelChange(evt);
    BioModel oldValue = (BioModel) evt.getOldValue();
    if (oldValue != null) {
        for (SimulationContext simulationContext : oldValue.getSimulationContexts()) {
            simulationContext.removePropertyChangeListener(this);
        }
    }
    BioModel newValue = (BioModel) evt.getNewValue();
    if (newValue != null) {
        for (SimulationContext simulationContext : newValue.getSimulationContexts()) {
            simulationContext.addPropertyChangeListener(this);
        }
    }
}
Also used : BioModel(cbit.vcell.biomodel.BioModel) SimulationContext(cbit.vcell.mapping.SimulationContext)

Aggregations

BioModel (cbit.vcell.biomodel.BioModel)158 SimulationContext (cbit.vcell.mapping.SimulationContext)72 Simulation (cbit.vcell.solver.Simulation)53 XMLSource (cbit.vcell.xml.XMLSource)37 KeyValue (org.vcell.util.document.KeyValue)36 MathModel (cbit.vcell.mathmodel.MathModel)33 DataAccessException (org.vcell.util.DataAccessException)29 XmlParseException (cbit.vcell.xml.XmlParseException)28 File (java.io.File)28 Model (cbit.vcell.model.Model)27 BioModelInfo (org.vcell.util.document.BioModelInfo)25 MathDescription (cbit.vcell.math.MathDescription)24 IOException (java.io.IOException)24 BigString (org.vcell.util.BigString)22 Geometry (cbit.vcell.geometry.Geometry)21 UserCancelException (org.vcell.util.UserCancelException)20 User (org.vcell.util.document.User)20 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)19 SpeciesContext (cbit.vcell.model.SpeciesContext)17 VCDocument (org.vcell.util.document.VCDocument)16