Author: rodche
Date: 2011-10-26 12:19:53 -0700 (Wed, 26 Oct 2011)
New Revision: 27306
Removed:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathException.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProperties.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProtocol.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathResponseFormat.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebService.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceImpl.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceListener.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CytoscapeCPathWebService.java
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/EmptySetException.java
Log:
deleted
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathException.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathException.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathException.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,127 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-/**
- * Indicates Error Connecting to cPath.
- *
- * @author Ethan Cerami.
- */
-public class CPathException extends Exception {
- /**
- * Error: Canceled by User.
- */
- public final static int ERROR_CANCELED_BY_USER = 1;
-
- /**
- * Error: Unknown Host.
- */
- public final static int ERROR_UNKNOWN_HOST = 2;
-
- /**
- * Error: Network IO.
- */
- public final static int ERROR_NETWORK_IO = 3;
-
- /**
- * Error: XML Parsing.
- */
- public final static int ERROR_XML_PARSING = 4;
-
- /**
- * Error: Web Service API.
- */
- public final static int ERROR_WEB_SERVICE_API = 5;
-
- /**
- * Error HTTP
- */
- public final static int ERROR_HTTP = 6;
-
- private int errorCode;
- private String errorMessage;
- private String errorDetail;
- private String recoveryTip;
-
- private final static String NETWORK_RECOVERY_TIP
- = "Please check your network settings and try again.";
-
- private final static String SERVER_ERROR_RECOVERY_TIP
- = "Please try a different search term, or try again later.";
-
- /**
- * Constructor.
- * @param errorCode Error Code.
- * @param t Root throwable.
- */
- public CPathException(int errorCode, Throwable t) {
- super(t);
- this.errorCode = errorCode;
- setErrorMessages(errorCode);
- if (t != null) {
- errorMessage = errorMessage + " " + t.getMessage();
- }
- }
-
- public CPathException(int errorCode, String errorDetail) {
- this.errorDetail = errorDetail;
- this.errorCode = errorCode;
- setErrorMessages(errorCode);
- if (errorDetail != null) {
- errorMessage = errorMessage + " " + errorDetail;
- }
- }
-
- /**
- * Gets the Error Code.
- * @return Error Code.
- */
- public int getErrorCode() {
- return errorCode;
- }
-
- /**
- * Gets Error Message.
- * @return Error Message.
- */
- public String getMessage() {
- return errorMessage;
- }
-
- /**
- * Gets the Recovery Tip.
- * @return Recovery Tip.
- */
- public String getRecoveryTip() {
- return recoveryTip;
- }
-
- private void setErrorMessages(int errorCode) {
- switch (errorCode) {
- case ERROR_CANCELED_BY_USER:
- errorMessage = "Canceled by user.";
- break;
- case ERROR_UNKNOWN_HOST:
- errorMessage = "Network error occurred while tring to connect
to "
- + "remote web service.";
- recoveryTip = NETWORK_RECOVERY_TIP;
- break;
- case ERROR_NETWORK_IO:
- errorMessage = "Network error occurred while tring to connect
to "
- + "remote web service.";
- recoveryTip = NETWORK_RECOVERY_TIP;
- break;
- case ERROR_XML_PARSING:
- errorMessage = "Error occurred while trying to parse XML
results "
- + "retrieved from remote web service.";
- break;
- case ERROR_HTTP:
- errorMessage = "Network error occurred while trying to
connect to "
- + "remote web service.";
- recoveryTip = SERVER_ERROR_RECOVERY_TIP;
- break;
- case ERROR_WEB_SERVICE_API:
- errorMessage = "Error occurred while trying to connect to
remote web service. ";
- recoveryTip = SERVER_ERROR_RECOVERY_TIP;
- break;
- }
- }
-}
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProperties.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProperties.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProperties.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,63 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-import java.util.ArrayList;
-
-import org.cytoscape.cpathsquared.internal.view.Organism;
-
-/**
- * Contains cPath Specific Properties
- *
- * @author Ethan Cerami, Igor Rodchenkov
- */
-public class CPathProperties {
- /**
- * Download Networks in Full BioPAX Mode.
- */
- public final static int DOWNLOAD_FULL_BIOPAX = 1;
-
- /**
- * Download Networks in Binary SIF Reduced Mode
- */
- public final static int DOWNLOAD_REDUCED_BINARY_SIF = 2;
-
-
- public static String cPathUrl = "http://www.pathwaycommons.org/pc2/";
-
- public static String serverName = "Pathway Commons (BioPAX L3)";
-
- public static String blurb =
- "<span class='bold'>Pathway Commons</span> is a convenient
point of access " +
- "to biological pathway " +
- "information collected from public pathway databases, which you
can " +
- "browse or search. <BR><BR>Pathways include biochemical reactions,
complex " +
- "assembly, transport and catalysis events, and physical
interactions " +
- "involving proteins, DNA, RNA, small molecules and complexes.";
-
- public static String iconToolTip = "Retrieve Pathway Data from
PathwayCommons.org";
-
- public static String iconFileName = "pc.png";
-
- public static ArrayList<Organism> organismList = new ArrayList<Organism>();
-
- public static int downloadMode = DOWNLOAD_REDUCED_BINARY_SIF;
-
- private CPathProperties () {
- // no-op; private constructor;
- }
-
- static {
- organismList.add(new Organism("Human", 9606));
- organismList.add(new Organism("Mouse", 10090));
- organismList.add(new Organism("Rat", 10116));
- organismList.add(new Organism("S. cerevisiae", 4932));
- }
-
- /**
- * Gets the Web Services ID.
- * @return Web Service ID.
- */
- public static String getWebServicesId() {
- String temp = serverName.toLowerCase();
- return temp.replaceAll(" ", "_");
- }
-}
\ No newline at end of file
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProtocol.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProtocol.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathProtocol.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,412 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.net.Proxy;
-import java.net.SocketException;
-import java.net.URLEncoder;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.cytoscape.work.TaskMonitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.converter.FormHttpMessageConverter;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * Utility Class for Connecting to the cPathSquared Web Service API.
- *
- * @author Ethan Cerami, Igor Rodchenkov
- */
-public class CPathProtocol {
- /**
- * Query Argument.
- */
- public static final String ARG_QUERY = "q";
-
- /**
- * Format Argument.
- */
- public static final String ARG_FORMAT = "output";
-
- /**
- * Organism Argument.
- */
- public static final String ARG_ORGANISM = "organism";
-
- /**
- * Max Hits Argument.
- */
- public static final String ARG_MAX_HITS = "maxHits";
-
- /**
- * Start Index Argument.
- */
- public static final String ARG_START_INDEX = "startIndex";
-
- /**
- * Get Records By Keyword.
- */
- public static final String COMMAND_SEARCH ="entity/find";
-
- /**
- * Gets Parent Summaries.
- */
- public static final String COMMAND_GET_PARENTS = "get_parents";
-
- /**
- * Get Interactions By Interactor Name / Xref.
- */
- public static final String COMMAND_GET_BY_INTERACTOR_XREF =
- "get_by_interactor_name_xref";
-
- /**
- * Get Interactions By Organism.
- */
- public static final String COMMAND_GET_BY_ORGANISM =
- "get_by_organism";
-
- /**
- * Get Interactions By Experiment Type.
- */
- public static final String COMMAND_GET_BY_EXPERIMENT_TYPE =
- "get_by_experiment_type";
-
- /**
- * Get Interactions by PMID.
- */
- public static final String COMMAND_GET_BY_PMID =
- "get_by_pmid";
-
- /**
- * Get Interactions By Database.
- */
- public static final String COMMAND_GET_BY_DATABASE =
- "get_by_database";
-
- /**
- * Get Top Level Pathway List.
- */
- //TODO cPathSquared WS API does not currently support this
- public static final String COMMAND_GET_TOP_LEVEL_PATHWAY_LIST =
- "get_top_level_pathway_list";
-
- /**
- * Get Patheway record by CPath ID.
- */
- public static final String COMMAND_GET = "get";
-
- /**
- * Default for Max Hits.
- */
- public static final int DEFAULT_MAX_HITS = 10;
-
- /**
- * Not Specified
- */
- public static final int NOT_SPECIFIED = -1;
-
- /**
- * XML Tag.
- */
- private static final String XML_TAG = "xml";
-
- /*** Default initial size of the response buffer if content length is
unknown. */
- private static final int DEFAULT_INITIAL_BUFFER_SIZE = 4*1024; // 4 kB
-
- private String command;
- private String query;
- private int taxonomyId;
- private int maxHits;
- private int startIndex;
- private String format;
- private String baseUrl;
- private boolean cancelledByUser = false;
- private static boolean debug = false;
- private Logger logger = LoggerFactory.getLogger(CPathProtocol.class);
-
- private RestTemplate template;
-
- /**
- * Constructor.
- */
- public CPathProtocol() {
- this.baseUrl = CPathProperties.cPathUrl;
- this.maxHits = DEFAULT_MAX_HITS;
- this.taxonomyId = NOT_SPECIFIED;
- template = new RestTemplate();
- List<HttpMessageConverter<?>> msgCovs = new
ArrayList<HttpMessageConverter<?>>();
- msgCovs.add(new FormHttpMessageConverter());
- msgCovs.add(new StringHttpMessageConverter());
- template.setMessageConverters(msgCovs);
- }
-
- /**
- * Sets the Command Argument.
- *
- * @param command Command Argument.
- */
- public void setCommand (String command) {
- this.command = command;
- }
-
- /**
- * Sets the Query Argument.
- *
- * @param query Query Argument.
- */
- public void setQuery (String query) {
- this.query = query;
- }
-
- /**
- * Sets the Format Argument.
- *
- * @param format Format Argument.
- */
- public void setFormat (CPathResponseFormat format) {
- this.format = format.getFormatString();
- }
-
- /**
- * Sets the Organism Argument.
- *
- * @param taxonomyId NCBI TaxonomyID
- */
- public void setOrganism (int taxonomyId) {
- this.taxonomyId = taxonomyId;
- }
-
- /**
- * Sets the MaxHits Argument.
- *
- * @param maxHits Max Number of Hits.
- */
- public void setMaxHits (int maxHits) {
- this.maxHits = maxHits;
- }
-
- /**
- * Sets the StartIndex Argument.
- *
- * @param startIndex StartIndex Argument.
- */
- public void setStartIndex (int startIndex) {
- this.startIndex = startIndex;
- }
-
-
- /**
- * Connects to cPath Web Service API.
- *
- * @return XML Document.
- * @throws CPathException Indicates Error connecting.
- * @throws EmptySetException All went all, but no results found.
- */
- //TODO use Spring RestTemplate and MultiValueMap
- public String connect (TaskMonitor taskMonitor) throws CPathException,
EmptySetException {
- try {
- NameValuePair[] nvps;
-
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
- setProxyInfo(client);
-
- // Create a method instance.
- // If the query string is long, use POST. Otherwise, use GET.
- if (query != null && query.length() > 100) {
- nvps = createNameValuePairs(true);
- method = new PostMethod(baseUrl);
- ((PostMethod)(method)).addParameters(nvps);
- logger.info("Connect: " + method.getURI() + " (via POST)");
- } else {
- nvps = createNameValuePairs(false);
- String liveUrl = createURI(baseUrl, nvps);
- method = new GetMethod(liveUrl);
- logger.info("Connect: " + liveUrl);
- }
-
- int statusCode = client.executeMethod(method);
-
- // Check status code
- checkHttpStatusCode(statusCode);
-
- // Read in Content
- InputStream instream = method.getResponseBodyAsStream();
- long contentLength = method.getResponseContentLength();
- if (contentLength > 0) {
- if (taskMonitor != null) {
- taskMonitor.setProgress(0);
- }
- }
-
- ByteArrayOutputStream outstream = new ByteArrayOutputStream(
- contentLength > 0 ? (int) contentLength :
DEFAULT_INITIAL_BUFFER_SIZE);
- byte[] buffer = new byte[4096];
- int len;
- int totalBytes = 0;
- while ((len = instream.read(buffer)) > 0) {
- outstream.write(buffer, 0, len);
- totalBytes = updatePercentComplete(contentLength, len,
totalBytes, taskMonitor);
- }
- instream.close();
-
- String content = new String(outstream.toByteArray());
- if (content.toLowerCase().indexOf(XML_TAG) >= 0) {
- // Check for protocol errors.
- if (content.indexOf("<error>") >=0) {
- StringReader reader = new StringReader(content);
- SAXBuilder builder = new SAXBuilder();
- Document document = builder.build(reader);
- checkForErrors(document);
- }
- return content.trim();
- } else {
- return content.trim();
- }
- } catch (UnknownHostException e) {
- throw new CPathException(CPathException.ERROR_UNKNOWN_HOST, e);
- } catch (SocketException e) {
- if (cancelledByUser) {
- throw new
CPathException(CPathException.ERROR_CANCELED_BY_USER, e);
- } else {
- throw new CPathException(CPathException.ERROR_NETWORK_IO, e);
- }
- } catch (IOException e) {
- throw new CPathException(CPathException.ERROR_NETWORK_IO, e);
- } catch (JDOMException e) {
- throw new CPathException(CPathException.ERROR_XML_PARSING, e);
- }
- }
-
- /**
- * Sets Proxy Information (if set).
- */
- private void setProxyInfo(HttpClient client) {
- // TODO: Port this.
-// Proxy proxyServer = ProxyHandler.getProxyServer();
- Proxy proxyServer = null;
-
- // The java.net.Proxy object does not provide getters for host and
port.
- // So, we have to hack it by using the toString() method.
-
- // Note to self for future reference: I was able to test all this code
- // by downloading and installing Privoxy, a local HTTP proxy,
- // available at: http://www.privoxy.org/. Once it was running, I
used the
- // following props in ~/.cytoscape/cytoscape.props:
- // proxy.server=127.0.0.1
- // proxy.server.port=8118
- // proxy.server.type=HTTP
- if (proxyServer != null) {
- String proxyAddress = proxyServer.toString();
- if (debug) logger.debug("full proxy string: " + proxyAddress);
- String[] addressComponents = proxyAddress.split("@");
- if (addressComponents.length == 2) {
- String parts[] = addressComponents[1].split(":");
- if (parts.length == 2) {
- String hostString = parts[0].trim();
- String hostParts[] = hostString.split("/");
- if (hostParts.length > 0) {
- String host = hostParts[0].trim();
- String port = parts[1].trim();
- if (debug) logger.debug("proxy host: " + host);
- if (debug) logger.debug("proxy port: " + port);
- client.getHostConfiguration().setProxy(host,
Integer.parseInt(port));
- }
- }
- }
- }
- }
-
- private int updatePercentComplete(long contentLength, int len, int
totalBytes,
- TaskMonitor taskMonitor) {
- if (contentLength > 0) {
- totalBytes += len;
- double percentComplete = (int) ((totalBytes / (double)
contentLength));
- if (taskMonitor != null) {
- taskMonitor.setProgress(percentComplete);
- }
- if (debug) {
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- return totalBytes;
- }
-
- /**
- * Gets URI
- *
- * @return URI.
- */
- public String getURI () {
- NameValuePair[] nvps = createNameValuePairs(false);
- return createURI(baseUrl, nvps);
- }
-
- /**
- * Gets URI of cPath Call.
- *
- * @return URI for cPath Call.
- */
- private String createURI (String url, NameValuePair[] nvps) {
- StringBuffer buf = new StringBuffer(url);
- buf.append(command + "?");
- for (int i = 0; i < nvps.length; i++) {
- buf.append(nvps[i].getName() + "=" + nvps[i].getValue() + "&");
- }
- return buf.toString();
- }
-
- private NameValuePair[] createNameValuePairs (boolean post) {
- NameValuePair nvps[] = null;
- if (taxonomyId == NOT_SPECIFIED) {
- nvps = new NameValuePair[5];
- } else {
- nvps = new NameValuePair[6];
- nvps[5] = new NameValuePair(ARG_ORGANISM,
- Integer.toString(taxonomyId));
- }
- try {
- if (!post) {
- nvps[0] = new NameValuePair(ARG_QUERY,
URLEncoder.encode(query, "UTF-8"));
- } else {
- nvps[0] = new NameValuePair(ARG_QUERY, query);
- }
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- nvps[1] = new NameValuePair(ARG_FORMAT, format);
- nvps[2] = new NameValuePair(ARG_VERSION, CURRENT_VERSION);
- nvps[3] = new NameValuePair(ARG_MAX_HITS, Integer.toString(maxHits));
- nvps[4] = new NameValuePair(ARG_START_INDEX,
- Integer.toString(startIndex));
- return nvps;
- }
-
- private void checkForErrors (Document document)
- throws CPathException, EmptySetException {
- Element element = document.getRootElement();
- String name = element.getName();
- if (name.equals("error")) {
- String errorCode = element.getChild("error_code").getText();
- String errorMsg = element.getChild("error_msg").getText();
- if (errorCode.equals("460")) {
- throw new EmptySetException();
- } else {
- throw new CPathException(CPathException.ERROR_WEB_SERVICE_API,
- "Error Code: " + errorCode + ", " + errorMsg + ".");
- }
- }
- }
-}
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathResponseFormat.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathResponseFormat.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathResponseFormat.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,57 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-/**
- * CPath Response Format.
- */
-public class CPathResponseFormat {
- private String format;
-
- /**
- * BioPAX Format.
- */
- public static CPathResponseFormat BIOPAX = new CPathResponseFormat
("biopax");
-
- /**
- * Simplified Binary SIF Format.
- */
- public static CPathResponseFormat BINARY_SIF = new CPathResponseFormat
("binary_sif");
-
- /**
- * Generic XML Format.
- */
- public static CPathResponseFormat GENERIC_XML = new CPathResponseFormat
("xml");
-
- /**
- * Gets the Proper cPath Response Format.
- * @param format Format String.
- * @return CPathResponseFormat Object.
- */
- public static CPathResponseFormat getResponseFormat (String format) {
- if (format.equals(BIOPAX.getFormatString())) {
- return BIOPAX;
- } else if (format.equals(BINARY_SIF.getFormatString())) {
- return BINARY_SIF;
- } else if (format.equals(GENERIC_XML.getFormatString())) {
- return GENERIC_XML;
- }
- else {
- throw new IllegalArgumentException ("Format: " + format + " is
not valid.");
- }
- }
-
- /**
- * Private Constructor.
- * @param format Format String.
- */
- private CPathResponseFormat(String format) {
- this.format = format;
- }
-
- /**
- * Gets the format string.
- * @return format string.
- */
- public String getFormatString() {
- return this.format;
- }
-}
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebService.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebService.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebService.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,99 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.biopax.paxtools.model.level3.BioSource;
-import org.biopax.paxtools.model.level3.Entity;
-import org.cytoscape.cpath.service.jaxb.*;
-import org.cytoscape.work.TaskMonitor;
-
-/**
- * Interface for accessing the cPath Web API.
- *
- * @author Ethan Cerami
- */
-public interface CPathWebService {
-
- /**
- * Searches for Physical Entities in cPath Instance.
- * Given a keyword, such as "BRCA1", this method returns the first 10
physical entities
- * which contain this keyword. For each matching physical entity, you
will receive
- * entity details, such as name, synonyms, external links, and list of all
pathways in
- * which this entity participates.
- *
- * @param keyword Keyword to search for.
- * @param ncbiTaxonomyId Organism filter (-1 to to search all organisms).
- * @param taskMonitor TaskMonitor Object (can be null);
- * @return SearchResponseType Object.
- * @throws CPathException CPath Connect Error.
- * @throws EmptySetException No matches found to specified query.
- */
- public SearchResponseType searchPhysicalEntities(String keyword, int
ncbiTaxonomyId,
- TaskMonitor taskMonitor) throws CPathException, EmptySetException;
-
- /**
- * Gets parent summaries for specified record.
- * For example, if primaryId refers to protein A, the "parent" records are
all
- * interactions in which protein A participates. If primaryId refers to
interaction X,
- * the "parent" records are all parent interactions which control or
modulate X.
- * To retrieve the full record (instead of just the summary), you must
extract the primary
- * ID, and follow-up with a call to getRecordsByIds().
- *
- * @param primaryId Primary ID of Record.
- * @param taskMonitor Task Monitor Object.
- * @return List of parent BioPAX Entities
- * @throws CPathException CPath Error.
- * @throws EmptySetException Empty Set Error.
- */
- public List<Entity> getParentSummaries (String primaryId, TaskMonitor
taskMonitor)
- throws CPathException, EmptySetException;
-
- /**
- * Gets One or more records by primary ID.
- * You can obtain primary IDs for physical entities and/or pathways via the
- * searchPhysicalEntities() method.
- *
- * @param ids Array of Primary IDs.
- * @param format CPathResponseFormat.BIOPAX or
CPathResponseFormat.BINARY_SIF.
- * @param taskMonitor Task Monitor Object.
- * @return BioPAX XML String or SIF String.
- * @throws CPathException CPath Error.
- * @throws EmptySetException Empty Set Error.
- */
- public String getRecordsByIds(String[] ids, CPathResponseFormat format,
TaskMonitor taskMonitor)
- throws CPathException, EmptySetException;
-
- /**
- * Gets a list of all Organisms currently available within the cPath
instance.
- *
- * @return List of Organism (BioSource) Objects.
- */
- public List<BioSource> getOrganismList();
-
- /**
- * Abort the Request.
- */
- public void abort();
-
- /**
- * Registers a new listener.
- *
- * @param listener CPathWebService Listener.
- */
- public void addApiListener(CPathWebServiceListener listener);
-
- /**
- * Removes the specified listener.
- *
- * @param listener CPathWebService Listener.
- */
- public void removeApiListener(CPathWebServiceListener listener);
-
- /**
- * Gets the list of all registered listeners.
- *
- * @return ArrayList of CPathWebServiceListener Objects.
- */
- public ArrayList<CPathWebServiceListener> getListeners();
-}
\ No newline at end of file
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceImpl.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceImpl.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceImpl.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,259 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
-
-import org.biopax.paxtools.model.level3.Entity;
-import org.cytoscape.cpath.service.jaxb.*;
-import org.cytoscape.work.TaskMonitor;
-
-/**
- * Class for accessing the cPath Web API.
- *
- * @author Ethan Cerami
- */
-public class CPathWebServiceImpl implements CPathWebService {
- private static ArrayList<CPathWebServiceListener> listeners =
- new ArrayList<CPathWebServiceListener>();
- private volatile CPathProtocol protocol;
- private static CPathWebService webApi;
-
- /**
- * Gets Singelton instance of CPath Web API.
- * @return CPathWebService Object.
- */
- public static CPathWebService getInstance() {
- if (webApi == null) {
- webApi = new CPathWebServiceImpl();
- }
- return webApi;
- }
-
- /**
- * Private Constructor.
- */
- private CPathWebServiceImpl() {
- }
-
- /**
- * Searches Physical Entities in cPath Instance.
- *
- * @param keyword Keyword to search for.
- * @param ncbiTaxonomyId Organism filter (-1 to to search all organisms)
- * @return SearchResponseType Object.
- */
- public SearchResponseType searchPhysicalEntities(String keyword, int
ncbiTaxonomyId,
- TaskMonitor taskMonitor) throws CPathException, EmptySetException {
-
- // Notify all listeners of start
- for (int i = listeners.size() - 1; i >= 0; i--) {
- CPathWebServiceListener listener = listeners.get(i);
- listener.searchInitiatedForPhysicalEntities(keyword,
ncbiTaxonomyId);
- }
-
- protocol = new CPathProtocol();
- protocol.setCommand(CPathProtocol.COMMAND_SEARCH);
- protocol.setOrganism(ncbiTaxonomyId);
- protocol.setFormat(CPathResponseFormat.GENERIC_XML);
- protocol.setQuery(keyword);
-
- SearchResponseType searchResponse;
- if (keyword.equalsIgnoreCase("dummy")) {
- searchResponse = this.createDummySearchResults();
- searchResponse.setTotalNumHits(Long.valueOf(10L));
- } else {
- String responseXml = protocol.connect(taskMonitor);
- StringReader reader = new StringReader(responseXml);
-
- Class[] classes = new Class[2];
- classes[0] = SearchResponseType.class;
- try {
- JAXBContext jc = JAXBContext.newInstance(classes);
- Unmarshaller u = jc.createUnmarshaller();
- JAXBElement element = (JAXBElement) u.unmarshal(reader);
- searchResponse = (SearchResponseType) element.getValue();
- } catch(Throwable e){
- throw new CPathException(CPathException.ERROR_XML_PARSING, e);
- }
- }
-
- //SearchResponseType searchResponse = createDummySearchResults();
- // Notify all listeners of end
- for (int i = listeners.size() - 1; i >= 0; i--) {
- CPathWebServiceListener listener = listeners.get(i);
- listener.searchCompletedForPhysicalEntities(searchResponse);
- }
- return searchResponse;
- }
-
- /**
- * Gets parent summaries for specified record.
- *
- * @param primaryId Primary ID of Record.
- * @param taskMonitor Task Monitor Object.
- * @return SummaryResponse Object.
- * @throws CPathException CPath Error.
- * @throws EmptySetException Empty Set Error.
- */
- public List<Entity> getParentSummaries (String primaryId, TaskMonitor
taskMonitor)
- throws CPathException, EmptySetException {
- // Notify all listeners of start
- for (int i = listeners.size() - 1; i >= 0; i--) {
- CPathWebServiceListener listener = listeners.get(i);
- listener.requestInitiatedForParentSummaries(primaryId);
- }
-
- protocol = new CPathProtocol();
- protocol.setCommand(CPathProtocol.COMMAND_GET_PARENTS);
- protocol.setFormat(CPathResponseFormat.GENERIC_XML);
-
- protocol.setQuery(Long.toString(primaryId));
-
- SummaryResponseType summaryResponse;
- String responseXml = protocol.connect(taskMonitor);
- StringReader reader = new StringReader(responseXml);
-
- Class[] classes = new Class[2];
- classes[0] =
org.cytoscape.cpathsquared.internal.schemas.summary_response.SummaryResponseType.class;
- classes[1] =
org.cytoscape.cpathsquared.internal.schemas.summary_response.ObjectFactory.class;
- try {
- JAXBContext jc = JAXBContext.newInstance(classes);
- Unmarshaller u = jc.createUnmarshaller();
- JAXBElement element = (JAXBElement) u.unmarshal(reader);
- summaryResponse = (SummaryResponseType) element.getValue();
- } catch(Throwable e){
- throw new CPathException(CPathException.ERROR_XML_PARSING, e);
- }
-
- // Notify all listeners of end
- for (int i = listeners.size() - 1; i >= 0; i--) {
- CPathWebServiceListener listener = listeners.get(i);
- listener.requestCompletedForParentSummaries(primaryId,
summaryResponse);
- }
- return summaryResponse;
- }
-
- /**
- * Gets One or more records by Primary ID.
- * @param ids Array of Primary IDs.
- * @param format CPathResponseFormat Object.
- * @param taskMonitor Task Monitor Object.
- * @return BioPAX XML String.
- * @throws CPathException CPath Error.
- * @throws EmptySetException Empty Set Error.
- */
- public String getRecordsByIds(String[] ids, CPathResponseFormat format,
- TaskMonitor taskMonitor) throws CPathException, EmptySetException {
- protocol = new CPathProtocol();
- protocol.setCommand(CPathProtocol.COMMAND_GET);
- protocol.setFormat(format);
- StringBuffer q = new StringBuffer();
- for (int i=0; i<ids.length; i++) {
- q.append (Long.toString(ids[i])+",");
- }
- protocol.setQuery(q.toString());
- String xml = protocol.connect(taskMonitor);
- return xml;
- }
-
- /**
- * Abort the Request.
- */
- public void abort() {
- //TODO
- }
-
- private SearchResponseType createDummySearchResults() {
- SearchResponseType searchResponse = new SearchResponseType();
- List<ExtendedRecordType> searchHits = searchResponse.getSearchHit();
- for (int i = 0; i < 10; i++) {
- ExtendedRecordType searchHit = new ExtendedRecordType();
- searchHit.setName("Protein " + i);
-
- OrganismType organism = new OrganismType();
- organism.setCommonName("Human");
- organism.setSpeciesName("Homo Sapiens");
- searchHit.setOrganism(organism);
-
- List synList = new ArrayList();
- synList.add("Synonym 1");
- synList.add("Synonym 2");
- synList.add("Synonym 3");
- synList.add("Synonym 4");
- searchHit.getSynonym().addAll(synList);
-
- List <XRefType> xrefList = new ArrayList();
- for (int j=0; j<3; j++) {
- XRefType xref = new XRefType();
- xref.setDb("Database_" + j);
- xref.setId("ID_" + j);
- xref.setUrl("http://www.yahoo.com");
- xrefList.add(xref);
- }
- searchHit.getXref().addAll(xrefList);
-
- List extracts = searchHit.getExcerpt();
- extracts.add ("Vestibulum pharetra <B>laoreet ante</B> dictum
dolor sed, "
- + "elementum egestas nunc nullam, pede mauris mattis, eros
nam, elit "
- + "aliquam lorem vestibulum duis a tortor. Adipiscing elit
habitant justo, "
- + "nonummy nunc wisi eros, dictum eget orci placerat metus
vehicula eu.");
-
- ObjectFactory factory = new ObjectFactory();
- PathwayListType pathwayListType = factory.createPathwayListType();
- List <PathwayType> pathwayList = pathwayListType.getPathway();
- searchHit.setPathwayList(pathwayListType);
- for (int j = 0; j < 10; j++) {
- PathwayType pathwaySummary = new PathwayType();
- pathwaySummary.setName("Pathway " + j + "[" + i + "]");
- pathwaySummary.setPrimaryId((long) j);
- DataSourceType dataSource = new DataSourceType();
- dataSource.setName("Data Source " + j);
- pathwaySummary.setDataSource(dataSource);
- pathwayList.add(pathwaySummary);
- }
- searchHits.add(searchHit);
- }
- return searchResponse;
- }
-
- /**
- * Gets a list of all Organisms currently available within cPath instance.
- *
- * @return ArrayList of Organism Type Objects.
- */
- public List<BioSource> getOrganismList() {
- throw new UnsupportedOperationException("getOrganismList() is not yet
implemented.");
- }
-
- /**
- * Registers a new listener.
- *
- * @param listener CPathWebService Listener.
- */
- public void addApiListener(CPathWebServiceListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Removes the specified listener.
- *
- * @param listener CPathWebService Listener.
- */
- public void removeApiListener(CPathWebServiceListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Gets the list of all registered listeners.
- *
- * @return ArrayList of CPathWebServiceListener Objects.
- */
- public ArrayList<CPathWebServiceListener> getListeners() {
- return listeners;
- }
-}
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceListener.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceListener.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CPathWebServiceListener.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,45 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-import java.util.List;
-
-import org.biopax.paxtools.model.level3.Entity;
-import org.cytoscape.cpath.service.jaxb.SearchResponseType;
-
-/**
- * Listener for listener to Requests made to the cPath Web API.
- *
- * @author Ethan Cerami
- */
-public interface CPathWebServiceListener {
-
- /**
- * Indicates that someone has initiated a search for physical entities.
- *
- * @param keyword Keyword Term(s)
- * @param ncbiTaxonomyId NCBI Texonomy ID.
- */
- public void searchInitiatedForPhysicalEntities(String keyword, int
ncbiTaxonomyId);
-
- /**
- * Indicates that a search for physical entities has completed.
- *
- * @param peSearchResponse Search Response Object.
- */
- public void searchCompletedForPhysicalEntities(SearchResponseType
peSearchResponse);
-
- /**
- * Indicates that someone has initiated a request for parent summaries.
- *
- * @param primaryId Primary ID of Child.
- */
- public void requestInitiatedForParentSummaries (String primaryId);
-
- /**
- * Indicates that a request for parent summaries has completed.
- *
- * @param primaryId Primary ID of Child.
- * @param parents
- */
- public void requestCompletedForParentSummaries (String primaryId,
- List<Entity> parents);
-}
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CytoscapeCPathWebService.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CytoscapeCPathWebService.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/CytoscapeCPathWebService.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,140 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.util.List;
-import java.util.Set;
-
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-
-import org.cytoscape.cpathsquared.internal.CPath2Factory;
-import org.cytoscape.cpathsquared.internal.CPathNetworkImportTask;
-import org.cytoscape.cpathsquared.internal.CPathPlugIn2;
-import org.cytoscape.cpathsquared.internal.view.TabUi;
-import org.cytoscape.cpathsquared.internal.view.cPathSearchPanel;
-import org.cytoscape.io.webservice.NetworkImportWebServiceClient;
-import org.cytoscape.io.webservice.SearchWebServiceClient;
-import org.cytoscape.io.webservice.client.AbstractWebServiceClient;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.view.model.View;
-import org.cytoscape.work.TaskIterator;
-import org.cytoscape.work.Tunable;
-
-/**
- * CPath Web Service, integrated into the Cytoscape Web Services Framework.
- */
-public class CytoscapeCPathWebService extends AbstractWebServiceClient
implements NetworkImportWebServiceClient, SearchWebServiceClient<Object> {
- // Display name of this client.
- private static final String DISPLAY_NAME =
CPathProperties.getInstance().getCPathServerName() +
- " Web Service Client";
-
- /**
- * NCBI Taxonomy ID Filter.
- */
- public static final String NCBI_TAXONOMY_ID_FILTER =
"ncbi_taxonomy_id_filter";
-
- /**
- * Response Format.
- */
- public static final String RESPONSE_FORMAT = "response_format";
-
- @Tunable(description="Filter by Organism - NCBI Taxonomy ID")
- Integer taxonomyId = -1;
-
- private JPanel mainPanel;
-
- private final CPath2Factory factory;
-
- private CPathWebService webApi;
-
- public List<JMenuItem> getNodeContextMenuItems(View<CyNode> nodeView) {
- // TODO: Figure out how we're going to wire this up with OSGi
-// CyNetworkView networkView = (CyNetworkView) nodeView.getGraphView();
-// CyNetwork cyNetwork = networkView.getNetwork();
-// CyAttributes networkAttributes = Cytoscape.getNetworkAttributes();
-// Boolean b =
networkAttributes.getBooleanAttribute(cyNetwork.getIdentifier(),
-// BinarySifVisualStyleUtil.BINARY_NETWORK);
-// if (b != null) {
-// List<JMenuItem> menuList = new ArrayList<JMenuItem>();
-// JMenuItem menuItem = new JMenuItem ("Get Neighbors");
-// menuItem.addActionListener(new ExpandNode(nodeView));
-// menuList.add(menuItem);
-// return menuList;
-// }
- return null;
- }
-
- @Override
- public Container getQueryBuilderGUI() {
- return mainPanel;
- }
-
- @Override
- public Set<CyNetwork> getNetworks() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Object getSearchResult() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public TaskIterator getTaskIterator() {
- String query = "";
- CPathResponseFormat format = CPathResponseFormat.BINARY_SIF;
- CPathNetworkImportTask task =
factory.createCPathNetworkImportTask(query, webApi, format);
- return new TaskIterator(task);
- }
-
- /**
- * Creates a new Web Services client.
- * @param factory
- */
- public CytoscapeCPathWebService(CPath2Factory factory) {
- super(CPathProperties.getInstance().getCPathUrl(), DISPLAY_NAME,
makeDescription());
- this.factory = factory;
-
- // Set properties for this client.
- setProperty();
-
- mainPanel = new JPanel();
- mainPanel.setPreferredSize(new Dimension (500,400));
- mainPanel.setLayout (new BorderLayout());
-
- webApi = CPathWebServiceImpl.getInstance();
- cPathSearchPanel cpathPanel = new cPathSearchPanel(webApi, factory);
-
- TabUi tabbedPane = TabUi.getInstance();
- tabbedPane.add("Search", cpathPanel);
-
- JScrollPane configPanel = CPathPlugIn2.createConfigPanel();
- tabbedPane.add("Options", configPanel);
- mainPanel.add(tabbedPane, BorderLayout.CENTER);
- }
-
- private static String makeDescription() {
- String desc = CPathProperties.getInstance().getCPathBlurb();
- desc = desc.replaceAll("<span class='bold'>", "<B>");
- desc = desc.replaceAll("</span>", "</B>");
- return "<html><body>" + desc + "</body></html>";
- }
-
- /**
- * Set props for this client.
- */
- private void setProperty() {
-// props = new ModulePropertiesImpl(clientID, "wsc");
-// props.add(new Tunable(NCBI_TAXONOMY_ID_FILTER, "Filter by Organism -
NCBI Taxonomy ID",
-// Tunable.INTEGER, new Integer(-1)));
-// props.add(new Tunable(RESPONSE_FORMAT, "Response Format",
-// Tunable.INTEGER,
CPathResponseFormat.BINARY_SIF.getFormatString()));
- }
-}
-
Deleted:
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/EmptySetException.java
===================================================================
---
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/EmptySetException.java
2011-10-26 17:54:54 UTC (rev 27305)
+++
csplugins/trunk/toronto/rodche/cpathsquared-impl/src/main/java/org/cytoscape/cpathsquared/internal/web_service/EmptySetException.java
2011-10-26 19:19:53 UTC (rev 27306)
@@ -1,9 +0,0 @@
-package org.cytoscape.cpathsquared.internal.web_service;
-
-/**
- * Empty Set Exception.
- *
- * @author Ethan Cerami
- */
-public class EmptySetException extends Exception {
-}
--
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.