Search in sources :

Example 6 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData 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 7 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class MolecularTypePropertiesPanel method updateInterface.

public void updateInterface() {
    boolean bNonNullMolecularType = molecularType != null && bioModel != null;
    // annotationTextArea.setEditable(bNonNullMolecularType);
    if (bNonNullMolecularType) {
        VCMetaData vcMetaData = bioModel.getModel().getVcMetaData();
        String annText = vcMetaData.getFreeTextAnnotation(molecularType);
        // annotationTextArea.setText(annText);
        // annotationTextArea.setCaretPosition(0);
        // annotationTextArea.setText(molecularType.comment);
        // titleLabel.setText("Properties for " + molecularType.getDisplayType() + ": " + molecularType.getDisplayName());
        titleLabel.setText("Anchor Molecule");
        titleLabel.setToolTipText("Anchor a Molecule to a Structure to prevent it being moved to unwanted locations by a rule.");
        molecularTypeShapeList.clear();
        int maxYOffset = computeStatesVerticalOffset(molecularType);
        MolecularTypeLargeShape stls = new MolecularTypeLargeShape(xOffsetInitial, maxYOffset, molecularType, shapePanel, molecularType, issueManager);
        molecularTypeShapeList.add(stls);
        int maxXOffset = xOffsetInitial + stls.getWidth();
        Dimension preferredSize = new Dimension(maxXOffset + 100, maxYOffset + 60);
        shapePanel.setPreferredSize(preferredSize);
        shapePanel.repaint();
    // splitPane.getRightComponent().repaint();
    } else {
    // annotationTextArea.setText(null);
    }
    listLinkedPathwayObjects();
}
Also used : VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 8 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class ITextWriter method writeReactions.

