Search in sources :

Example 16 with Structure

use of cbit.vcell.model.Structure in project vcell by virtualcell.

the class XmlReader method getMembrane.

/**
 * This method returns a Membrane object from a XML element.
 * Creation date: (4/4/2001 4:17:32 PM)
 * @return cbit.vcell.model.Membrane
 * @param param org.jdom.Element
 */
private Membrane getMembrane(Model model, Element param, List<Structure> featureList) throws XmlParseException {
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    Membrane newmembrane = null;
    // retrieve the key if there is one
    KeyValue key = null;
    String stringkey = param.getAttributeValue(XMLTags.KeyValueAttrTag);
    if (stringkey != null && stringkey.length() > 0 && this.readKeysFlag) {
        key = new KeyValue(stringkey);
    }
    // try to create new Membrane named "name"
    try {
        newmembrane = new Membrane(key, name);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("An error occurred while trying to create the Membrane object " + name, e);
    }
    // set inside feature
    String infeaturename = unMangle(param.getAttributeValue(XMLTags.InsideFeatureTag));
    String outfeaturename = unMangle(param.getAttributeValue(XMLTags.OutsideFeatureTag));
    String posFeatureName = unMangle(param.getAttributeValue(XMLTags.PositiveFeatureTag));
    String negFeatureName = unMangle(param.getAttributeValue(XMLTags.NegativeFeatureTag));
    Feature infeatureref = null;
    Feature outfeatureref = null;
    Feature posFeature = null;
    Feature negFeature = null;
    for (Structure s : featureList) {
        String sname = s.getName();
        if (sname.equals(infeaturename)) {
            infeatureref = (Feature) s;
        }
        if (sname.equals(outfeaturename)) {
            outfeatureref = (Feature) s;
        }
        if (sname.equals(posFeatureName)) {
            posFeature = (Feature) s;
        }
        if (sname.equals(negFeatureName)) {
            negFeature = (Feature) s;
        }
    }
    // set inside and outside features
    if (infeatureref != null) {
        model.getStructureTopology().setInsideFeature(newmembrane, infeatureref);
    }
    if (outfeatureref != null) {
        model.getStructureTopology().setOutsideFeature(newmembrane, outfeatureref);
    }
    // set positive & negative features
    if (posFeature != null) {
        model.getElectricalTopology().setPositiveFeature(newmembrane, posFeature);
    }
    if (negFeature != null) {
        model.getElectricalTopology().setNegativeFeature(newmembrane, negFeature);
    }
    // set MemVoltName
    if (param.getAttribute(XMLTags.MemVoltNameTag) == null) {
        throw new XmlParseException("Error reading membrane Voltage Name!");
    }
    String memvoltName = unMangle(param.getAttributeValue(XMLTags.MemVoltNameTag));
    try {
        newmembrane.getMembraneVoltage().setName(memvoltName);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("Error setting the membrane Voltage Name", e);
    }
    return newmembrane;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) KeyValue(org.vcell.util.document.KeyValue) Membrane(cbit.vcell.model.Membrane) Structure(cbit.vcell.model.Structure) Feature(cbit.vcell.model.Feature)

Example 17 with Structure

use of cbit.vcell.model.Structure in project vcell by virtualcell.

the class XmlReader method getDiagram.

/**
 * This method returns a Diagram object from a XML element.
 * Creation date: (4/4/2001 4:20:52 PM)
 * @return cbit.vcell.model.Diagram
 * @param param org.jdom.Element
 */
private Diagram getDiagram(Element param, Model model) throws XmlParseException {
    // get Attibutes
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    String structureName = unMangle(param.getAttributeValue(XMLTags.StructureAttrTag));
    Structure structureref = model.getStructure(structureName);
    if (structureref == null) {
        throw new XmlParseException("The structure " + structureName + "could not be resolved!");
    }
    // try to create the new Diagram
    Diagram newdiagram = new Diagram(structureref, name);
    // Add Nodereferences (Shapes)
    List<Element> children = param.getChildren();
    if (children.size() > 0) {
        List<NodeReference> nodeRefList = new ArrayList<>();
        for (int i = 0; i < children.size(); i++) {
            nodeRefList.add(getNodeReference(children.get(i)));
        }
        newdiagram.setNodeReferences(nodeRefList);
    }
    return newdiagram;
}
Also used : NodeReference(cbit.vcell.model.NodeReference) Element(org.jdom.Element) ArrayList(java.util.ArrayList) Structure(cbit.vcell.model.Structure) Diagram(cbit.vcell.model.Diagram)

