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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations