Search in sources :

Example 6 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class AnnotationMapping method annotation2BioPaxObject.

public String annotation2BioPaxObject(BioModel bioModel, Identifiable identifiable) {
    String name = "";
    String type = "";
    ArrayList<String> componentInfo = getComponentInfo(bioModel, identifiable);
    if (componentInfo.size() > 0) {
        name = componentInfo.get(0);
        type = componentInfo.get(1);
    }
    String info = type + " : " + name;
    HashMap<String, String> refInfo = getRefInfo(bioModel, identifiable);
    // otherwise, create object and add link
    if (type.equals(VCID.CLASS_SPECIES)) {
        // lookup name by speciesContext
        ArrayList<SpeciesContext> speciesContextArrList = new ArrayList<SpeciesContext>(Arrays.asList(new SpeciesContext[] { bioModel.getModel().getSpeciesContext(name) }));
        if (speciesContextArrList.get(0) == null) {
            speciesContextArrList.clear();
            // lookup name by species
            for (int i = 0; i < bioModel.getModel().getSpeciesContexts().length; i++) {
                if (bioModel.getModel().getSpeciesContexts()[i].getSpecies().getCommonName().equals(name)) {
                    speciesContextArrList.add(bioModel.getModel().getSpeciesContexts()[i]);
                }
            }
        }
        for (int i = 0; i < speciesContextArrList.size(); i++) {
            SpeciesContext speciesContext = speciesContextArrList.get(i);
            if (bioModel.getRelationshipModel().getRelationshipObjects(speciesContext).size() == 0) {
                ArrayList<Xref> xRef = getXrefs(bioModel, refInfo);
                ArrayList<String> refName = getNameRef(xRef, name);
                BioPaxObject bpObject = bioModel.getPathwayModel().findFromNameAndType(refName.get(0), EntityImpl.TYPE_PHYSICALENTITY);
            // 
            // Commenting out legacy code from the times when we didn't have proper annotation visualization
            // What we were doing below was to create a bioPax object, link it to the species and create
            // copies of the annotations in order to be able to navigate to external databases through XRef
            // Commenting out this code since we can now navigate to external databases from the annotation panel
            // 
            // if(bpObject == null){
            // bpObject = createPhysicalEntity(xRef, refName, name);
            // bioModel.getPathwayModel().add(bpObject);
            // }
            // if(bpObject != null && !isLinked(bioModel, bpObject, speciesContext)) {
            // // create linkage
            // RelationshipObject newRelationship = new RelationshipObject(speciesContext, bpObject);
            // bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
            // return info;
            // }
            }
        }
    } else if (type.equals(VCID.CLASS_BIOMODEL)) {
    // BioPaxObject bpObject = bioModel.getPathwayModel().findFromName(refName.get(0), "Pathway");
    // if(bpObject == null){
    // bpObject = createPathway(componentInfo, refInfo);
    // bioModel.getPathwayModel().add(bpObject);
    // return info;
    // }
    } else if (type.equals(VCID.CLASS_REACTION_STEP)) {
        ReactionStep reactionStep = bioModel.getModel().getReactionStep(name);
        ArrayList<Xref> xRef = getXrefs(bioModel, refInfo);
        ArrayList<String> refName = getNameRef(xRef, name);
        if (bioModel.getRelationshipModel().getRelationshipObjects(reactionStep).size() == 0) {
            BioPaxObject bpObject = bioModel.getPathwayModel().findFromNameAndType(refName.get(0), EntityImpl.TYPE_INTERACTION);
        // 
        // We are eliminating some obsolete code, see above the species context comment
        // 
        // if(bpObject == null){
        // bpObject = createInteraction(reactionStep, xRef, refName);
        // bioModel.getPathwayModel().add(bpObject);
        // }
        // if(bpObject != null && !isLinked(bioModel, bpObject, reactionStep)) {
        // // create linkage
        // RelationshipObject newRelationship = new RelationshipObject(reactionStep, bpObject);
        // bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
        // return info;
        // }
        }
    }
    return null;
}
Also used : Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) BioPaxObject(org.vcell.pathway.BioPaxObject) ReactionStep(cbit.vcell.model.ReactionStep) ArrayList(java.util.ArrayList) SpeciesContext(cbit.vcell.model.SpeciesContext)