Example 18 with Structure

use of cbit.vcell.model.Structure in project vcell by virtualcell.

the class Xmlproducer method getXML.

private Element getXML(MolecularType param) {
    Element e = new Element(XMLTags.RbmMolecularTypeTag);
    e.setAttribute(XMLTags.NameAttrTag, mangle(param.getName()));
    boolean anchorAll = param.isAnchorAll();
    e.setAttribute(XMLTags.RbmMolecularTypeAnchorAllAttrTag, String.valueOf(anchorAll));
    for (Structure ss : param.getAnchors()) {
        Element es = new Element(XMLTags.RbmMolecularTypeAnchorTag);
        es.setAttribute(XMLTags.StructureAttrTag, mangle(ss.getName()));
        e.addContent(es);
    }
    for (MolecularComponent pp : param.getComponentList()) {
        e.addContent(getXML(pp));
    }
    return e;
}
Also used : ParticleMolecularComponent(cbit.vcell.math.ParticleMolecularComponent) MolecularComponent(org.vcell.model.rbm.MolecularComponent) Element(org.jdom.Element) Structure(cbit.vcell.model.Structure)

Example 19 with Structure

use of cbit.vcell.model.Structure in project vcell by virtualcell.

the class BioModelEditorReactionTableModel method setValueAt.

public void setValueAt(Object value, int row, int column) {
    if (getModel() == null || value == null) {
        return;
    }
    try {
        ModelProcess modelProcess = getValueAt(row);
        if (modelProcess != null) {
            switch(column) {
                case COLUMN_NAME:
                    {
                        String inputValue = ((String) value);
                        inputValue = inputValue.trim();
                        modelProcess.setName(inputValue);
                        break;
                    }
                case COLUMN_EQUATION:
                    {
                        String inputValue = (String) value;
                        inputValue = inputValue.trim();
                        if (modelProcess instanceof ReactionStep) {
                            ReactionStep reactionStep = (ReactionStep) modelProcess;
                            ReactionParticipant[] rpArray = ModelProcessEquation.parseReaction(reactionStep, getModel(), inputValue);
                            for (ReactionParticipant rp : rpArray) {
                                SpeciesContext speciesContext = rp.getSpeciesContext();
                                if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
                                    bioModel.getModel().addSpecies(speciesContext.getSpecies());
                                    bioModel.getModel().addSpeciesContext(speciesContext);
                                }
                            }
                            reactionStep.setReactionParticipants(rpArray);
                        } else if (modelProcess instanceof ReactionRule) {
                            ReactionRule oldReactionRule = (ReactionRule) modelProcess;
                            // when editing an existing reaction rule
                            ReactionRule newReactionRule = (ReactionRule) RbmUtils.parseReactionRule(inputValue, oldReactionRule.getStructure(), bioModel);
                            if (newReactionRule != null) {
                                oldReactionRule.setProductPatterns(newReactionRule.getProductPatterns(), false, false);
                                oldReactionRule.setReactantPatterns(newReactionRule.getReactantPatterns(), false, false);
                            // String name = oldReactionRule.getName();
                            // RbmKineticLaw kl = oldReactionRule.getKineticLaw();
                            // Structure st = oldReactionRule.getStructure();
                            // getModel().getRbmModelContainer().removeReactionRule(oldReactionRule);
                            // newReactionRule.setName(name);
                            // newReactionRule.setKineticLaw(kl);
                            // newReactionRule.setStructure(st);
                            // getModel().getRbmModelContainer().addReactionRule(newReactionRule);
                            }
                        }
                        break;
                    }
                case COLUMN_STRUCTURE:
                    {
                        Structure s = (Structure) value;
                        modelProcess.setStructure(s);
                        break;
                    }
            }
        } else {
            switch(column) {
                case COLUMN_EQUATION:
                    {
                        if (getModel().getNumStructures() == 1) {
                            String inputValue = ((String) value);
                            inputValue = inputValue.trim();
                            if (inputValue.contains("(") && inputValue.contains(")")) {
                                ReactionRule reactionRule = (ReactionRule) RbmUtils.parseReactionRule(inputValue, getModel().getStructure(0), bioModel);
                                getModel().getRbmModelContainer().addReactionRule(reactionRule);
                            } else {
                                if (BioModelEditorRightSideTableModel.ADD_NEW_HERE_REACTION_TEXT.equals(inputValue)) {
                                    return;
                                }
                                ReactionStep reactionStep = getModel().createSimpleReaction(getModel().getStructure(0));
                                ReactionParticipant[] rpArray = ModelProcessEquation.parseReaction(reactionStep, getModel(), inputValue);
                                for (ReactionParticipant rp : rpArray) {
                                    SpeciesContext speciesContext = rp.getSpeciesContext();
                                    if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
                                        bioModel.getModel().addSpecies(speciesContext.getSpecies());
                                        bioModel.getModel().addSpeciesContext(speciesContext);
                                    }
                                }
                                reactionStep.setReactionParticipants(rpArray);
                            }
                        }
                        break;
                    }
            }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
        DialogUtils.showErrorDialog(ownerTable, e.getMessage(), e);
    }
}
Also used : ReactionRule(cbit.vcell.model.ReactionRule) ReactionStep(cbit.vcell.model.ReactionStep) ModelProcess(cbit.vcell.model.ModelProcess) SpeciesContext(cbit.vcell.model.SpeciesContext) Structure(cbit.vcell.model.Structure) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 20 with Structure

