Author: kono
Date: 2011-12-12 14:21:56 -0800 (Mon, 12 Dec 2011)
New Revision: 27772
Added:
csplugins/trunk/ucsd/kono/cy3plugins/
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
Removed:
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
Log:
Moved to regular plugin.
Deleted:
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
===================================================================
---
core3/impl/trunk/webservice-ncbi-client-impl/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
2011-12-06 19:38:22 UTC (rev 27709)
+++
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
2011-12-12 22:21:56 UTC (rev 27772)
@@ -1,187 +0,0 @@
-package org.cytoscape.webservice.ncbi.rest;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyTableEntry;
-import org.cytoscape.work.TaskMonitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class ImportNetworkTask implements Callable<Double> {
-
- private static final Logger logger =
LoggerFactory.getLogger(ImportNetworkTask.class);
-
- private static final String TARGET_ID = "";
- private static final String TARGET_DB = "";
- private static final String TARGET_NAMES = "";
-
- private static final String GENE_ID_TAG = "Gene-track_geneid";
-
- private final InteractionDocNodeProcessor processor;
-
- final String[] ids;
-
- private final CyNetwork network;
-
- private final ConcurrentMap<String, CyNode> nodeName2CyNodeMap;
- private final Map<String, CyEdge> nodeName2CyEdgeMap;
-
- private final Double portion;
-
- public ImportNetworkTask(final String[] ids, final CyNetwork network,
- final ConcurrentMap<String, CyNode> nodeName2CyNodeMap,
int totalSize) {
- this.ids = ids;
- this.network = network;
- this.processor = new InteractionDocNodeProcessor();
- this.nodeName2CyNodeMap = nodeName2CyNodeMap;
- this.nodeName2CyEdgeMap = new HashMap<String, CyEdge>();
-
- portion = (double)ids.length/(double)totalSize;
- }
-
- @Override
- public Double call() throws Exception {
- final URL url = createURL();
-
- final DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- final DocumentBuilder builder = factory.newDocumentBuilder();
- InputStream is = url.openStream();
-
- final Document result = builder.parse(is);
-
- logger.debug("######## 1 Got Result for = " + url.toString());
- logger.debug("######## 2 Got Result for = " +
result.getChildNodes().getLength());
-
- NodeList geneID = result.getElementsByTagName(GENE_ID_TAG);
- final String geneIDString = geneID.item(0).getTextContent();
- logger.debug("Gene ID ======== " + geneIDString);
- if (geneIDString == null)
- throw new NullPointerException("Could not find NCBI
Gene ID for the entry.");
-
- // This is the center of spokes
- final CyNode centerNode = network.addNode();
- centerNode.getCyRow().set(CyTableEntry.NAME, geneIDString);
- this.nodeName2CyNodeMap.put(geneIDString, centerNode);
-
- final NodeList ids =
result.getElementsByTagName("Gene-commentary");
- final int dataSize = ids.getLength();
-
- boolean interactionFound = false;
- Node interactionNode = null;
- for (int i = 0; i < dataSize; i++) {
- // logger.debug(" GC = " +
- // ids.item(i).getChildNodes().getLength());
- NodeList children = ids.item(i).getChildNodes();
- for (int j = 0; j < children.getLength(); j++) {
- if
(children.item(j).getNodeName().equals("Gene-commentary_heading")) {
-
- // logger.debug("HEADING = " +
- // children.item(j).getTextContent());
- if
(children.item(j).getTextContent().equals("Interactions")) {
- logger.debug("FOUND
interactions");
- interactionFound = true;
- break;
- }
- }
- }
- if (interactionFound) {
- interactionNode = ids.item(i);
- break;
- }
- }
-
- is.close();
- is = null;
-
- if (interactionNode == null)
- logger.warn("Interacrtion Not found");
- else
- processInteraction(interactionNode, centerNode);
-
- return portion;
- }
-
- private void processInteraction(Node node, CyNode centerNode) {
- NodeList children = node.getChildNodes();
- int dataSize = children.getLength();
- NodeList interactionList = null;
- for (int i = 0; i < dataSize; i++) {
- Node item = children.item(i);
- if
(item.getNodeName().equals("Gene-commentary_comment")) {
- interactionList = item.getChildNodes();
- break;
- }
- }
-
- logger.debug("Num interactions: " +
interactionList.getLength());
- processNode(interactionList, centerNode);
- }
-
- private void processNode(NodeList interactionList, CyNode centerNode) {
- int dataSize = interactionList.getLength();
- for (int i = 0; i < dataSize; i++) {
- final Node item = interactionList.item(i);
- if (item.getNodeType() == Node.ELEMENT_NODE) {
- logger.debug(item.getNodeName() + " Number = "
+ i);
- // logger.debug(" contents = " +
item.getTextContent());
-
- processor.process(item);
- final String id = processor.getTargetID();
- if (id != null) {
- // Create actual nodes and edges here.
- CyNode targetNode =
this.nodeName2CyNodeMap.get(id);
- ;
- if (targetNode == null) {
- targetNode = network.addNode();
- nodeName2CyNodeMap.put(id,
targetNode);
- }
-
-
targetNode.getCyRow().set(CyTableEntry.NAME, id);
- logger.debug("New Node Name = " + id);
- final CyEdge newEdge =
network.addEdge(centerNode, targetNode, false);
- newEdge.getCyRow().set(
- CyTableEntry.NAME,
-
centerNode.getCyRow().get(CyTableEntry.NAME, String.class) + " ("
- +
processor.getInteractionType() + ") "
- +
targetNode.getCyRow().get(CyTableEntry.NAME, String.class));
- }
- }
- }
-
- }
-
- private URL createURL() throws IOException {
-
- final StringBuilder builder = new StringBuilder();
-
- for (final String id : ids) {
- if (id != null)
- builder.append(id + ",");
- }
-
- String urlString = builder.toString();
- urlString = urlString.substring(0, urlString.length() - 1);
- final URL url = new URL(EntrezRestClient.FETCH_URL + urlString);
- logger.debug("Import Query URL = " + url.toString());
- return url;
- }
-
-}
\ No newline at end of file
Copied:
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
(from rev 27770,
core3/impl/trunk/webservice-ncbi-client-impl/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java)
===================================================================
---
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
(rev 0)
+++
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/rest/ImportNetworkTask.java
2011-12-12 22:21:56 UTC (rev 27772)
@@ -0,0 +1,187 @@
+package org.cytoscape.webservice.ncbi.rest;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.work.TaskMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ImportNetworkTask implements Callable<Double> {
+
+ private static final Logger logger =
LoggerFactory.getLogger(ImportNetworkTask.class);
+
+ private static final String TARGET_ID = "";
+ private static final String TARGET_DB = "";
+ private static final String TARGET_NAMES = "";
+
+ private static final String GENE_ID_TAG = "Gene-track_geneid";
+
+ private final InteractionDocNodeProcessor processor;
+
+ final String[] ids;
+
+ private final CyNetwork network;
+
+ private final ConcurrentMap<String, CyNode> nodeName2CyNodeMap;
+ private final Map<String, CyEdge> nodeName2CyEdgeMap;
+
+ private final Double portion;
+
+ public ImportNetworkTask(final String[] ids, final CyNetwork network,
+ final ConcurrentMap<String, CyNode> nodeName2CyNodeMap,
int totalSize) {
+ this.ids = ids;
+ this.network = network;
+ this.processor = new InteractionDocNodeProcessor();
+ this.nodeName2CyNodeMap = nodeName2CyNodeMap;
+ this.nodeName2CyEdgeMap = new HashMap<String, CyEdge>();
+
+ portion = (double)ids.length/(double)totalSize;
+ }
+
+ @Override
+ public Double call() throws Exception {
+ final URL url = createURL();
+
+ final DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ InputStream is = url.openStream();
+
+ final Document result = builder.parse(is);
+
+ logger.debug("######## 1 Got Result for = " + url.toString());
+ logger.debug("######## 2 Got Result for = " +
result.getChildNodes().getLength());
+
+ NodeList geneID = result.getElementsByTagName(GENE_ID_TAG);
+ final String geneIDString = geneID.item(0).getTextContent();
+ logger.debug("Gene ID ======== " + geneIDString);
+ if (geneIDString == null)
+ throw new NullPointerException("Could not find NCBI
Gene ID for the entry.");
+
+ // This is the center of spokes
+ final CyNode centerNode = network.addNode();
+ network.getRow(centerNode).set(CyTableEntry.NAME, geneIDString);
+ this.nodeName2CyNodeMap.put(geneIDString, centerNode);
+
+ final NodeList ids =
result.getElementsByTagName("Gene-commentary");
+ final int dataSize = ids.getLength();
+
+ boolean interactionFound = false;
+ Node interactionNode = null;
+ for (int i = 0; i < dataSize; i++) {
+ // logger.debug(" GC = " +
+ // ids.item(i).getChildNodes().getLength());
+ NodeList children = ids.item(i).getChildNodes();
+ for (int j = 0; j < children.getLength(); j++) {
+ if
(children.item(j).getNodeName().equals("Gene-commentary_heading")) {
+
+ // logger.debug("HEADING = " +
+ // children.item(j).getTextContent());
+ if
(children.item(j).getTextContent().equals("Interactions")) {
+ logger.debug("FOUND
interactions");
+ interactionFound = true;
+ break;
+ }
+ }
+ }
+ if (interactionFound) {
+ interactionNode = ids.item(i);
+ break;
+ }
+ }
+
+ is.close();
+ is = null;
+
+ if (interactionNode == null)
+ logger.warn("Interacrtion Not found");
+ else
+ processInteraction(interactionNode, centerNode);
+
+ return portion;
+ }
+
+ private void processInteraction(Node node, CyNode centerNode) {
+ NodeList children = node.getChildNodes();
+ int dataSize = children.getLength();
+ NodeList interactionList = null;
+ for (int i = 0; i < dataSize; i++) {
+ Node item = children.item(i);
+ if
(item.getNodeName().equals("Gene-commentary_comment")) {
+ interactionList = item.getChildNodes();
+ break;
+ }
+ }
+
+ logger.debug("Num interactions: " +
interactionList.getLength());
+ processNode(interactionList, centerNode);
+ }
+
+ private void processNode(NodeList interactionList, CyNode centerNode) {
+ int dataSize = interactionList.getLength();
+ for (int i = 0; i < dataSize; i++) {
+ final Node item = interactionList.item(i);
+ if (item.getNodeType() == Node.ELEMENT_NODE) {
+ logger.debug(item.getNodeName() + " Number = "
+ i);
+ // logger.debug(" contents = " +
item.getTextContent());
+
+ processor.process(item);
+ final String id = processor.getTargetID();
+ if (id != null) {
+ // Create actual nodes and edges here.
+ CyNode targetNode =
this.nodeName2CyNodeMap.get(id);
+ ;
+ if (targetNode == null) {
+ targetNode = network.addNode();
+ nodeName2CyNodeMap.put(id,
targetNode);
+ }
+
+
network.getRow(targetNode).set(CyTableEntry.NAME, id);
+ logger.debug("New Node Name = " + id);
+ final CyEdge newEdge =
network.addEdge(centerNode, targetNode, false);
+ network.getRow(newEdge).set(
+ CyTableEntry.NAME,
+
network.getRow(centerNode).get(CyTableEntry.NAME, String.class) + " ("
+ +
processor.getInteractionType() + ") "
+ +
network.getRow(targetNode).get(CyTableEntry.NAME, String.class));
+ }
+ }
+ }
+
+ }
+
+ private URL createURL() throws IOException {
+
+ final StringBuilder builder = new StringBuilder();
+
+ for (final String id : ids) {
+ if (id != null)
+ builder.append(id + ",");
+ }
+
+ String urlString = builder.toString();
+ urlString = urlString.substring(0, urlString.length() - 1);
+ final URL url = new URL(EntrezRestClient.FETCH_URL + urlString);
+ logger.debug("Import Query URL = " + url.toString());
+ return url;
+ }
+
+}
Deleted:
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
===================================================================
---
core3/impl/trunk/webservice-ncbi-client-impl/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
2011-12-06 19:38:22 UTC (rev 27709)
+++
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
2011-12-12 22:21:56 UTC (rev 27772)
@@ -1,71 +0,0 @@
-package org.cytoscape.webservice.ncbi.task;
-
-
-import java.util.Set;
-
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNetworkFactory;
-import org.cytoscape.model.CyNetworkManager;
-import org.cytoscape.model.CyTableEntry;
-import org.cytoscape.model.CyTableFactory;
-import org.cytoscape.model.CyTableManager;
-import org.cytoscape.webservice.ncbi.rest.EntrezRestClient;
-import org.cytoscape.work.AbstractTask;
-import org.cytoscape.work.TaskMonitor;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class ImportNetworkFromGeneTask extends AbstractTask {
- private static final Logger logger =
LoggerFactory.getLogger(ImportNetworkFromGeneTask.class);
-
- private final String queryString;
- private final CyNetworkFactory networkFactory;
- private final CyTableFactory tableFactory;
- private final CyNetworkManager manager;
- private final CyTableManager tableManager;
-
- private CyNetwork newNetwork;
-
- public ImportNetworkFromGeneTask(final String queryString,
- final CyNetworkFactory networkFactory,
- final CyTableFactory tableFactory,
- final CyNetworkManager manager,
- final CyTableManager tableManager)
- {
- this.queryString = queryString;
- this.networkFactory = networkFactory;
- this.manager = manager;
- this.tableFactory = tableFactory;
- this.tableManager = tableManager;
- }
-
- @Override
- public void run(TaskMonitor taskMonitor) throws Exception {
- logger.debug("Import Start: Query = " + queryString);
-
- taskMonitor.setProgress(0.01d);
-
- final EntrezRestClient restClient =
- new EntrezRestClient(networkFactory, tableFactory,
tableManager);
-
- taskMonitor.setTitle("Accessing NCBI Entrez Gene");
- taskMonitor.setStatusMessage("Searching matching genes...");
- final Set<String> searchResult = restClient.search(queryString);
-
- if(searchResult.size() == 0)
- return;
-
- taskMonitor.setStatusMessage("Creating network from matching
genes...");
- newNetwork = restClient.importNetwork(searchResult,
taskMonitor);
-
- // Register it
- newNetwork.getCyRow().set(CyTableEntry.NAME, "NCBI");
- manager.addNetwork(newNetwork);
- }
-
- public CyNetwork getNetwork() {
- return newNetwork;
- }
-}
Copied:
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
(from rev 27770,
core3/impl/trunk/webservice-ncbi-client-impl/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java)
===================================================================
---
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
(rev 0)
+++
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/task/ImportNetworkFromGeneTask.java
2011-12-12 22:21:56 UTC (rev 27772)
@@ -0,0 +1,71 @@
+package org.cytoscape.webservice.ncbi.task;
+
+
+import java.util.Set;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkFactory;
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.model.CyTableFactory;
+import org.cytoscape.model.CyTableManager;
+import org.cytoscape.webservice.ncbi.rest.EntrezRestClient;
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ImportNetworkFromGeneTask extends AbstractTask {
+ private static final Logger logger =
LoggerFactory.getLogger(ImportNetworkFromGeneTask.class);
+
+ private final String queryString;
+ private final CyNetworkFactory networkFactory;
+ private final CyTableFactory tableFactory;
+ private final CyNetworkManager manager;
+ private final CyTableManager tableManager;
+
+ private CyNetwork newNetwork;
+
+ public ImportNetworkFromGeneTask(final String queryString,
+ final CyNetworkFactory networkFactory,
+ final CyTableFactory tableFactory,
+ final CyNetworkManager manager,
+ final CyTableManager tableManager)
+ {
+ this.queryString = queryString;
+ this.networkFactory = networkFactory;
+ this.manager = manager;
+ this.tableFactory = tableFactory;
+ this.tableManager = tableManager;
+ }
+
+ @Override
+ public void run(TaskMonitor taskMonitor) throws Exception {
+ logger.debug("Import Start: Query = " + queryString);
+
+ taskMonitor.setProgress(0.01d);
+
+ final EntrezRestClient restClient =
+ new EntrezRestClient(networkFactory, tableFactory,
tableManager);
+
+ taskMonitor.setTitle("Accessing NCBI Entrez Gene");
+ taskMonitor.setStatusMessage("Searching matching genes...");
+ final Set<String> searchResult = restClient.search(queryString);
+
+ if(searchResult.size() == 0)
+ return;
+
+ taskMonitor.setStatusMessage("Creating network from matching
genes...");
+ newNetwork = restClient.importNetwork(searchResult,
taskMonitor);
+
+ // Register it
+ newNetwork.getRow(newNetwork).set(CyTableEntry.NAME, "NCBI");
+ manager.addNetwork(newNetwork);
+ }
+
+ public CyNetwork getNetwork() {
+ return newNetwork;
+ }
+}
Deleted:
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
===================================================================
---
core3/impl/trunk/webservice-ncbi-client-impl/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
2011-12-06 19:38:22 UTC (rev 27709)
+++
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
2011-12-12 22:21:56 UTC (rev 27772)
@@ -1,156 +0,0 @@
-/*
- Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package org.cytoscape.webservice.ncbi.ui;
-
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.swing.DefaultListModel;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNetworkManager;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.webservice.ncbi.NCBIQuery;
-import org.cytoscape.webservice.ncbi.NCBITableImportClient;
-import org.cytoscape.work.TaskManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Simple attribute import GUI for Entrez Gene database This UI depends on
- */
-public class NCBIGenePanel extends AttributeImportPanel {
-
- private static final long serialVersionUID = -7433578094886775930L;
-
- private static final Logger logger =
LoggerFactory.getLogger(NCBIGenePanel.class);
-
- private static final Icon LOGO = new
ImageIcon(NCBIGenePanel.class.getResource("/images/entrez_page_title.gif"));
-
- private DefaultListModel model;
-
- private final NCBITableImportClient client;
- private final TaskManager taskManager;
-
- public NCBIGenePanel(final NCBITableImportClient client, final
TaskManager taskManager,
- final CyNetworkManager netManager, String
attrPanelName) {
- super(netManager, LOGO, "NCBI Client", attrPanelName);
- this.client = client;
- this.taskManager = taskManager;
-
- initDataSources();
- titleLabel.setText("");
- this.setPreferredSize(new Dimension(650, 480));
- }
-
- private void initDataSources() {
- this.databaseComboBox.addItem("NCBI Entrez Gene");
- databaseComboBox.setEnabled(false);
- setDataType();
- }
-
- private void setDataType() {
- this.attributeTypeComboBox.addItem("Entrez Gene ID");
- attributeTypeComboBox.setEnabled(false);
-
- buildList();
- }
-
- protected void importButtonActionPerformed(ActionEvent e) {
- importAttributes();
- }
-
- protected void resetButtonActionPerformed(ActionEvent e) {
- buildList();
- }
-
- private void buildList() {
- model = new DefaultListModel();
- attrCheckboxList.setModel(model);
- for (AnnotationCategory dispAttrName :
AnnotationCategory.values()) {
- model.addElement(dispAttrName.getName());
- }
- }
-
- @Override
- protected void importAttributes() {
- logger.debug("Import start.");
- client.setQuery(new NCBIQuery(getCategory(), createIDSet()));
- taskManager.execute(client);
- }
-
- private Set<AnnotationCategory> getCategory() {
- final Set<AnnotationCategory> category = new
HashSet<AnnotationCategory>();
- final Object[] selectedAttr =
attrCheckboxList.getSelectedValues();
- for (Object name : selectedAttr) {
- logger.debug("Category Selected: " + name);
- AnnotationCategory ann =
AnnotationCategory.getValue(name.toString());
-
- if (ann != null)
- category.add(ann);
- }
- return category;
- }
-
- private Set<String> createIDSet() {
- final Set<String> idList = new HashSet<String>();
- final String attrName =
this.attributeComboBox.getSelectedItem().toString();
-
- logger.debug("Attr Name = " + attrName);
-
- final Set<CyNetwork> networks = this.netManager.getNetworkSet();
- for(final CyNetwork net: networks) {
- final List<CyNode> nodes = net.getNodeList();
- for(final CyNode node: nodes) {
- final String val =
node.getCyRow().get(attrName, String.class);
- if(val != null) {
- logger.debug("node ID found = " + val);
- idList.add(val);
- }
- }
- }
- return idList;
- }
-
- @Override
- protected void databaseComboBoxActionPerformed(ActionEvent evt) {
- // TODO Auto-generated method stub
- }
-}
Copied:
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
(from rev 27770,
core3/impl/trunk/webservice-ncbi-client-impl/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java)
===================================================================
---
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
(rev 0)
+++
csplugins/trunk/ucsd/kono/cy3plugins/src/main/java/org/cytoscape/webservice/ncbi/ui/NCBIGenePanel.java
2011-12-12 22:21:56 UTC (rev 27772)
@@ -0,0 +1,156 @@
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.webservice.ncbi.ui;
+
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.DefaultListModel;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.webservice.ncbi.NCBIQuery;
+import org.cytoscape.webservice.ncbi.NCBITableImportClient;
+import org.cytoscape.work.TaskManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Simple attribute import GUI for Entrez Gene database This UI depends on
+ */
+public class NCBIGenePanel extends AttributeImportPanel {
+
+ private static final long serialVersionUID = -7433578094886775930L;
+
+ private static final Logger logger =
LoggerFactory.getLogger(NCBIGenePanel.class);
+
+ private static final Icon LOGO = new
ImageIcon(NCBIGenePanel.class.getResource("/images/entrez_page_title.gif"));
+
+ private DefaultListModel model;
+
+ private final NCBITableImportClient client;
+ private final TaskManager taskManager;
+
+ public NCBIGenePanel(final NCBITableImportClient client, final
TaskManager taskManager,
+ final CyNetworkManager netManager, String
attrPanelName) {
+ super(netManager, LOGO, "NCBI Client", attrPanelName);
+ this.client = client;
+ this.taskManager = taskManager;
+
+ initDataSources();
+ titleLabel.setText("");
+ this.setPreferredSize(new Dimension(650, 480));
+ }
+
+ private void initDataSources() {
+ this.databaseComboBox.addItem("NCBI Entrez Gene");
+ databaseComboBox.setEnabled(false);
+ setDataType();
+ }
+
+ private void setDataType() {
+ this.attributeTypeComboBox.addItem("Entrez Gene ID");
+ attributeTypeComboBox.setEnabled(false);
+
+ buildList();
+ }
+
+ protected void importButtonActionPerformed(ActionEvent e) {
+ importAttributes();
+ }
+
+ protected void resetButtonActionPerformed(ActionEvent e) {
+ buildList();
+ }
+
+ private void buildList() {
+ model = new DefaultListModel();
+ attrCheckboxList.setModel(model);
+ for (AnnotationCategory dispAttrName :
AnnotationCategory.values()) {
+ model.addElement(dispAttrName.getName());
+ }
+ }
+
+ @Override
+ protected void importAttributes() {
+ logger.debug("Import start.");
+ client.setQuery(new NCBIQuery(getCategory(), createIDSet()));
+ taskManager.execute(client);
+ }
+
+ private Set<AnnotationCategory> getCategory() {
+ final Set<AnnotationCategory> category = new
HashSet<AnnotationCategory>();
+ final Object[] selectedAttr =
attrCheckboxList.getSelectedValues();
+ for (Object name : selectedAttr) {
+ logger.debug("Category Selected: " + name);
+ AnnotationCategory ann =
AnnotationCategory.getValue(name.toString());
+
+ if (ann != null)
+ category.add(ann);
+ }
+ return category;
+ }
+
+ private Set<String> createIDSet() {
+ final Set<String> idList = new HashSet<String>();
+ final String attrName =
this.attributeComboBox.getSelectedItem().toString();
+
+ logger.debug("Attr Name = " + attrName);
+
+ final Set<CyNetwork> networks = this.netManager.getNetworkSet();
+ for(final CyNetwork net: networks) {
+ final List<CyNode> nodes = net.getNodeList();
+ for(final CyNode node: nodes) {
+ final String val =
net.getRow(node).get(attrName, String.class);
+ if(val != null) {
+ logger.debug("node ID found = " + val);
+ idList.add(val);
+ }
+ }
+ }
+ return idList;
+ }
+
+ @Override
+ protected void databaseComboBoxActionPerformed(ActionEvent evt) {
+ // TODO Auto-generated method stub
+ }
+}
--
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.