Author: pwang
Date: 2011-01-19 17:12:08 -0800 (Wed, 19 Jan 2011)
New Revision: 23520
Modified:
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/NetworkLineParser.java
Log:
Load edge attributes
Modified:
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/NetworkLineParser.java
===================================================================
---
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/NetworkLineParser.java
2011-01-20 01:11:48 UTC (rev 23519)
+++
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/NetworkLineParser.java
2011-01-20 01:12:08 UTC (rev 23520)
@@ -108,6 +108,9 @@
//edge = Cytoscape.getCyEdge(source, target,
Semantics.INTERACTION, interaction, true, true);
CyEdge edge = network.addEdge(source, target, true);
+ edge.getCyRow().set("interaction", interaction);
+ String edgeName = source.getCyRow().get("name", String.class)+
" ("+interaction+") "+ target.getCyRow().get("name", String.class);
+ edge.getCyRow().set("name", edgeName);
edgeList.add(edge.getSUID());
@@ -141,12 +144,20 @@
if ((i != nmp.getSourceIndex()) && (i !=
nmp.getTargetIndex())
&& (i != nmp.getInteractionIndex()) && parts[i] !=
null ) {
if ((nmp.getImportFlag().length > i) &&
(nmp.getImportFlag()[i] == true)) {
- //mapAttribute(edge.getIdentifier(),
parts[i].trim(), i);
+ mapAttribute(edge, parts[i].trim(), i);
}
}
}
}
+ private void createColumn(final CyEdge edge, final String
attributeName, Class<?> theType){
+ // If attribute does not exist, create it
+ if
(edge.getCyRow().getDataTable().getColumnTypeMap().get(attributeName)==null){
+
edge.getCyRow().getDataTable().createColumn(attributeName, theType);
+ }
+ }
+
+
/**
* Based on the attribute types, map the entry to CyAttributes.<br>
*
@@ -154,7 +165,8 @@
* @param entry
* @param index
*/
- private void mapAttribute(final String key, final String entry, final
int index) {
+ //private void mapAttribute(final String key, final String entry, final
int index) {
+ private void mapAttribute(final CyEdge edge, final String entry, final
int index) {
Byte type = nmp.getAttributeTypes()[index];
@@ -164,26 +176,34 @@
}
switch (type) {
- case AttributeTypes.TYPE_BOOLEAN:
+ case AttributeTypes.TYPE_BOOLEAN:
//nmp.getAttributes()
// .setAttribute(key,
nmp.getAttributeNames()[index], new Boolean(entry));
+ createColumn(edge,
nmp.getAttributeNames()[index],Boolean.class);
+
edge.getCyRow().set(nmp.getAttributeNames()[index], new Boolean(entry));
break;
case AttributeTypes.TYPE_INTEGER:
//nmp.getAttributes()
// .setAttribute(key,
nmp.getAttributeNames()[index], new Integer(entry));
+ createColumn(edge,
nmp.getAttributeNames()[index],Integer.class);
+
edge.getCyRow().set(nmp.getAttributeNames()[index], new Integer(entry));
break;
case AttributeTypes.TYPE_FLOATING:
//nmp.getAttributes()
// .setAttribute(key,
nmp.getAttributeNames()[index], new Double(entry));
+ createColumn(edge,
nmp.getAttributeNames()[index],Double.class);
+
edge.getCyRow().set(nmp.getAttributeNames()[index], new Double(entry));
break;
case AttributeTypes.TYPE_STRING:
//nmp.getAttributes().setAttribute(key,
nmp.getAttributeNames()[index], entry);
+ createColumn(edge,
nmp.getAttributeNames()[index],String.class);
+
edge.getCyRow().set(nmp.getAttributeNames()[index], entry.trim());
break;
--
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.