// each reaction has its own table, ordered by the structures.
protected void writeReactions(Chapter physioChapter, Model model) throws DocumentException {
    if (model == null) {
        return;
    }
    Paragraph reactionParagraph = new Paragraph();
    reactionParagraph.add(new Chunk("Structures and Reactions Diagram").setLocalDestination(model.getName()));
    Section reactionDiagramSection = physioChapter.addSection(reactionParagraph, physioChapter.numberDepth() + 1);
    try {
        addImage(reactionDiagramSection, encodeJPEG(generateDocReactionsImage(model, null)));
    } catch (Exception e) {
        e.printStackTrace();
        throw new DocumentException(e.getClass().getName() + ": " + e.getMessage());
    }
    for (int i = 0; i < model.getNumStructures(); i++) {
        ReactionStep[] reactionSteps = model.getReactionSteps();
        ReactionStep rs = null;
        Table modifierTable = null;
        Table reactionTable = null;
        boolean firstTime = true;
        Section reactStructSection = null;
        for (int j = 0; j < reactionSteps.length; j++) {
            if (reactionSteps[j].getStructure() == model.getStructure(i)) {
                // can also use structureName1.equals(structureName2)
                if (firstTime) {
                    Paragraph linkParagraph = new Paragraph();
                    linkParagraph.add(new Chunk("Reaction(s) in " + model.getStructure(i).getName()).setLocalDestination(model.getStructure(i).getName()));
                    reactStructSection = physioChapter.addSection(linkParagraph, physioChapter.numberDepth() + 1);
                    firstTime = false;
                }
                rs = reactionSteps[j];
                String type;
                if (rs instanceof SimpleReaction) {
                    type = "Reaction";
                } else {
                    type = "Flux";
                }
                // write Reaction equation as a table
                // Get the image arrow cell depending on type of reactionStep : MassAction => double arrow, otherwise, forward arrow
                boolean bReversible = false;
                if (rs.getKinetics() instanceof MassActionKinetics) {
                    bReversible = true;
                }
                Cell arrowImageCell = getReactionArrowImageCell(bReversible);
                // Get reactants and products strings
                ReactionCanvas rc = new ReactionCanvas();
                rc.setReactionStep(rs);
                ReactionCanvasDisplaySpec rcdSpec = rc.getReactionCanvasDisplaySpec();
                String reactants = rcdSpec.getLeftText();
                String products = rcdSpec.getRightText();
                // Create table and add cells for reactants, arrow(s) images, products
                int[] widths = { 8, 1, 8 };
                reactionTable = getTable(3, 100, 0, 2, 2);
                // Add reactants as cell
                Cell tableCell = createCell(reactants, getBold());
                tableCell.setHorizontalAlignment(Cell.ALIGN_RIGHT);
                tableCell.setBorderColor(Color.white);
                reactionTable.addCell(tableCell);
                // add arrow(s) image as cell
                if (arrowImageCell != null) {
                    arrowImageCell.setHorizontalAlignment(Cell.ALIGN_CENTER);
                    arrowImageCell.setBorderColor(Color.white);
                    reactionTable.addCell(arrowImageCell);
                }
                // add products as cell
                tableCell = createCell(products, getBold());
                tableCell.setBorderColor(Color.white);
                reactionTable.addCell(tableCell);
                // reactionTable.setBorderColor(Color.white);
                reactionTable.setWidths(widths);
                // Identify modifiers,
                ReactionParticipant[] rpArr = rs.getReactionParticipants();
                Vector<ReactionParticipant> modifiersVector = new Vector<ReactionParticipant>();
                for (int k = 0; k < rpArr.length; k += 1) {
                    if (rpArr[k] instanceof Catalyst) {
                        modifiersVector.add(rpArr[k]);
                    }
                }
                // Write the modifiers in a separate table, if present
                if (modifiersVector.size() > 0) {
                    modifierTable = getTable(1, 50, 0, 1, 1);
                    modifierTable.addCell(createCell("Modifiers List", getBold(DEF_HEADER_FONT_SIZE), 1, 1, Element.ALIGN_CENTER, true));
                    StringBuffer modifierNames = new StringBuffer();
                    for (int k = 0; k < modifiersVector.size(); k++) {
                        modifierNames.append(((Catalyst) modifiersVector.elementAt(k)).getName() + "\n");
                    }
                    modifierTable.addCell(createCell(modifierNames.toString().trim(), getFont()));
                    modifiersVector.removeAllElements();
                }
                Section reactionSection = reactStructSection.addSection(type + " " + rs.getName(), reactStructSection.numberDepth() + 1);
                // Annotation
                VCMetaData vcMetaData = rs.getModel().getVcMetaData();
                if (vcMetaData.getFreeTextAnnotation(rs) != null) {
                    Table annotTable = getTable(1, 100, 1, 3, 3);
                    annotTable.addCell(createCell("Reaction Annotation", getBold(DEF_HEADER_FONT_SIZE), 1, 1, Element.ALIGN_CENTER, true));
                    annotTable.addCell(createCell(vcMetaData.getFreeTextAnnotation(rs), getFont()));
                    reactionSection.add(annotTable);
                // reactionSection.add(new Paragraph("\""+rs.getAnnotation()+"\""));
                }
                // reaction table
                if (reactionTable != null) {
                    reactionSection.add(reactionTable);
                    // re-set reactionTable
                    reactionTable = null;
                }
                if (modifierTable != null) {
                    reactionSection.add(modifierTable);
                    modifierTable = null;
                }
                // Write kinetics parameters, etc. in a table
                writeKineticsParams(reactionSection, rs);
            }
        }
    }
}
Also used : Table(com.lowagie.text.Table) SimpleReaction(cbit.vcell.model.SimpleReaction) ReactionCanvasDisplaySpec(cbit.vcell.model.ReactionCanvasDisplaySpec) ReactionCanvas(cbit.vcell.model.ReactionCanvas) Chunk(com.lowagie.text.Chunk) Section(com.lowagie.text.Section) DocumentException(com.lowagie.text.DocumentException) ExpressionException(cbit.vcell.parser.ExpressionException) Paragraph(com.lowagie.text.Paragraph) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) DocumentException(com.lowagie.text.DocumentException) ReactionStep(cbit.vcell.model.ReactionStep) MassActionKinetics(cbit.vcell.model.MassActionKinetics) Cell(com.lowagie.text.Cell) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Vector(java.util.Vector) Catalyst(cbit.vcell.model.Catalyst)

