Search in sources :

Example 1 with RelationshipObject

use of org.vcell.relationship.RelationshipObject in project vcell by virtualcell.

the class SpeciesPropertiesPanel method listLinkedPathwayObjects.

// wei's code
private String listLinkedPathwayObjects() {
    if (getSpeciesContext() == null) {
        return "no selected species";
    }
    if (bioModel == null || bioModel.getModel() == null) {
        return "no biomodel";
    }
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    String linkedPOlist = "";
    for (RelationshipObject relObject : bioModel.getRelationshipModel().getRelationshipObjects(getSpeciesContext())) {
        final BioPaxObject bpObject = relObject.getBioPaxObject();
        if (bpObject instanceof Entity) {
            JLabel label = new JLabel("<html><u>" + ((Entity) bpObject).getName().get(0) + "</u></html>");
            label.setForeground(Color.blue);
            label.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), new Object[] { bpObject });
                    }
                }
            });
            panel.add(label);
        }
    }
    linkedPOScrollPane.setViewportView(panel);
    return linkedPOlist;
}
Also used : JPanel(javax.swing.JPanel) Entity(org.vcell.pathway.Entity) MouseEvent(java.awt.event.MouseEvent) BioPaxObject(org.vcell.pathway.BioPaxObject) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 2 with RelationshipObject

use of org.vcell.relationship.RelationshipObject in project vcell by virtualcell.

the class MolecularTypeTableModel method getValueAt.

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Column col = Column.values()[columnIndex];
    MolecularType molecularType = getValueAt(rowIndex);
    if (molecularType == null) {
        if (col == Column.name) {
            return ADD_NEW_HERE_TEXT;
        }
    } else {
        switch(col) {
            case name:
                return molecularType.getName();
            case link:
                HashSet<RelationshipObject> relObjsHash = bioModel.getRelationshipModel().getRelationshipObjects(molecularType);
                if (relObjsHash != null && relObjsHash.size() > 0) {
                    return relObjsHash.iterator().next().getBioPaxObject();
                }
                return null;
            case bngl_pattern:
                return pattern(molecularType);
        }
    }
    return null;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 3 with RelationshipObject

use of org.vcell.relationship.RelationshipObject in project vcell by virtualcell.

the class ReactionRuleKineticsPropertiesPanel method listLinkedPathwayObjects.

private String listLinkedPathwayObjects() {
    if (reactionRule == null) {
        return "no selected rule";
    }
    if (bioModel == null || bioModel.getModel() == null) {
        return "no biomodel";
    }
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    String linkedPOlist = "";
    for (RelationshipObject relObject : bioModel.getRelationshipModel().getRelationshipObjects(reactionRule)) {
        if (relObject == null) {
            continue;
        }
        final BioPaxObject bpObject = relObject.getBioPaxObject();
        if (bpObject == null) {
            continue;
        }
        if (bpObject instanceof Entity) {
            String name = new String();
            if (((Entity) bpObject).getName().isEmpty()) {
                name = ((Entity) bpObject).getID();
            } else {
                name = ((Entity) bpObject).getName().get(0);
            }
            if (name.contains("#")) {
                name = name.substring(name.indexOf("#") + 1);
            }
            JLabel label = new JLabel("<html><u>" + name + "</u></html>");
            label.setForeground(Color.blue);
            label.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), new Object[] { bpObject });
                    }
                }
            });
            panel.add(label);
        }
    }
    Dimension dim = new Dimension(200, 20);
    panel.setMinimumSize(dim);
    panel.setPreferredSize(dim);
    linkedPOScrollPane.setViewportView(panel);
    return linkedPOlist;
}
Also used : JPanel(javax.swing.JPanel) Entity(org.vcell.pathway.Entity) MouseEvent(java.awt.event.MouseEvent) BioPaxObject(org.vcell.pathway.BioPaxObject) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject) Dimension(java.awt.Dimension) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 4 with RelationshipObject

use of org.vcell.relationship.RelationshipObject in project vcell by virtualcell.

the class BioModelEditorPathwayDiagramPanel method importIntoModel.