Example 7 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class AnnotationMapping method isSmallMolecule.

// private Pathway createPathway(ArrayList<String> componentInfo, HashMap<String, String> refInfo){
// Pathway pathway = new Pathway();
// ArrayList<String> name = getName(componentInfo);
// pathway.setName(name);
// pathway.setxRef(getXrefs(refInfo));
// pathway.setID(name.get(0));
// return pathway;
// }
private boolean isSmallMolecule(ArrayList<Xref> xRef) {
    HashSet<String> refDB = new HashSet<String>();
    for (Xref xref : xRef) {
        String ref = xref.getDb().toLowerCase();
        if (ref.contains("chebi"))
            ref = "chebi";
        refDB.add(ref);
    }
    if (refDB.contains("chebi") && !refDB.contains("uniprot"))
        return true;
    return false;
}
Also used : Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) HashSet(java.util.HashSet)

Example 8 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class BioPaxObjectPropertiesPanel method initialize.

private void initialize() {
    try {
        table = new ScrollTable();
        tableModel = new BioPaxObjectPropertiesTableModel(table);
        table.setModel(tableModel);
        details = new JTextPane();
        details.setContentType("text/html");
        details.setEditable(false);
        JScrollPane scrl = new JScrollPane(details);
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    BioPaxObjectProperty property = tableModel.getValueAt(table.getSelectedRow());
                    if (property != null) {
                        final String htmlStart = "<html><font face = \"Arial\"><font size =\"-2\">";
                        final String htmlEnd = "</font></font></html>";
                        if (!property.getDetails().isEmpty()) {
                            details.setText(htmlStart + property.getDetails() + htmlEnd);
                        } else if ((property.value != null) && !property.value.isEmpty()) {
                            String text = FormatDetails(property);
                            details.setText(htmlStart + text + htmlEnd);
                        } else {
                            details.setText(htmlStart + "row: " + table.getSelectedRow() + ", col: " + table.getSelectedColumn() + htmlEnd);
                        }
                    }
                }
            }
        });
        splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getEnclosingScrollPane(), scrl);
        splitPane.setOneTouchExpandable(true);
        splitPane.setDividerLocation(150);
        // provide minimum sizes for the two components in the split pane
        Dimension minimumSize = new Dimension(100, 50);
        table.getEnclosingScrollPane().setMinimumSize(minimumSize);
        scrl.setMinimumSize(minimumSize);
        setLayout(new BorderLayout());
        // add(table.getEnclosingScrollPane(), BorderLayout.CENTER);
        // add(details, BorderLayout.CENTER);
        add(splitPane, BorderLayout.CENTER);
        setBackground(Color.white);
        table.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    // launch the browser when double click on hyperlinks
                    Point pt = e.getPoint();
                    int crow = table.rowAtPoint(pt);
                    int ccol = table.columnAtPoint(pt);
                    if (table.convertColumnIndexToModel(ccol) == BioPaxObjectPropertiesTableModel.Column_Value) {
                        BioPaxObjectProperty property = tableModel.getValueAt(crow);
                        BioPaxObject bioPaxObject = property.bioPaxObject;
                        if (bioPaxObject == null) {
                            BioModelEntityObject bioModelEntityObject = property.bioModelEntityObject;
                            if (bioModelEntityObject != null) {
                                if (bioModelEntityObject instanceof SpeciesContext) {
                                    selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram), new Object[] { bioModelEntityObject });
                                } else if (bioModelEntityObject instanceof MolecularType) {
                                    selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.species_definitions), new Object[] { bioModelEntityObject });
                                } else if (bioModelEntityObject instanceof SimpleReaction) {
                                    selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram), new Object[] { bioModelEntityObject });
                                }
                            } else if (((Entity) BioPaxObjectPropertiesPanel.this.bioPaxObject).getFormalNames() == null || ((Entity) BioPaxObjectPropertiesPanel.this.bioPaxObject).getFormalNames().size() == 0) {
                                lookupFormalName(crow);
                            }
                        } else if (bioPaxObject instanceof Xref) {
                            // if xRef, get url
                            String url = ((Xref) bioPaxObject).getURL();
                            DialogUtils.browserLauncher(BioPaxObjectPropertiesPanel.this, url, "Wrong URL.");
                        } else if (bioPaxObject instanceof SBEntity) {
                            // TODO: kineticLaw
                            SBEntity sbE = (SBEntity) bioPaxObject;
                            if (sbE.getID().contains("kineticLaw")) {
                                // String url = "http://sabio.h-its.org/sabioRestWebServices/kineticLaws/" + sbE.getID().substring(sbE.getID().indexOf("kineticLaw") + 10);
                                String url = BeanUtils.getDynamicClientProperties().getProperty(PropertyLoader.SABIO_DIRECT_IFRAME_URL) + sbE.getID().substring(sbE.getID().indexOf("kineticLaw") + 10);
                                DialogUtils.browserLauncher(BioPaxObjectPropertiesPanel.this, url, "Wrong URL.");
                            }
                        }
                    }
                }
            }
        });
        // --- end of addMouseListener()
        table.getColumnModel().getColumn(BioPaxObjectPropertiesTableModel.Column_Value).setCellRenderer(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 (column == BioPaxObjectPropertiesTableModel.Column_Value) {
                    BioPaxObjectProperty property = tableModel.getValueAt(row);
                    BioPaxObject bpObject = property.bioPaxObject;
                    String text = property.value;
                    // colorize BLUE and add surround text with <html></html> tags
                    if (bpObject == null) {
                        BioModelEntityObject bioModelEntityObject = property.bioModelEntityObject;
                        if (bioModelEntityObject != null) {
                            if (!isSelected) {
                                setForeground(Color.blue);
                            }
                            setText("<html><u>" + text + "</u></html>");
                        }
                    } else {
                        if (bpObject instanceof Xref) {
                            String url = ((Xref) bpObject).getURL();
                            if (url != null) {
                                setToolTipText(url);
                                if (!isSelected) {
                                    setForeground(Color.blue);
                                }
                                setText("<html><u>" + text + "</u></html>");
                            }
                        } else if (bpObject instanceof SBEntity) {
                            String url = ((SBEntity) bpObject).getID();
                            if (url.contains("kineticLaw")) {
                                setToolTipText(url);
                                if (!isSelected) {
                                    setForeground(Color.blue);
                                }
                                if (url.contains("http")) {
                                    setText("<html><u>" + text + "</u></html>");
                                }
                            }
                        }
                    }
                }
                BioPaxObjectProperty property = tableModel.getValueAt(row);
                if (!property.tooltip.isEmpty()) {
                    setToolTipText(property.tooltip);
                }
                return this;
            }
        });
    // --- end of setCellRenderer()
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : SBEntity(org.vcell.pathway.sbpax.SBEntity) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Entity(org.vcell.pathway.Entity) ScrollTable(org.vcell.util.gui.ScrollTable) BioPaxObject(org.vcell.pathway.BioPaxObject) ListSelectionEvent(javax.swing.event.ListSelectionEvent) SpeciesContext(cbit.vcell.model.SpeciesContext) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) SBEntity(org.vcell.pathway.sbpax.SBEntity) JTextPane(javax.swing.JTextPane) Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) BorderLayout(java.awt.BorderLayout) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) SimpleReaction(cbit.vcell.model.SimpleReaction) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) Point(java.awt.Point) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) MolecularType(org.vcell.model.rbm.MolecularType) JTable(javax.swing.JTable) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) JSplitPane(javax.swing.JSplitPane)

