Author: kono
Date: 2011-01-25 14:04:16 -0800 (Tue, 25 Jan 2011)
New Revision: 23614
Modified:
core3/webservice-biomart-client/trunk/pom.xml
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/LoadRepositoryTask.java
core3/webservice-biomart-client/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Mapping function implemented.
Modified: core3/webservice-biomart-client/trunk/pom.xml
===================================================================
--- core3/webservice-biomart-client/trunk/pom.xml 2011-01-25 21:41:08 UTC
(rev 23613)
+++ core3/webservice-biomart-client/trunk/pom.xml 2011-01-25 22:04:16 UTC
(rev 23614)
@@ -82,7 +82,7 @@
<Bundle-Version>${pom.version}</Bundle-Version>
<!-- | assume public classes
are in the top package, and private classes
are under ".internal"
-->
-
+
<!-- | each module can override
these defaults in their osgi.bnd file -->
<_include>-osgi.bnd</_include>
</instructions>
@@ -109,6 +109,11 @@
<artifactId>swing-application-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>core-task-api</artifactId>
+ <version>3.0.0-alpha2-SNAPSHOT</version>
+ </dependency>
<!-- Testing -->
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
2011-01-25 21:41:08 UTC (rev 23613)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
2011-01-25 22:04:16 UTC (rev 23614)
@@ -47,47 +47,53 @@
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableFactory;
+import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.work.TaskIterator;
/**
* Biomart Web Service Client.
*
*/
-public class BiomartClient extends AbstractWebServiceClient implements
TableImportWebServiceClient {
-
+public class BiomartClient extends AbstractWebServiceClient implements
+ TableImportWebServiceClient {
+
private final CyTableFactory tableFactory;
- private final CyNetworkManager manager;
-
+
private final BiomartRestClient restClient;
-
+
private BiomartAttrMappingPanel gui;
-
+
private ImportTableTask importTask;
-
+ private final CyNetworkManager networkManager;
+ private final CyApplicationManager applicationManager;
+
/**
* Creates a new Biomart Client object.
*
* @throws ServiceException
* @throws ConfigurationException
*/
- public BiomartClient(final String displayName, final String
description,
+ public BiomartClient(final String displayName, final String description,
final BiomartRestClient restClient,
- final CyTableFactory tableFactory,
- final CyNetworkManager manager) {
+ final CyTableFactory tableFactory,
+ final CyNetworkManager networkManager,
+ final CyApplicationManager applicationManager) {
super(restClient.getBaseURL(), displayName, description);
this.tableFactory = tableFactory;
- this.manager = manager;
this.restClient = restClient;
+ this.networkManager = networkManager;
+ this.applicationManager = applicationManager;
+
// TODO: set optional parameters (Tunables?)
}
-
+
public void setGUI(final BiomartAttrMappingPanel gui) {
this.gui = gui;
}
-
+
public BiomartRestClient getRestClient() {
return this.restClient;
}
@@ -95,7 +101,7 @@
@Override
public Set<CyTable> getTables() {
// Return empty task if not executed yet.
- if(importTask == null)
+ if (importTask == null)
return new HashSet<CyTable>();
else
return importTask.getCyTables();
@@ -103,12 +109,15 @@
@Override
public TaskIterator getTaskIterator() {
- if(gui == null)
- throw new IllegalStateException("Could not build query
because Query Builder GUI is null.");
-
+ if (gui == null)
+ throw new IllegalStateException(
+ "Could not build query because Query
Builder GUI is null.");
+
final BiomartQuery query = this.gui.getTableImportQuery();
+
+ importTask = new ImportTableTask(restClient, query,
tableFactory, networkManager, applicationManager);
+
- importTask = new ImportTableTask(restClient, query,
tableFactory, manager);
return new TaskIterator(importTask);
}
}
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
2011-01-25 21:41:08 UTC (rev 23613)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
2011-01-25 22:04:16 UTC (rev 23614)
@@ -5,37 +5,52 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.cytoscape.io.webservice.biomart.BiomartQuery;
import org.cytoscape.io.webservice.biomart.rest.BiomartRestClient;
-import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyRow;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableFactory;
+import org.cytoscape.session.CyApplicationManager;
+import org.cytoscape.task.table.MapNetworkAttrTask;
import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.TaskMonitor;
+/**
+ * Task to import actual data tables from BioMart service.
+ *
+ */
public class ImportTableTask extends AbstractTask {
private final BiomartRestClient client;
private final BiomartQuery query;
private final CyTableFactory tableFactory;
- private final CyNetworkManager manager;
private Set<CyTable> tables;
+
+ private final CyNetworkManager networkManager;
+ private final CyApplicationManager applicationManager;
+
+
public ImportTableTask(final BiomartRestClient client,
- final BiomartQuery query, final CyTableFactory
tableFactory,
- final CyNetworkManager manager) {
+ final BiomartQuery query, final CyTableFactory
tableFactory,
+ final CyNetworkManager networkManager,
+ final CyApplicationManager applicationManager) {
this.client = client;
this.query = query;
this.tableFactory = tableFactory;
- this.manager = manager;
+
+ this.networkManager = networkManager;
+ this.applicationManager = applicationManager;
+
+ this.tables = new HashSet<CyTable>();
}
@Override
@@ -48,18 +63,25 @@
if (result.ready() == false)
throw new IOException("Could not get result.");
- tables = mapping(result, query.getKeyColumnName());
+ final CyTable newTable = mapping(result,
query.getKeyColumnName());
+
+ tables.add(newTable);
+
+ final MapNetworkAttrTask localMappingTask = new
MapNetworkAttrTask(
+ CyNode.class, newTable,
+ networkManager, applicationManager);
+
+ this.insertTasksAfterCurrentTask(localMappingTask);
}
- private Set<CyTable> mapping(BufferedReader reader, String key)
+ private CyTable mapping(BufferedReader reader, String key)
throws IOException {
- final Set<CyTable> newTables = new HashSet<CyTable>();
-
+
+ System.out.println("Key name = " + key);
final CyTable globalTable =
tableFactory.createTable(query.getTableName(), key,
String.class, true);
- newTables.add(globalTable);
// Read result from reader
String line = reader.readLine();
@@ -109,18 +131,18 @@
recordCount++;
keyVal = row[keyIdx];
-//
-// System.out.println("Key ====>" + keyVal + "<==");
rowLength = row.length;
+ final CyRow cyRow = globalTable.getRow(keyVal);
for (int j = 0; j < rowLength; j++) {
val = row[j];
- if ((val != null) && (val.length() != 0) && (j
!= keyIdx)) {
- listOfValList = new
ArrayList<List<Object>>();
+ if ((val != null) && (val.length() != 0)) {
- final CyRow cyRow =
globalTable.getRow(keyVal);
+ if(j == keyIdx) {
+ cyRow.set(key, val);
+ }
cyRow.set(columnNames[j], val);
// if (keyAttrName.equals("ID")) {
// testList = attr
@@ -169,13 +191,23 @@
// index++;
// }
}
- System.out.println();
}
}
reader.close();
reader = null;
- return newTables;
+
+ // Dump table
+// final List<CyRow> rows = globalTable.getAllRows();
+// for(CyRow r: rows) {
+// Map<String, Object> rowVals = r.getAllValues();
+// for(String k :rowVals.keySet()) {
+// System.out.print(k + ":" + rowVals.get(k) + "
");
+// }
+// System.out.println();
+// }
+
+ return globalTable;
}
public Set<CyTable> getCyTables() {
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/LoadRepositoryTask.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/LoadRepositoryTask.java
2011-01-25 21:41:08 UTC (rev 23613)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/LoadRepositoryTask.java
2011-01-25 22:04:16 UTC (rev 23614)
@@ -50,7 +50,7 @@
@Override
public void run(TaskMonitor taskMonitor) throws IOException,
ParserConfigurationException, SAXException {
-
+ taskMonitor.setTitle("Loading list of available BioMart
Services. Please wait...");
taskMonitor.setStatusMessage("Loading list of available
Marts...");
dsList = new ArrayList<String>();
Modified:
core3/webservice-biomart-client/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-01-25 21:41:08 UTC (rev 23613)
+++
core3/webservice-biomart-client/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-01-25 22:04:16 UTC (rev 23614)
@@ -32,6 +32,7 @@
<constructor-arg ref="biomartRestClient" />
<constructor-arg ref="cyTableFactoryServiceRef" />
<constructor-arg ref="cyNetworkManagerServiceRef" />
+ <constructor-arg ref="cyApplicationManagerServiceRef" />
</bean>
<bean id="biomartAttrMappingPanel"
--
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.