public void importIntoModel() {
    if (bioModel == null) {
        return;
    }
    String warningMessage = "";
    String warningMessage2 = "";
    int warningCount = 0;
    int warningCount2 = 0;
    String infoMessage = "";
    ArrayList<BioPaxObject> importedBPObjects = new ArrayList<BioPaxObject>();
    warningMessage = "The following pathway object(s) have been associated with object(s) in the physiology model:\n";
    warningMessage2 = "The following transport reaction(s) will NOT be converted to the physiology model:\n";
    warningCount = 0;
    warningCount2 = 0;
    infoMessage = "The following pathway object(s) have been coverted in the physiology model:\n\n";
    boolean hasMembrane = false;
    if (bioModel.getModel().getMembranes().size() > 0)
        hasMembrane = true;
    HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>();
    // convert group Object to regular biopaxObjects
    for (BioPaxObject bpo : getSelectedBioPaxObjects()) {
        if (bpo instanceof GroupObject) {
            selected.addAll(((GroupObject) bpo).computeGroupedBioPaxObjects());
        } else {
            selected.add(bpo);
        }
    }
    for (BioPaxObject bpo : selected) {
        if (bpo instanceof Conversion) {
            if (bpo instanceof Transport && !hasMembrane) {
                warningCount2++;
                if (((Conversion) bpo).getName().size() > 0)
                    warningMessage2 += "\nTransport: \'" + ((Conversion) bpo).getName().get(0) + "\'\n";
                else
                    warningMessage2 += "\nTransport: \'" + ((Conversion) bpo).getIDShort() + "\'\n";
            } else if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                importedBPObjects.add(bpo);
            } else {
                warningCount++;
                if (((Conversion) bpo).getName().size() > 0)
                    warningMessage += "\nReaction: \'" + ((Conversion) bpo).getName().get(0) + "\' =>\n";
                else
                    warningMessage += "\nReaction: \'" + ((Conversion) bpo).getIDShort() + "\' =>\n";
                for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                    warningMessage += "\t=> \'" + r.getBioModelEntityObject().getName() + "\'\n";
                }
            }
        } else if (bpo instanceof PhysicalEntity) {
            if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                importedBPObjects.add(bpo);
            } else {
                warningCount++;
                if (((PhysicalEntity) bpo).getName().size() > 0)
                    warningMessage += "\nSpecies: \'" + ((PhysicalEntity) bpo).getName().get(0) + "\' =>\n";
                else
                    warningMessage += "\nSpecies: \'" + ((PhysicalEntity) bpo).getIDShort() + "\' =>\n";
                for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                    warningMessage += "\t=> \'" + r.getBioModelEntityObject().getName() + "\'\n";
                }
            }
        }
    }
    // create import panel
    conversionPanel = new ConversionPanel();
    conversionPanel.setBioModel(bioModel);
    conversionPanel.setSelectionManager(getSelectionManager());
    // show warning message
    warningMessage2 += "\nNO membrane structures available in the physiology model.\n";
    if (warningCount2 > 0) {
        DialogUtils.showWarningDialog(conversionPanel, warningMessage2);
    }
    warningMessage += "\nThey will NOT be converted to the physiology model.\n";
    if (warningCount > 0) {
        DialogUtils.showWarningDialog(conversionPanel, warningMessage);
    }
    if (importedBPObjects.size() == 0) {
        return;
    }
    // set the selected objects to be the validly imported biopaxObject set
    conversionPanel.setBioPaxObjects(importedBPObjects);
    int returnCode = DialogUtils.showComponentOKCancelDialog(this, conversionPanel, "Import into Physiology");
    if (returnCode == JOptionPane.OK_OPTION) {
        PathwayMapping pathwayMapping = new PathwayMapping();
        try {
            // function I:
            // pass the table rows that contains user edited values to create Vcell object
            pathwayMapping.createBioModelEntitiesFromBioPaxObjects(bioModel, conversionPanel.getTableRows(), conversionPanel.isAddSubunits());
            for (BioPaxObject bpo : importedBPObjects) {
                if (bpo instanceof Conversion) {
                    infoMessage += "Reaction: \t\'";
                    for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                        infoMessage += r.getBioModelEntityObject().getName() + "\'\n";
                    }
                    infoMessage += "\n";
                } else if (bpo instanceof PhysicalEntity) {
                    infoMessage += "Species: \t\'";
                    for (RelationshipObject r : bioModel.getRelationshipModel().getRelationshipObjects(bpo)) {
                        infoMessage += r.getBioModelEntityObject().getName() + "\'\n";
                    }
                    infoMessage += "\n";
                }
            }
            DialogUtils.showInfoDialog(this, infoMessage);
            // jump the view to reaction diagram panel
            if (selectionManager != null) {
                selectionManager.setActiveView(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram));
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
            DialogUtils.showErrorDialog(this, "Errors occur when converting pathway objects to VCell bioModel objects.\n" + e.getMessage());
        }
    }
}
Also used : PathwayMapping(org.vcell.relationship.PathwayMapping) BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) Conversion(org.vcell.pathway.Conversion) RelationshipObject(org.vcell.relationship.RelationshipObject) ZoomRangeException(cbit.gui.graph.GraphResizeManager.ZoomRangeException) UtilCancelException(org.vcell.util.UtilCancelException) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Transport(org.vcell.pathway.Transport) HashSet(java.util.HashSet)