Example 9 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class PathwayProducerBiopax3 method addContentControlledVocabulary.

// term	String		multiple
// xref	Xref		multiple
private Element addContentControlledVocabulary(BioPaxObject bpObject, Element element) {
    element = addContentUtilityClass(bpObject, element);
    ControlledVocabulary ob = (ControlledVocabulary) bpObject;
    Element tmpElement = null;
    if (ob.getxRef() != null && ob.getxRef().size() > 0) {
        List<Xref> list = ob.getxRef();
        for (Xref item : list) {
            tmpElement = new Element("xref", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getTerm() != null && ob.getTerm().size() > 0) {
        List<String> list = ob.getTerm();
        for (String item : list) {
            tmpElement = new Element("term", bp);
            tmpElement.setAttribute("datatype", schemaString, rdf);
            tmpElement.setText(item);
            element.addContent(tmpElement);
        }
    }
    return element;
}
Also used : ControlledVocabulary(org.vcell.pathway.ControlledVocabulary) Xref(org.vcell.pathway.Xref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) Element(org.jdom.Element) PathwayXMLHelper.schemaString(org.vcell.pathway.PathwayXMLHelper.schemaString)

Example 10 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class PathwayProducerBiopax3 method addContentEntityReference.

// memberEntityReference	EntityReference					multiple
// entityReferenceType		EntityReferenceTypeVocabulary	single
// entityFeature			EntityFeature					multiple
// name					String							multiple
// xref					Xref							multiple
// evidence				Evidence						multiple
private Element addContentEntityReference(BioPaxObject bpObject, Element element) {
    element = addContentUtilityClass(bpObject, element);
    EntityReference ob = (EntityReference) bpObject;
    Element tmpElement = null;
    if (ob.getMemberEntityReference() != null && ob.getMemberEntityReference().size() > 0) {
        List<EntityReference> list = ob.getMemberEntityReference();
        for (EntityReference item : list) {
            tmpElement = new Element("memberEntityReference", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getEntityReferenceType() != null) {
        tmpElement = new Element("entityReferenceType", bp);
        addIDToProperty(tmpElement, ob.getEntityReferenceType());
        mustPrintObject(ob.getEntityReferenceType());
        element.addContent(tmpElement);
    }
    if (ob.getEntityFeature() != null && ob.getEntityFeature().size() > 0) {
        List<EntityFeature> list = ob.getEntityFeature();
        for (EntityFeature item : list) {
            tmpElement = new Element("entityFeature", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getName() != null && ob.getName().size() > 0) {
        List<String> list = ob.getName();
        for (String item : list) {
            tmpElement = new Element("name", bp);
            tmpElement.setAttribute("datatype", schemaString, rdf);
            tmpElement.setText(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getxRef() != null && ob.getxRef().size() > 0) {
        List<Xref> list = ob.getxRef();
        for (Xref item : list) {
            tmpElement = new Element("xref", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getEvidence() != null && ob.getEvidence().size() > 0) {
        List<Evidence> list = ob.getEvidence();
        for (Evidence item : list) {
            tmpElement = new Element("evidence", bp);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    return element;
}
Also used : EntityFeature(org.vcell.pathway.EntityFeature) Xref(org.vcell.pathway.Xref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) Element(org.jdom.Element) EntityReference(org.vcell.pathway.EntityReference) Evidence(org.vcell.pathway.Evidence) PathwayXMLHelper.schemaString(org.vcell.pathway.PathwayXMLHelper.schemaString)

Aggregations

Xref (org.vcell.pathway.Xref)20 PublicationXref (org.vcell.pathway.PublicationXref)18 RelationshipXref (org.vcell.pathway.RelationshipXref)18 UnificationXref (org.vcell.pathway.UnificationXref)12 Element (org.jdom.Element)9 BioPaxObject (org.vcell.pathway.BioPaxObject)7 ArrayList (java.util.ArrayList)5 PathwayXMLHelper.schemaString (org.vcell.pathway.PathwayXMLHelper.schemaString)5 PhysicalEntity (org.vcell.pathway.PhysicalEntity)5 HashSet (java.util.HashSet)4 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)3 Entity (org.vcell.pathway.Entity)3 GroupObject (org.vcell.pathway.GroupObject)3 SBEntity (org.vcell.pathway.sbpax.SBEntity)3 SimpleReaction (cbit.vcell.model.SimpleReaction)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 Namespace (org.jdom.Namespace)2 MolecularType (org.vcell.model.rbm.MolecularType)2 XrefProxy (org.vcell.pathway.persistence.BiopaxProxy.XrefProxy)2 RelationshipObject (org.vcell.relationship.RelationshipObject)2