Example 9 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class MolecularType method setComment.

public void setComment(String comment) {
    if (comment == null) {
        return;
    }
    try {
        // set text from annotationTextField in free text annotation for species in vcMetaData (from model)
        if (model != null && model.getVcMetaData() != null) {
            VCMetaData vcMetaData = model.getVcMetaData();
            String oldValue = vcMetaData.getFreeTextAnnotation(this);
            if (!Compare.isEqualOrNull(oldValue, comment)) {
                vcMetaData.setFreeTextAnnotation(this, comment);
                firePropertyChange(PROPERTY_NAME_ANNOTATION, oldValue, comment);
            }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) PropertyVetoException(java.beans.PropertyVetoException)

Example 10 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class SBMLImporter method translateSBMLModel.

/**
 * translateSBMLModel:
 */
private void translateSBMLModel() {
    // Add Function Definitions (Lambda functions).
    addFunctionDefinitions();
    // Check for SBML features not supported in VCell; stop import process if present.
    try {
        checkForUnsupportedVCellFeaturesAndApplyDefaults();
    } catch (Exception e) {
        e.printStackTrace(System.out);
        throw new SBMLImportException(e.getMessage(), e);
    }
    // Create Virtual Cell Model with species, compartment, etc. and read in the 'values' from the SBML model
    // Add compartmentTypes (not handled in VCell)
    addCompartmentTypes();
    // Add spciesTypes (not handled in VCell)
    addSpeciesTypes();
    // when sbml non-spatial model uses a vCell reserved symbols x,y,z as
    Map<String, String> vcToSbmlNameMap = new HashMap<>();
    // species or reaction name (ex: in the BMDB database), we rename it
    Map<String, String> sbmlToVcNameMap = new HashMap<>();
    // could be defined by assignment rules
    try {
        // we just read and place them in a hash
        parseAssignmentRules();
    } catch (SBMLImportException sie) {
        throw sie;
    } catch (Exception ee) {
        ee.printStackTrace(System.out);
        throw new SBMLImportException(ee.getMessage(), ee);
    }
    // Add features/compartments
    VCMetaData vcMetaData = vcBioModel.getVCMetaData();
    Map<String, Expression> deferredStructureExpression = new HashMap<>();
    addCompartments(vcMetaData, deferredStructureExpression);
    // Add species/speciesContexts
    addSpecies(vcMetaData, vcToSbmlNameMap, sbmlToVcNameMap);
    // Add Parameters
    try {
        addParameters(vcToSbmlNameMap, sbmlToVcNameMap);
    } catch (Exception e) {
        e.printStackTrace(System.out);
        throw new SBMLImportException(e.getMessage(), e);
    }
    // If species variables were renamed from x,y,z, apply corrections to the hash
    try {
        readAssignmentRules(sbmlToVcNameMap);
    } catch (ExpressionException | PropertyVetoException e) {
        e.printStackTrace();
        throw new SBMLImportException(e.getMessage(), e);
    }
    // Set initial conditions on species
    // assignment rules must be present already because initConc set by an assignment rule
    // takes precedence over initConc value set on species
    setSpeciesInitialConditions(vcToSbmlNameMap);
    // Add InitialAssignments
    addInitialAssignments(deferredStructureExpression, sbmlToVcNameMap);
    // Add constraints (not handled in VCell)
    addConstraints();
    // Add Reactions
    addReactions(vcMetaData, vcToSbmlNameMap, sbmlToVcNameMap);
    // Check if we found and renamed successfully any reserved symbols used as species or reaction name
    for (Map.Entry<String, String> entry : sbmlToVcNameMap.entrySet()) {
        String sbmlName = entry.getKey();
        String vcName = entry.getValue();
        localIssueList.add(new Issue(vcBioModel, issueContext, IssueCategory.SBMLImport_ReservedSymbolUsed, "Reserved vCell symbol '" + sbmlName + "' found and replaced with '" + vcName + "' during import. Please check for correctness.", Issue.Severity.WARNING));
    }
    // for those vars can be read in).
    try {
        readRateRules(sbmlToVcNameMap);
        processParameters();
        processAssignmentRules();
        processRateRules();
    } catch (ExpressionException | SBMLException | XMLStreamException | PropertyVetoException e) {
        e.printStackTrace(System.out);
        throw new SBMLImportException(e.getMessage(), e);
    }
    // now that we have the parameters loaded, we can bind
    // TODO: use BMDB model Whitcomb to test comp size initialized with expression
    finalizeCompartments(deferredStructureExpression);
    // Sort VCell-model Structures in structure array according to reaction
    // adjacency and parentCompartment.
    Structure[] sortedStructures = StructureSorter.sortStructures(vcBioModel.getSimulationContext(0).getModel());
    try {
        vcBioModel.getSimulationContext(0).getModel().setStructures(sortedStructures);
    } catch (PropertyVetoException e1) {
        e1.printStackTrace(System.out);
        throw new SBMLImportException("Error while sorting compartments: " + e1.getMessage(), e1);
    }
    // Add Events
    addEvents(sbmlToVcNameMap);
    // (say, > 64), if so give warning.
    try {
        checkIdentifiersNameLength();
    } catch (Exception e) {
        e.printStackTrace(System.out);
        throw new SBMLImportException(e.getMessage(), e);
    }
    // Add geometry, if sbml model is spatial
    if (bSpatial) {
        addGeometry();
    }
    // post processing
    finalizeAssignmentRules();
    finalizeRateRules();
    postProcessing();
}
Also used : SBMLException(org.sbml.jsbml.SBMLException) Issue(org.vcell.util.Issue) HashMap(java.util.HashMap) XMLStreamException(javax.xml.stream.XMLStreamException) SbmlException(org.vcell.sbml.SbmlException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) PropertyVetoException(java.beans.PropertyVetoException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) SBMLException(org.sbml.jsbml.SBMLException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) ModelPropertyVetoException(cbit.vcell.model.ModelPropertyVetoException) ExpressionException(cbit.vcell.parser.ExpressionException) ExpressionException(cbit.vcell.parser.ExpressionException) PropertyVetoException(java.beans.PropertyVetoException) ModelPropertyVetoException(cbit.vcell.model.ModelPropertyVetoException) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) XMLStreamException(javax.xml.stream.XMLStreamException) Expression(cbit.vcell.parser.Expression) Structure(cbit.vcell.model.Structure) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)21 PropertyVetoException (java.beans.PropertyVetoException)10 BioModel (cbit.vcell.biomodel.BioModel)5 SimulationContext (cbit.vcell.mapping.SimulationContext)4 Structure (cbit.vcell.model.Structure)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)3 Model (cbit.vcell.model.Model)3 ReactionStep (cbit.vcell.model.ReactionStep)3 Simulation (cbit.vcell.solver.Simulation)3 IOException (java.io.IOException)3 MolecularType (org.vcell.model.rbm.MolecularType)3 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)2 DocumentEditorTreeFolderClass (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass)2 DocumentEditorTreeFolderNode (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode)2 CSGObject (cbit.vcell.geometry.CSGObject)2 GeometryInfo (cbit.vcell.geometry.GeometryInfo)2 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)2 Catalyst (cbit.vcell.model.Catalyst)2 ReactionParticipant (cbit.vcell.model.ReactionParticipant)2