Example 5 with RelationshipObject

use of org.vcell.relationship.RelationshipObject in project vcell by virtualcell.

the class BioModelEditorConversionTableModel method createTableRow.

private ConversionTableRow createTableRow(BioPaxObject bpObject, String interactionId, String interactionLabel, String participantType, double stoich, HashSet<RelationshipObject> relationshipObjects) {
    String location = "";
    ConversionTableRow conversionTableRow = new ConversionTableRow(bpObject);
    conversionTableRow.setInteractionId(interactionId);
    conversionTableRow.setInteractionLabel(interactionLabel);
    conversionTableRow.setParticipantType(participantType);
    // stoichiometry and location
    if (participantType.equals("Reactant") || participantType.equals("Product")) {
        // stoichiometry
        if (stoich != 0)
            conversionTableRow.setStoich(stoich);
        else
            conversionTableRow.setStoich(1.0);
        // location
        // if(((PhysicalEntity)bpObject).getCellularLocation() != null && ((PhysicalEntity)bpObject).getCellularLocation().getTerm().size()>0)
        // location = ((PhysicalEntity)bpObject).getCellularLocation().getTerm().get(0);
        // else
        location = bioModel.getModel().getStructures()[0].getName();
        conversionTableRow.setLocation(location);
    } else {
        conversionTableRow.setStoich(1.0);
        // else
        if (bpObject instanceof Transport) {
            if (bioModel.getModel().getMembranes().size() > 0)
                location = bioModel.getModel().getMembranes().get(0).getName();
            else
                location = bioModel.getModel().getStructures()[0].getName();
        } else
            location = bioModel.getModel().getStructures()[0].getName();
        conversionTableRow.setLocation(location);
    }
    // id
    if (relationshipObjects == null) {
        if (bpObject instanceof Entity) {
            String id = (BioPAXUtil.getName((Entity) bpObject) + "_" + location).trim();
            if (isValid(id))
                conversionTableRow.setId(id);
            else
                conversionTableRow.setId(changeID(id));
        }
    } else {
        String id = null;
        for (RelationshipObject relationshipObject : relationshipObjects) {
            if (relationshipObject.getBioModelEntityObject() instanceof MolecularType) {
                id = relationshipObject.getBioModelEntityObject().getName();
                location = "";
            } else if (relationshipObject.getBioModelEntityObject().getStructure().getName().equalsIgnoreCase(location)) {
                id = relationshipObject.getBioModelEntityObject().getName();
            }
        }
        if (id != null) {
            // the linked bmObject with the same location will be used
            conversionTableRow.setId(id);
        } else {
            // a new bmObject will be created if no linked bmObject in the same location
            if (bpObject instanceof Entity) {
                id = (BioPAXUtil.getName((Entity) bpObject) + "_" + location).trim();
                if (isValid(id))
                    conversionTableRow.setId(id);
                else
                    conversionTableRow.setId(changeID(id));
            }
        }
    }
    return conversionTableRow;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) Entity(org.vcell.pathway.Entity) PhysicalEntity(org.vcell.pathway.PhysicalEntity) ConversionTableRow(org.vcell.relationship.ConversionTableRow) Transport(org.vcell.pathway.Transport) RelationshipObject(org.vcell.relationship.RelationshipObject)

Aggregations

RelationshipObject (org.vcell.relationship.RelationshipObject)24 ArrayList (java.util.ArrayList)11 BioPaxObject (org.vcell.pathway.BioPaxObject)11 Entity (org.vcell.pathway.Entity)10 ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)7 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)6 MolecularType (org.vcell.model.rbm.MolecularType)6 PhysicalEntity (org.vcell.pathway.PhysicalEntity)6 JLabel (javax.swing.JLabel)5 JPanel (javax.swing.JPanel)5 SpeciesContext (cbit.vcell.model.SpeciesContext)4 Dimension (java.awt.Dimension)4 MouseAdapter (java.awt.event.MouseAdapter)4 MouseEvent (java.awt.event.MouseEvent)4 BoxLayout (javax.swing.BoxLayout)4 Conversion (org.vcell.pathway.Conversion)4 ReactionStep (cbit.vcell.model.ReactionStep)3 ModelProcessEquation (cbit.gui.ModelProcessEquation)2 Shape (cbit.gui.graph.Shape)2 ModelProcess (cbit.vcell.model.ModelProcess)2