use of cbit.vcell.model.Structure in project vcell by virtualcell.

the class BioModelEditorRightSidePanel method initialize.

private void initialize() {
    addNewButton = new JButton("New Application");
    deleteButton = new JButton("Delete");
    textFieldSearch = new JTextField(10);
    textFieldSearch.putClientProperty("JTextField.variant", "search");
    table = new EditorScrollTable();
    tableModel = createTableModel();
    table.setModel(tableModel);
    table.setDefaultRenderer(Structure.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof Structure) {
                setText(((Structure) value).getName());
            }
            return this;
        }
    });
    addNewButton.addActionListener(eventHandler);
    deleteButton.addActionListener(eventHandler);
    deleteButton.setEnabled(false);
    textFieldSearch.getDocument().addDocumentListener(eventHandler);
    table.getSelectionModel().addListSelectionListener(eventHandler);
}
Also used : JTable(javax.swing.JTable) JButton(javax.swing.JButton) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) JTextField(javax.swing.JTextField) Component(java.awt.Component) Structure(cbit.vcell.model.Structure)

Aggregations

Structure (cbit.vcell.model.Structure)159 SpeciesContext (cbit.vcell.model.SpeciesContext)57 Membrane (cbit.vcell.model.Membrane)47 PropertyVetoException (java.beans.PropertyVetoException)42 Feature (cbit.vcell.model.Feature)36 Model (cbit.vcell.model.Model)35 ArrayList (java.util.ArrayList)35 ReactionStep (cbit.vcell.model.ReactionStep)33 Expression (cbit.vcell.parser.Expression)33 ReactionRule (cbit.vcell.model.ReactionRule)27 ExpressionException (cbit.vcell.parser.ExpressionException)27 BioModel (cbit.vcell.biomodel.BioModel)23 StructureMapping (cbit.vcell.mapping.StructureMapping)22 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)22 Species (cbit.vcell.model.Species)21 MolecularType (org.vcell.model.rbm.MolecularType)20 ReactionParticipant (cbit.vcell.model.ReactionParticipant)19 SimpleReaction (cbit.vcell.model.SimpleReaction)19 SimulationContext (cbit.vcell.mapping.SimulationContext)18 ModelException (cbit.vcell.model.ModelException)18