Author: kono Date: 2009-12-15 12:36:02 -0800 (Tue, 15 Dec 2009) New Revision: 18768
Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICServiceRegistory.java csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java Log: Removed duplicate code and fixed some bugs. Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props =================================================================== --- csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props 2009-12-15 20:35:34 UTC (rev 18767) +++ csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props 2009-12-15 20:36:02 UTC (rev 18768) @@ -11,7 +11,7 @@ pluginDescription=PSICQUIC Web Service Universal Client. You can perform meta-search for <a href="http://code.google.com/p/psicquic/">PSICQUIC data service providers</a>. This plugin works with Cytoscape 2.7.0 (not released yet) or later. # Plugin version number, this must be two numbers separated by a decimlal. Ex. 0.2, 14.03 -pluginVersion=0.05 +pluginVersion=0.06 # Compatible Cytoscape version cytoscapeVersion=2.7 @@ -21,4 +21,4 @@ # List of authors. Note each author and institution pair are separated by a : (colon) # each additional author institution pair must be separated from other pairs bye a ; (semicolon) -pluginAuthorsIntsitutions=Keiichiro Ono:UCSD Department of Medicine Trey Ideker Lab +pluginAuthorsIntsitutions=Keiichiro Ono:UC San Diego Department of Medicine Trey Ideker Lab Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICServiceRegistory.java =================================================================== --- csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICServiceRegistory.java 2009-12-15 20:35:34 UTC (rev 18767) +++ csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICServiceRegistory.java 2009-12-15 20:36:02 UTC (rev 18768) @@ -5,7 +5,6 @@ import java.net.URI; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -93,63 +92,20 @@ */ public Map<URI, QueryResponse> getCount(List<DbRef> interactors, RequestInfo reqInfo, String operator) throws CyWebServiceException { - final Map<URI, QueryResponse> result = new ConcurrentHashMap<URI, QueryResponse>(); - System.out.println("===== Search Start ===="); - final ExecutorService exe = Executors.newCachedThreadPool(); - final long startTime = System.currentTimeMillis(); - - final CompletionService<List<Object>> cs = new ExecutorCompletionService<List<Object>>( - exe); - - Future<List<Object>> res = null; - - // Submit tasks - Object port; - for (URI key : services.keySet()) { - port = services.get(key); - cs.submit(new PSICQUICRemoteTask(interactors, reqInfo, operator, - port, key, OperationType.GET_COUNT)); - System.out.println("Submit search query to " + key); - } - - try { - for (int i = 0; i < services.size(); i++) { - res = cs.take(); - URI name = (URI) res.get().get(0); - QueryResponse qr = (QueryResponse) res.get().get(1); - if (qr != null) { - result.put(name, qr); - System.out.println("End: " + name + " ---> " - + qr.getResultInfo().getTotalResults()); - } - } - - long endTime = System.currentTimeMillis(); - double sec = (endTime - startTime) / (1000.0); - System.out.println("PSICQUIC DB search finished in " + sec - + " msec."); - } catch (Exception ee) { - ee.printStackTrace(); - CyLogger.getLogger().fatal( - "Could not complete PSICQUIC search task.", ee); - throw new CyWebServiceException( - CyWebServiceException.WSErrorCode.REMOTE_EXEC_FAILED); - - } finally { - // res.cancel(true); - exe.shutdown(); - } - - return result; + return submitTask(null, interactors, reqInfo, operator); } public Map<URI, QueryResponse> getCount(String query, RequestInfo reqInfo) throws CyWebServiceException { - final Map<URI, QueryResponse> result = new ConcurrentHashMap<URI, QueryResponse>(); + return submitTask(query, null, reqInfo, null); + } - System.out.println("===== Search Start ===="); + private Map<URI, QueryResponse> submitTask(String query, + List<DbRef> interactors, RequestInfo reqInfo, String operator) + throws CyWebServiceException { + final Map<URI, QueryResponse> result = new ConcurrentHashMap<URI, QueryResponse>(); final ExecutorService exe = Executors.newCachedThreadPool(); final long startTime = System.currentTimeMillis(); @@ -162,11 +118,17 @@ Object port; for (URI key : services.keySet()) { port = services.get(key); - cs.submit(new PSICQUICRemoteTask(query, reqInfo, port, key, - OperationType.GET_COUNT)); + if (query != null) { + cs.submit(new PSICQUICRemoteTask(query, reqInfo, port, key, + OperationType.GET_COUNT)); + } else { + cs.submit(new PSICQUICRemoteTask(interactors, reqInfo, + operator, port, key, OperationType.GET_COUNT)); + } System.out.println("Submit search query to " + key); } + emptyResults.clear(); try { for (int i = 0; i < services.size(); i++) { res = cs.take(); @@ -174,7 +136,8 @@ QueryResponse qr = (QueryResponse) res.get().get(1); if (qr != null) { result.put(name, qr); - System.out.println("End: " + name + " ---> " + System.out.println(name.toASCIIString() + + ": Interactions Found = " + qr.getResultInfo().getTotalResults()); if (qr.getResultInfo().getTotalResults() == 0) { emptyResults.add(name); @@ -194,18 +157,16 @@ CyWebServiceException.WSErrorCode.REMOTE_EXEC_FAILED); } finally { - // res.cancel(true); exe.shutdown(); } return result; - } public Map<URI, List<QueryResponse>> getByInteractorList( List<DbRef> interactors, RequestInfo reqInfo, String operator) throws CyWebServiceException { - + return doImport(null, interactors, reqInfo, operator); } @@ -257,7 +218,14 @@ final List<QueryResponse> qrList = new ArrayList<QueryResponse>(); for (int j = 1; j < res.get().size(); j++) { - qrList.add((QueryResponse) res.get().get(j)); + // Add only non-empty results. + final QueryResponse response = (QueryResponse) res.get() + .get(j); + // System.out.println(response.getResultSet().getMitab() + + // "\n\n"); + final String mitab = response.getResultSet().getMitab(); + if (mitab != null && mitab.length() != 0) + qrList.add(response); } result.put(name, qrList); System.out.println("End: " + name); @@ -279,11 +247,16 @@ exe.shutdown(); } - emptyResults.clear(); - return result; } + protected boolean isEmpty(final URI serviceURI) { + if (this.emptyResults.contains(serviceURI)) + return true; + else + return false; + } + class PSICQUICRemoteTask implements Callable<List<Object>>, CyWebServiceEventListener { Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java =================================================================== --- csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java 2009-12-15 20:35:34 UTC (rev 18767) +++ csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java 2009-12-15 20:36:02 UTC (rev 18768) @@ -2,7 +2,6 @@ import static cytoscape.data.webservice.CyWebServiceEvent.WSResponseType.SEARCH_FINISHED; -import java.awt.event.ActionEvent; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URI; @@ -162,8 +161,6 @@ info.setResultType(PSICQUICReturnType.COUNT.getTypeName()); info.setBlockSize(blockSize); try { - System.out.println("** Submit Search Query: " + query); - Tunable mode = props.get("query_mode"); System.out.println("QueryMode ====> " + mode.getValue()); @@ -210,11 +207,10 @@ info.setBlockSize(100); try { if (queryList != null) { - System.out.println("========Get by List"); + // Use OR as operand importResult = importClient.getByInteractorList(queryList, info, "OR"); } else { - System.out.println("========Get by Query"); importResult = importClient.getByQuery(query, info); } } catch (Exception ex) { @@ -233,15 +229,20 @@ Map<URI, String> newNameMap = new HashMap<URI, String>(); String netName = null; for (URI name : importResult.keySet()) { + if (importClient.isEmpty(name)) + continue; + else { netName = nameMap.get(name); defNetworkNames.add(netName); newNameMap.put(name, netName); + } } final ResultDialog report = new ResultDialog(Cytoscape.getDesktop(), true, newNameMap); report.setLocationRelativeTo(Cytoscape.getDesktop()); report.setVisible(true); + report.setModal(true); newNameMap = report.getNewNames(); @@ -259,9 +260,6 @@ for (URI key : importResult.keySet()) { - System.out.println("========Import Finished2!!!!!!!!!!!!!!!!!!!\n" - + importResult.get(key).size()); - StringBuilder builder = new StringBuilder(); List<QueryResponse> res = importResult.get(key); for (QueryResponse qr : res) { -- 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.
