Author: rodche
Date: 2011-09-20 13:53:22 -0700 (Tue, 20 Sep 2011)
New Revision: 26888
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/MapBioPaxToCytoscape.java
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/MapBioPaxToCytoscapeImpl.java
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/ExportAsBioPAXTask.java
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/NetworkListenerImpl.java
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/AttributeUtil.java
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/view/BioPaxDetailsPanel.java
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/util/BioPaxUtil.java
Log:
Continue with re-factoring and clean-up (e.g., several attribute colums are now
created in the hidden_attrs namespace; better api - to use from the cpath2-impl
core plugin, etc..)
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/MapBioPaxToCytoscape.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/MapBioPaxToCytoscape.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/MapBioPaxToCytoscape.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -1,6 +1,7 @@
package org.cytoscape.biopax;
import org.biopax.paxtools.model.BioPAXElement;
+import org.biopax.paxtools.model.Model;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.CyNetworkView;
@@ -79,7 +80,7 @@
/**
- * Maps a BioPAX model (internal) to a new CyNetwork.
+ * Maps a BioPAX model (set internally) to a new CyNetwork.
*
* @param networkName
* @return
@@ -89,9 +90,10 @@
/**
* Maps BioPAX element properties to CyNode attributes.
* @param element BioPAX Object.
- * @param node
+ * @param node
+ * @param network
*/
- void createAttributesFromProperties(BioPAXElement element, CyNode node);
+ void createAttributesFromProperties(BioPAXElement element, CyNode node,
CyNetwork network);
void customNodes(CyNetworkView networkView);
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxNetworkViewReaderTask.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -96,7 +96,7 @@
+ " BioPAX elements");
//normalize/infer properties: displayName, cellularLocation,
organism, dartaSource
- fixDisplayName(model);
+ BioPaxUtil.fixDisplayName(model);
ModelUtils mu = new ModelUtils(model);
mu.inferPropertyFromParent("dataSource");
mu.inferPropertyFromParent("organism");
@@ -166,35 +166,5 @@
return view;
}
-
-
- private void fixDisplayName(Model model) {
- if (log.isInfoEnabled())
- log.info("Trying to auto-fix 'null' displayName...");
- // where it's null, set to the shortest name if possible
- for (Named e : model.getObjects(Named.class)) {
- if (e.getDisplayName() == null) {
- if (e.getStandardName() != null) {
- e.setDisplayName(e.getStandardName());
- } else if (!e.getName().isEmpty()) {
- String dsp =
e.getName().iterator().next();
- for (String name : e.getName()) {
- if (name.length() <
dsp.length())
- dsp = name;
- }
- e.setDisplayName(dsp);
- }
- }
- }
- // if required, set PE name to (already fixed) ER's name...
- for(EntityReference er :
model.getObjects(EntityReference.class)) {
- for(SimplePhysicalEntity spe :
er.getEntityReferenceOf()) {
- if(spe.getDisplayName() == null ||
spe.getDisplayName().trim().length() == 0) {
- if(er.getDisplayName() != null &&
er.getDisplayName().trim().length() > 0) {
-
spe.setDisplayName(er.getDisplayName());
- }
- }
- }
- }
- }
+
}
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/MapBioPaxToCytoscapeImpl.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/MapBioPaxToCytoscapeImpl.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/MapBioPaxToCytoscapeImpl.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -25,7 +25,6 @@
import org.biopax.paxtools.model.level3.Complex;
import org.biopax.paxtools.model.level3.Control;
import org.biopax.paxtools.model.level3.ControlType;
-import org.biopax.paxtools.model.level3.ControlledVocabulary;
import org.biopax.paxtools.model.level3.Controller;
import org.biopax.paxtools.model.level3.Conversion;
import org.biopax.paxtools.model.level3.Entity;
@@ -105,7 +104,8 @@
// BioPAX ID (URI) to CyNode map
// remark: nodes's CyTable will also have 'URI' (RDF Id) column
- private final Map<String, CyNode> uriToCyNodeMap = new HashMap<String,
CyNode>();
+ private final Map<BioPAXElement, CyNode>
+ uriToCyNodeMap = new HashMap<BioPAXElement, CyNode>();
/**
* Inner class to store a given nodes's
@@ -174,20 +174,14 @@
@Override
public CyNetwork createCyNetwork(String networkName) {
CyNetwork network = networkFactory.getInstance();
-
- //TODO create BioPaxUtil.PRIVATE_TABLE_NAME private table
-
+
// First, create nodes for all Entity class objects
- // (skip creating attributes for now, except for the URI)
createEntityNodes(network);
-
+
+ // create edges
createInteractionEdges(network);
createComplexEdges(network);
- // traverse the entire model to
- // generate node attributes from BioPAX properties
- createAttributesFromProperties(network);
-
// Finally, set network attributes:
// name
@@ -203,7 +197,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
new SimpleIOHandler().convertToOWL(model, baos);
- AttributeUtil.set(network,
BioPaxUtil.PRIVATE_TABLE_NAME,
+ AttributeUtil.set(network, CyNetwork.HIDDEN_ATTRS,
BioPaxUtil.BIOPAX_DATA,
baos.toString("UTF-8"), String.class);
} catch (Exception e) {
log.error("Serializing BioPAX to RDF/XML string
failed.", e);
@@ -224,44 +218,13 @@
if(bpe instanceof Pathway)
continue;
- String id = bpe.getRDFId();
// Create node symbolizing the interaction
CyNode node = network.addNode();
- uriToCyNodeMap.put(id, node);
-
- // set the most important attributes
- AttributeUtil.set(node, BIOPAX_RDF_ID, bpe.getRDFId(),
String.class);
- //AttributeUtil.set(node, BIOPAX_ENTITY_TYPE,
BioPaxUtil.getType(bpe), String.class);
- AttributeUtil.set(node, BIOPAX_ENTITY_TYPE,
bpe.getModelInterface().getSimpleName(), String.class);
+ uriToCyNodeMap.put(bpe, node);
+
+ // traverse
+ createAttributesFromProperties(bpe, node, network);
- // add a piece of the BioPAX (RDF/XML without
parent|child elements)
-
- String owl = BioPaxUtil.toOwl(bpe); // (requires
common-lang-2.4 bundle to be started)
- AttributeUtil.set(node,
BioPaxUtil.PRIVATE_TABLE_NAME,BioPaxUtil.BIOPAX_DATA, owl, String.class);
-
- String name =
BioPaxUtil.truncateLongStr(BioPaxUtil.getNodeName(bpe) + "");
-
- if (!(bpe instanceof Interaction)) {
- // get chemical modification & cellular
location attributes
- NodeAttributesWrapper
chemicalModificationsWrapper = getInteractionChemicalModifications(bpe);
- // add modifications to the label/name
- String modificationsString =
getModificationsString(chemicalModificationsWrapper);
- name += modificationsString;
- // add cellular location to the label/name
- if(bpe instanceof PhysicalEntity) {
- CellularLocationVocabulary cl =
((PhysicalEntity) bpe).getCellularLocation();
- if(cl != null) {
- String clAbbr =
BioPaxUtil.getAbbrCellLocation(cl.toString())
- .replaceAll("\\[|\\]",
"");
- name += (clAbbr.length() > 0) ?
("\n" + clAbbr) : "";
- }
- }
- // set node attributes
- setChemicalModificationAttributes(node,
chemicalModificationsWrapper);
- }
-
- AttributeUtil.set(node, CyNode.NAME, name,
String.class);
-
// update progress bar
double perc = (double) i++ / entities.size();
taskMonitor.setProgress(perc);
@@ -308,14 +271,12 @@
private void createComplexEdges(CyNetwork network) {
// interate through all pe's
for (Complex complexElement : model.getObjects(Complex.class)) {
- // get id
- String id = complexElement.getRDFId();
// get node
- CyNode complexCyNode = uriToCyNodeMap.get(id);
+ CyNode complexCyNode =
uriToCyNodeMap.get(complexElement);
// get all components. There can be 0 or more
for (PhysicalEntity member :
complexElement.getComponent())
{
- CyNode complexMemberCyNode =
uriToCyNodeMap.get(member.getRDFId());
+ CyNode complexMemberCyNode =
uriToCyNodeMap.get(member);
// create edge, set attributes
CyEdge edge = network.addEdge(complexCyNode,
complexMemberCyNode, true);
AttributeUtil.set(edge, BIOPAX_EDGE_TYPE,
"contains", String.class);
@@ -359,8 +320,8 @@
private void linkNodes(CyNetwork network, BioPAXElement bpeA,
BioPAXElement bpeB, String type)
{
// Note: getCyNode also assigns cellular location attribute...
- CyNode nodeA = uriToCyNodeMap.get(bpeA.getRDFId());
- CyNode nodeB = uriToCyNodeMap.get(bpeB.getRDFId());
+ CyNode nodeA = uriToCyNodeMap.get(bpeA);
+ CyNode nodeB = uriToCyNodeMap.get(bpeB);
CyEdge edge = null;
if (type.equals("right") || type.equals("cofactor")
|| type.equals("participant")) {
@@ -526,25 +487,6 @@
}
}
-
- /**
- * Maps BioPAX properties to node attributes.
- *
- */
- public void createAttributesFromProperties(CyNetwork network) {
- for (CyNode node : network.getNodeList()) {
- // get node element
- String biopaxID = node.getCyRow().get(BIOPAX_RDF_ID,
String.class);
- BioPAXElement resource = model.getByID(biopaxID);
-
- // traverse
- createAttributesFromProperties(resource, node);
-
- // create custom (convenience?) attributes, mainly - from xrefs
- createExtraXrefAttributes(resource, network, node);
- }
- }
-
private void createExtraXrefAttributes(BioPAXElement resource, CyNetwork
network, CyNode node) {
// the following code should replace the old way to set
@@ -559,7 +501,7 @@
// ihop links
String stringRef = addIHOPLinks(network, resource);
if (stringRef != null) {
- AttributeUtil.set(node, BIOPAX_IHOP_LINKS, stringRef,
String.class);
+ AttributeUtil.set(node, CyNetwork.HIDDEN_ATTRS,
BIOPAX_IHOP_LINKS, stringRef, String.class);
}
List<String> allxList = new ArrayList<String>();
@@ -614,15 +556,15 @@
}
AttributeUtil.set(node, BIOPAX_XREF_IDS, allxList,
String.class);
- AttributeUtil.set(node, BioPaxUtil.PRIVATE_TABLE_NAME,
BIOPAX_UNIFICATION_REFERENCES, unifxfList, String.class);
- AttributeUtil.set(node, BioPaxUtil.PRIVATE_TABLE_NAME,
BIOPAX_RELATIONSHIP_REFERENCES, relxList, String.class);
- AttributeUtil.set(node, BioPaxUtil.PRIVATE_TABLE_NAME,
BIOPAX_PUBLICATION_REFERENCES, pubxList, String.class);
+ AttributeUtil.set(node, CyNetwork.HIDDEN_ATTRS,
BIOPAX_UNIFICATION_REFERENCES, unifxfList, String.class);
+ AttributeUtil.set(node, CyNetwork.HIDDEN_ATTRS,
BIOPAX_RELATIONSHIP_REFERENCES, relxList, String.class);
+ AttributeUtil.set(node, CyNetwork.HIDDEN_ATTRS,
BIOPAX_PUBLICATION_REFERENCES, pubxList, String.class);
}
@Override
public void createAttributesFromProperties(final BioPAXElement element,
- final CyNode node)
+ final CyNode node, CyNetwork network)
{
Filter<PropertyEditor> filter = new Filter<PropertyEditor>() {
@Override
@@ -647,8 +589,6 @@
}
};
-// final String elementType =
element.getModelInterface().getSimpleName();
-
@SuppressWarnings("unchecked")
AbstractTraverser bpeAutoMapper = new
AbstractTraverser(SimpleEditorMap.L3, filter)
{
@@ -705,8 +645,43 @@
}
};
- // do
+ // set the most important attributes
+ AttributeUtil.set(node, BIOPAX_RDF_ID, element.getRDFId(),
String.class);
+ AttributeUtil.set(node, BIOPAX_ENTITY_TYPE,
element.getModelInterface().getSimpleName(), String.class);
+
+ // add a piece of the BioPAX (RDF/XML without parent|child
elements)
+
+ String owl = BioPaxUtil.toOwl(element); // (requires
common-lang-2.4 bundle to be started)
+ AttributeUtil.set(node,
CyNetwork.HIDDEN_ATTRS,BioPaxUtil.BIOPAX_DATA, owl, String.class);
+
+ String name =
BioPaxUtil.truncateLongStr(BioPaxUtil.getNodeName(element) + "");
+
+ if (!(element instanceof Interaction)) {
+ // get chemical modification & cellular location
attributes
+ NodeAttributesWrapper chemicalModificationsWrapper =
getInteractionChemicalModifications(element);
+ // add modifications to the label/name
+ String modificationsString =
getModificationsString(chemicalModificationsWrapper);
+ name += modificationsString;
+ // add cellular location to the label/name
+ if(element instanceof PhysicalEntity) {
+ CellularLocationVocabulary cl =
((PhysicalEntity) element).getCellularLocation();
+ if(cl != null) {
+ String clAbbr =
BioPaxUtil.getAbbrCellLocation(cl.toString())
+ .replaceAll("\\[|\\]", "");
+ name += (clAbbr.length() > 0) ? ("\n" +
clAbbr) : "";
+ }
+ }
+ // set node attributes
+ setChemicalModificationAttributes(node,
chemicalModificationsWrapper);
+ }
+ // update the name (also used for node's label and quick find)
+ AttributeUtil.set(node, CyNode.NAME, name, String.class);
+
+ // traverse to create the rest of attr.
bpeAutoMapper.traverse(element, model);
+
+ // create custom (convenience?) attributes, mainly - from xrefs
+ createExtraXrefAttributes(element, network, node);
}
/**
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/ExportAsBioPAXTask.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/ExportAsBioPAXTask.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/ExportAsBioPAXTask.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -28,7 +28,8 @@
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
taskMonitor.setStatusMessage("Exporting BioPAX...");
- String bpModelStr = network.getCyRow().get(BioPaxUtil.BIOPAX_DATA,
String.class);
+ //String bpModelStr = network.getCyRow().get(BioPaxUtil.BIOPAX_DATA,
String.class);
+ String bpModelStr =
network.getCyRow(CyNetwork.HIDDEN_ATTRS).get(BioPaxUtil.BIOPAX_DATA,
String.class);
try {
Writer w = new OutputStreamWriter(stream);
w.write(bpModelStr);
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/NetworkListenerImpl.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/NetworkListenerImpl.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/action/NetworkListenerImpl.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -89,7 +89,8 @@
*/
@Override
public void registerNetwork(CyNetworkView view) {
- if (BioPaxUtil.isBioPAXNetwork(view.getModel())) {
+ if (BioPaxUtil.isBioPAXNetwork(view.getModel())
+ ||
BioPaxUtil.isBiopaxSifNetwork(view.getModel())) {
registerNodeSelectionEvents(view);
}
}
@@ -144,7 +145,8 @@
*/
@Override
public void handleEvent(NetworkViewAddedEvent e) {
- if(BioPaxUtil.isBioPAXNetwork(e.getNetworkView().getModel())) {
+ if(BioPaxUtil.isBioPAXNetwork(e.getNetworkView().getModel())
+ ||
BioPaxUtil.isBiopaxSifNetwork(e.getNetworkView().getModel())) {
bpContainer.showLegend();
bpPanel.resetText();
}
@@ -156,7 +158,8 @@
@Override
public void handleEvent(SetCurrentNetworkViewEvent e) {
// update bpPanel accordingly
- if (BioPaxUtil.isBioPAXNetwork(e.getNetworkView().getModel())) {
+ if (BioPaxUtil.isBioPAXNetwork(e.getNetworkView().getModel())
+ ||
BioPaxUtil.isBiopaxSifNetwork(e.getNetworkView().getModel())) {
bpPanel.resetText();
}
}
@@ -168,7 +171,8 @@
*/
@Override
public void handleEvent(NetworkViewAboutToBeDestroyedEvent e) {
- if (BioPaxUtil.isBioPAXNetwork(e.getNetworkView().getModel())) {
+ if (BioPaxUtil.isBioPAXNetwork(e.getNetworkView().getModel())
+ ||
BioPaxUtil.isBiopaxSifNetwork(e.getNetworkView().getModel())) {
CyNetworkView view = e.getNetworkView();
listeners.remove(view);
}
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/AttributeUtil.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/AttributeUtil.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/AttributeUtil.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -9,6 +9,7 @@
import org.cytoscape.model.CyTableEntry;
public class AttributeUtil {
+
public static void set(CyTableEntry entry, String name, Object value,
Class<?> type) {
set(entry, null, name, value, type);
}
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/view/BioPaxDetailsPanel.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/view/BioPaxDetailsPanel.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/view/BioPaxDetailsPanel.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -172,7 +172,6 @@
// type (to the text buffer)
String type = node.getCyRow().get(BIOPAX_ENTITY_TYPE, String.class);
- type = BioPaxUtil.getTypeInPlainEnglish(type);
buf.append("<h3>" + type + "</h3>");
// organism
@@ -208,8 +207,8 @@
// excerpt from the BioPAX OWL
stringRef = null;
- //stringRef =
node.getCyRow(BioPaxUtil.PRIVATE_TABLE_NAME).get(BioPaxUtil.BIOPAX_DATA,
String.class);
- stringRef = row.get(BioPaxUtil.BIOPAX_DATA, String.class);
+ stringRef =
node.getCyRow(CyNetwork.HIDDEN_ATTRS).get(BioPaxUtil.BIOPAX_DATA, String.class);
+ //stringRef = row.get(BioPaxUtil.BIOPAX_DATA, String.class);
if (stringRef != null) {
appendHeader("BioPAX L3 (excerpt)", buf);
buf.append("<pre>" + StringEscapeUtils.escapeXml(stringRef) +
"</pre>");
@@ -243,11 +242,11 @@
private void addLinks(CyNode node, StringBuffer buf) {
CyRow row = node.getCyRow();
- addAttributeList(node, BioPaxUtil.PRIVATE_TABLE_NAME,
+ addAttributeList(node, CyNetwork.HIDDEN_ATTRS,
BIOPAX_UNIFICATION_REFERENCES, "Links:", buf);
- addAttributeList(node, BioPaxUtil.PRIVATE_TABLE_NAME,
+ addAttributeList(node, CyNetwork.HIDDEN_ATTRS,
BIOPAX_RELATIONSHIP_REFERENCES, null, buf);
- addAttributeList(node, BioPaxUtil.PRIVATE_TABLE_NAME,
+ addAttributeList(node, CyNetwork.HIDDEN_ATTRS,
BIOPAX_PUBLICATION_REFERENCES, "Publications:", buf);
addIHOPLinks(node, buf);
@@ -278,8 +277,7 @@
String listItem = list.get(lc);
if ((listItem != null) && (listItem.length() > 0)) {
- String plainEnglish =
BioPaxUtil.getTypeInPlainEnglish(listItem);
- displayString.append("<LI> - " + plainEnglish);
+ displayString.append("<LI> - " + listItem);
displayString.append("</LI>");
}
}
@@ -311,7 +309,7 @@
}
private void addIHOPLinks(CyNode node, StringBuffer buf) {
- CyRow row = node.getCyRow();
+ CyRow row = node.getCyRow(CyNetwork.HIDDEN_ATTRS);
String ihopLinks = row.get(BIOPAX_IHOP_LINKS, String.class);
if (ihopLinks != null) {
Modified:
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/util/BioPaxUtil.java
===================================================================
---
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/util/BioPaxUtil.java
2011-09-20 20:43:15 UTC (rev 26887)
+++
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/util/BioPaxUtil.java
2011-09-20 20:53:22 UTC (rev 26888)
@@ -46,6 +46,7 @@
import org.biopax.paxtools.model.Model;
import org.biopax.paxtools.model.level3.BioSource;
import org.biopax.paxtools.model.level3.Entity;
+import org.biopax.paxtools.model.level3.EntityReference;
import org.biopax.paxtools.model.level3.Interaction;
import org.biopax.paxtools.model.level3.Level3Element;
import org.biopax.paxtools.model.level3.Named;
@@ -63,6 +64,7 @@
import org.cytoscape.biopax.internal.util.ParentFinder;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTableUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,7 +75,6 @@
* @author Ethan Cerami, Rex, Arman and Igor Rodchenkov
*/
public class BioPaxUtil {
- private static final Map<String,String> plainEnglishMap;
private static final Map<String,String> cellLocationMap;
private static final Map<String,String> chemModificationsMap;
@@ -82,7 +83,6 @@
public static final String DEFAULT_CHARSET = "UTF-8";
public static final int MAX_DISPLAY_STRING_LEN = 25;
public static final String NULL_ELEMENT_TYPE = "BioPAX Element";
- public static final String PRIVATE_TABLE_NAME = null; //TODO
"biopax_hidden";
/**
* BioPAX Class: phosphorylation site
@@ -92,56 +92,12 @@
/**
* BioPAX Class: protein phosphorylated
*/
- public static final String PROTEIN_PHOSPHORYLATED =
"protein-phosphorylated";
+ public static final String PROTEIN_PHOSPHORYLATED =
"Protein-phosphorylated";
// protected Constructor
protected BioPaxUtil() {}
static {
- plainEnglishMap = new HashMap<String,String>();
- // all keys are lower case!
- plainEnglishMap.put("protein", "Protein");
- plainEnglishMap.put("smallmolecule", "Small Molecule");
- plainEnglishMap.put("physicalentity", "Physical Entity");
- plainEnglishMap.put("complex", "Complex");
- plainEnglishMap.put("dna", "DNA");
- plainEnglishMap.put("rna", "RNA");
- plainEnglishMap.put("interaction", "Interaction");
- plainEnglishMap.put("physicalinteraction", "Physical
Interaction");
- plainEnglishMap.put("control", "Control");
- plainEnglishMap.put("catalysis", "Catalysis");
- plainEnglishMap.put("modulation", "Modulation");
- plainEnglishMap.put("conversion", "Conversion");
- plainEnglishMap.put("biochemicalreaction", "Biochemical
Reaction");
- plainEnglishMap.put("molecularinteraction", "Molecular
Interaction");
- plainEnglishMap.put("complexassembly", "Complex Assembly");
- plainEnglishMap.put("transportwithbiochemicalreaction",
"Transport with Biochemical Reaction");
- plainEnglishMap.put("transport", "Transport");
- plainEnglishMap.put("transportwithbiochemicalreaction",
"Transport with Biochemical Reaction");
- plainEnglishMap.put("geneticinteraction", "Genetic
Interaction");
- plainEnglishMap.put("templatereaction", "Template Reaction");
- plainEnglishMap.put("degradation", "Degradation");
- // chemical modifications
- plainEnglishMap.put("acetylation site", "Acetylation Site");
- plainEnglishMap.put("glycosylation site", "Glycosylation Site");
- plainEnglishMap.put("phosphorylation site", "Phosphorylation
Site");
- plainEnglishMap.put("sumoylation site", "Sumoylation Site");
- plainEnglishMap.put("ubiquitination site", "Ubiquitination
Site");
- // cellular locations
- plainEnglishMap.put("cellular component unknown", "Cellular
Component Unknown");
- plainEnglishMap.put("centrosome", "Centrosome");
- plainEnglishMap.put("cytoplasm", "Cytoplasm");
- plainEnglishMap.put("endoplasmic reticulum", "Endoplasmic
Reticulum");
- plainEnglishMap.put("endosome", "Endosome");
- plainEnglishMap.put("extracellular", "Extracellular");
- plainEnglishMap.put("golgi apparatus", "Golgi Apparatus");
- plainEnglishMap.put("mitochondrion", "Mitochondrion");
- plainEnglishMap.put("nucleoplasm", "Nucleoplasm");
- plainEnglishMap.put("nucleus", "Nucleus");
- plainEnglishMap.put("plasma membrane", "Plasma Membrane");
- plainEnglishMap.put("ribosome", "Ribosome");
- plainEnglishMap.put("transmembrane", "Transmembrane");
-
// the following is for node labels
cellLocationMap = new HashMap<String, String>();
cellLocationMap.put("cellular component unknown", "");
@@ -191,35 +147,7 @@
return model;
}
- /**
- * Converts the specified type into "Plain English".
- * For example, the type "biochemicalReaction" is converted to
- * "Biochemical Reaction".
- * <p/>
- * If the type is not know, the origianl argument type is simply
returned.
- *
- * @param type BioPAX Type String.
- * @return BioPAX Type String, in "Plain English".
- */
- public static String getTypeInPlainEnglish(String type) {
- String plainEnglish = plainEnglishMap.get(type.toLowerCase());
-
- if (plainEnglish == null) {
- return type;
- } else {
- return plainEnglish;
- }
- }
-
- @Deprecated
- public static String getType(BioPAXElement bpe) {
- return (bpe != null)
- ?
getTypeInPlainEnglish(bpe.getModelInterface().getSimpleName())
- : NULL_ELEMENT_TYPE;
- }
-
-
/**
* Gets or infers the name of the node.
*
@@ -248,17 +176,10 @@
return getTheShortestString(names);
}
- return getLocalPartRdfId(bpe);
+ return bpe.getRDFId();
}
- public static String getLocalPartRdfId(BioPAXElement bpe) {
- if(bpe == null)
- return "";
- else
- return bpe.getRDFId().replaceFirst("^.+#", "");
- }
-
// get the shortest string
public static String getTheShortestString(Collection<String> nameList) {
String shortest = null;
@@ -718,16 +639,17 @@
public static boolean isBioPAXNetwork(CyNetwork cyNetwork) {
- // BioPAX network (having interaction nodes)
- CyRow row = cyNetwork.getCyRow();
- Boolean b1 = row.get(MapBioPaxToCytoscapeImpl.BIOPAX_NETWORK,
Boolean.class);
- // BioPAX network that was converted to SIF (TODO mapping to
SIF network currently is not done)
- // Bug fix: disable exporting SIF networks (read from PC web service)
for now
- Boolean b2 = false;
//networkAttributes.getBooleanAttribute(networkID,
MapBioPaxToCytoscape.BINARY_NETWORK);
- return Boolean.TRUE.equals(b1) || Boolean.TRUE.equals(b2);
+ return Boolean.TRUE == cyNetwork.getCyRow()
+ .get(MapBioPaxToCytoscapeImpl.BIOPAX_NETWORK,
Boolean.class);
}
+ public static boolean isBiopaxSifNetwork(CyNetwork cyNetwork) {
+ return Boolean.TRUE == cyNetwork.getCyRow()
+ .get(MapBioPaxToCytoscapeImpl.BINARY_NETWORK,
Boolean.class);
+ }
+
+
public static String toOwl(BioPAXElement bpe) {
StringWriter writer = new StringWriter();
try {
@@ -738,4 +660,35 @@
}
return writer.toString();
}
+
+
+ public static void fixDisplayName(Model model) {
+ if (log.isInfoEnabled())
+ log.info("Trying to auto-fix 'null' displayName...");
+ // where it's null, set to the shortest name if possible
+ for (Named e : model.getObjects(Named.class)) {
+ if (e.getDisplayName() == null) {
+ if (e.getStandardName() != null) {
+ e.setDisplayName(e.getStandardName());
+ } else if (!e.getName().isEmpty()) {
+ String dsp =
e.getName().iterator().next();
+ for (String name : e.getName()) {
+ if (name.length() <
dsp.length())
+ dsp = name;
+ }
+ e.setDisplayName(dsp);
+ }
+ }
+ }
+ // if required, set PE name to (already fixed) ER's name...
+ for(EntityReference er :
model.getObjects(EntityReference.class)) {
+ for(SimplePhysicalEntity spe :
er.getEntityReferenceOf()) {
+ if(spe.getDisplayName() == null ||
spe.getDisplayName().trim().length() == 0) {
+ if(er.getDisplayName() != null &&
er.getDisplayName().trim().length() > 0) {
+
spe.setDisplayName(er.getDisplayName());
+ }
+ }
+ }
+ }
+ }
}
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.