Author: kono Date: 2009-12-08 16:46:15 -0800 (Tue, 08 Dec 2009) New Revision: 18701
Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSI25VisualStyleBuilder.java csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/ui/ResultDialog.java Log: Advanced Network Merge will be called when user select Merge button. Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props =================================================================== --- csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props 2009-12-09 00:44:53 UTC (rev 18700) +++ csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/plugin.props 2009-12-09 00:46:15 UTC (rev 18701) @@ -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.04 +pluginVersion=0.05 # 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 Dept. of Medicine Trey Ideker Lab +pluginAuthorsIntsitutions=Keiichiro Ono:UCSD Department of Medicine Trey Ideker Lab Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSI25VisualStyleBuilder.java =================================================================== --- csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSI25VisualStyleBuilder.java 2009-12-09 00:44:53 UTC (rev 18700) +++ csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSI25VisualStyleBuilder.java 2009-12-09 00:46:15 UTC (rev 18701) @@ -8,8 +8,6 @@ import java.util.HashMap; import java.util.Map; -import org.cytoscape.webservice.psicquic.ontology.OLSUtil; - import cytoscape.visual.EdgeAppearanceCalculator; import cytoscape.visual.GlobalAppearanceCalculator; import cytoscape.visual.LabelPosition; @@ -19,8 +17,8 @@ import cytoscape.visual.VisualPropertyType; import cytoscape.visual.VisualStyle; import cytoscape.visual.calculators.AbstractCalculator; -import cytoscape.visual.calculators.EdgeCalculator; -import cytoscape.visual.calculators.NodeCalculator; +import cytoscape.visual.calculators.BasicCalculator; +import cytoscape.visual.calculators.Calculator; import cytoscape.visual.mappings.DiscreteMapping; import cytoscape.visual.mappings.ObjectMapping; import cytoscape.visual.mappings.PassThroughMapping; @@ -73,10 +71,11 @@ gac.setDefaultBackgroundColor(Color.white); - PassThroughMapping m = new PassThroughMapping("", AbstractCalculator.ID); + final PassThroughMapping m = new PassThroughMapping("", + AbstractCalculator.ID); - NodeCalculator calc = new NodeCalculator(DEF_VS_NAME + "-" - + "NodeLabelMapping", m, null, NODE_LABEL); + final Calculator calc = new BasicCalculator(DEF_VS_NAME + "-" + + "NodeLabelMapping", m, NODE_LABEL); // PassThroughMapping me = new PassThroughMapping("", ATTR_PREFIX + // "interaction type"); // @@ -129,20 +128,20 @@ ATTR_PREFIX + "interaction type", ObjectMapping.EDGE_MAPPING); DiscreteMapping lineWidth = new DiscreteMapping(1.0, ATTR_PREFIX + "interaction type", ObjectMapping.EDGE_MAPPING); - DiscreteMapping edgeColorMap = new DiscreteMapping(Color.black, ATTR_PREFIX - + "interaction type", ObjectMapping.EDGE_MAPPING); + DiscreteMapping edgeColorMap = new DiscreteMapping(Color.black, + ATTR_PREFIX + "interaction type", ObjectMapping.EDGE_MAPPING); generateInteractionTypeMap(lineStyle, lineWidth, edgeColorMap); - EdgeCalculator lineStyleCalc = new EdgeCalculator(DEF_VS_NAME + "-" - + "EdgeLineStyleMapping", lineStyle, null, + final Calculator lineStyleCalc = new BasicCalculator(DEF_VS_NAME + "-" + + "EdgeLineStyleMapping", lineStyle, VisualPropertyType.EDGE_LINE_STYLE); - EdgeCalculator lineWidthCalc = new EdgeCalculator(DEF_VS_NAME + "-" - + "EdgeLineWidthMapping", lineWidth, null, + final Calculator lineWidthCalc = new BasicCalculator(DEF_VS_NAME + "-" + + "EdgeLineWidthMapping", lineWidth, VisualPropertyType.EDGE_LINE_WIDTH); - - EdgeCalculator edgeColorCalc = new EdgeCalculator(DEF_VS_NAME + "-" - + "EdgeColorMapping", edgeColorMap, null, + + final Calculator edgeColorCalc = new BasicCalculator(DEF_VS_NAME + "-" + + "EdgeColorMapping", edgeColorMap, VisualPropertyType.EDGE_COLOR); // @@ -187,21 +186,21 @@ private static void generateInteractionTypeMap(DiscreteMapping lineStyle, DiscreteMapping lineWidth, DiscreteMapping edgeColor) { // TODO Auto-generated method stub -// for (String childTerm : type.keySet()) { -// if ((type.get(childTerm)).equals("MI:0208")) { -// lineStyle.putMapValue(childTerm, LineStyle.LONG_DASH); -// lineWidth.putMapValue(childTerm, 2.0); -// edgeColor.putMapValue(childTerm, Color.CYAN); -// } else if ((type.get(childTerm)).equals("MI:0403")) { -// lineStyle.putMapValue(childTerm, LineStyle.SOLID); -// lineWidth.putMapValue(childTerm, 2.0); -// edgeColor.putMapValue(childTerm, Color.green); -// } else if ((type.get(childTerm)).equals("MI:0914")) { -// lineStyle.putMapValue(childTerm, LineStyle.SOLID); -// lineWidth.putMapValue(childTerm, 3.0); -// edgeColor.putMapValue(childTerm, Color.DARK_GRAY); -// } -// } + // for (String childTerm : type.keySet()) { + // if ((type.get(childTerm)).equals("MI:0208")) { + // lineStyle.putMapValue(childTerm, LineStyle.LONG_DASH); + // lineWidth.putMapValue(childTerm, 2.0); + // edgeColor.putMapValue(childTerm, Color.CYAN); + // } else if ((type.get(childTerm)).equals("MI:0403")) { + // lineStyle.putMapValue(childTerm, LineStyle.SOLID); + // lineWidth.putMapValue(childTerm, 2.0); + // edgeColor.putMapValue(childTerm, Color.green); + // } else if ((type.get(childTerm)).equals("MI:0914")) { + // lineStyle.putMapValue(childTerm, LineStyle.SOLID); + // lineWidth.putMapValue(childTerm, 3.0); + // edgeColor.putMapValue(childTerm, Color.DARK_GRAY); + // } + // } lineStyle.putMapValue("MI:0208", LineStyle.LONG_DASH); lineWidth.putMapValue("MI:0208", 3.0); @@ -218,23 +217,23 @@ private static void buildOntologyMap() { -// try { -// System.out.println("############Ontology Test============="); -// -// // Get child terms for each interaction type category. -// for (String rootTerm : ITR_TYPE_ROOT_TERMS) { -// final Map<String, String> children = OLSUtil -// .getAllChildren(rootTerm); -// for (String childTerm : children.keySet()) { -// type.put(childTerm, rootTerm); -// System.out.println(childTerm + ", root = " + rootTerm); -// } -// } -// -// System.out.println("############Ontology Test DONE!============="); -// } catch (Exception e) { -// e.printStackTrace(); -// } + // try { + // System.out.println("############Ontology Test============="); + // + // // Get child terms for each interaction type category. + // for (String rootTerm : ITR_TYPE_ROOT_TERMS) { + // final Map<String, String> children = OLSUtil + // .getAllChildren(rootTerm); + // for (String childTerm : children.keySet()) { + // type.put(childTerm, rootTerm); + // System.out.println(childTerm + ", root = " + rootTerm); + // } + // } + // + // System.out.println("############Ontology Test DONE!============="); + // } catch (Exception e) { + // e.printStackTrace(); + // } } 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-09 00:44:53 UTC (rev 18700) +++ csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java 2009-12-09 00:46:15 UTC (rev 18701) @@ -2,6 +2,9 @@ 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; import java.util.ArrayList; import java.util.Date; @@ -31,6 +34,8 @@ import cytoscape.layout.Tunable; import cytoscape.logger.CyLogger; import cytoscape.util.ModulePropertiesImpl; +import cytoscape.view.CyNetworkView; +import cytoscape.visual.VisualMappingManager; import cytoscape.visual.VisualStyle; public class PSICQUICUniversalClient extends @@ -49,7 +54,7 @@ private enum Mode { SEARCH, IMPORT; } - + private enum QueryMode { GET_BY_INTERACTOR, GET_BY_QUERY; } @@ -57,7 +62,7 @@ private void setDescription() { description = "http://code.google.com/p/psicquic/"; } - + private QueryMode qMode = QueryMode.GET_BY_INTERACTOR; private void setProperty() { @@ -68,14 +73,14 @@ new Integer(100))); props.add(new Tunable("timeout", "Timeout (sec.)", Tunable.INTEGER, new Integer(6000))); - props.add(new Tunable("active_only", "Active Services Only", Tunable.BOOLEAN, - new Boolean(true))); - - final String[] modeArray = {QueryMode.GET_BY_INTERACTOR.name(), QueryMode.GET_BY_QUERY.toString()}; - props.add(new Tunable("query_mode", "Query Mode", - Tunable.LIST, new Integer(0), - (Object) modeArray, (Object) null, 0)); + props.add(new Tunable("active_only", "Active Services Only", + Tunable.BOOLEAN, new Boolean(true))); + final String[] modeArray = { QueryMode.GET_BY_INTERACTOR.name(), + QueryMode.GET_BY_QUERY.toString() }; + props.add(new Tunable("query_mode", "Query Mode", Tunable.LIST, + new Integer(0), (Object) modeArray, (Object) null, 0)); + } // private static final Icon ABOUT_ICON = new ImageIcon( @@ -97,12 +102,13 @@ private Map<URI, QueryResponse> sResult; private List<DbRef> queryList; private String query; - + static { - try { + try { client = new PSICQUICUniversalClient(); } catch (Exception e) { - CyLogger.getLogger().error("Could not initialize PSICQUIC Client.", e); + CyLogger.getLogger().error("Could not initialize PSICQUIC Client.", + e); } } @@ -139,32 +145,29 @@ } - - private void search(String queryString, CyWebServiceEvent<?> e) throws CyWebServiceException { final PSICQUICServiceRegistory searchClient = ((PSICQUICServiceRegistory) clientStub); sResult = null; int blockSize = 100; - try{ + try { blockSize = Integer.parseInt(props.getValue("block_size")); - } catch( Exception exp ) { + } catch (Exception exp) { blockSize = 100; } - + this.query = queryString; final RequestInfo info = new RequestInfo(); 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()); - - - if(mode.getValue().equals(QueryMode.GET_BY_INTERACTOR.ordinal())) { + + if (mode.getValue().equals(QueryMode.GET_BY_INTERACTOR.ordinal())) { System.out.println("QueryMode ====> " + mode.getValue()); queryList = buildInteractorList(query); sResult = searchClient.getCount(queryList, info, "OR"); @@ -172,8 +175,7 @@ // Get by Query (MIQL) sResult = searchClient.getCount(query, info); } - - + } catch (Exception ex) { ex.printStackTrace(); throw new CyWebServiceException( @@ -196,10 +198,10 @@ sResult, nextMove)); } - + private void importNetwork(Object result, CyNetwork e) throws CyWebServiceException { - + PSICQUICServiceRegistory importClient = ((PSICQUICServiceRegistory) clientStub); Map<URI, List<QueryResponse>> importResult = null; final RequestInfo info = new RequestInfo(); @@ -207,9 +209,10 @@ info.setResultType(PSICQUICReturnType.MITAB25.getTypeName()); info.setBlockSize(100); try { - if(queryList != null) { + if (queryList != null) { System.out.println("========Get by List"); - importResult = importClient.getByInteractorList(queryList, info, "OR"); + importResult = importClient.getByInteractorList(queryList, + info, "OR"); } else { System.out.println("========Get by Query"); importResult = importClient.getByQuery(query, info); @@ -222,67 +225,115 @@ if (importResult == null) return; - + // Ask user to display names final List<String> defNetworkNames = new ArrayList<String>(); final Date time = new Date(System.currentTimeMillis()); final Map<URI, String> nameMap = importClient.getServiceNames(); Map<URI, String> newNameMap = new HashMap<URI, String>(); String netName = null; - for(URI name: importResult.keySet()) { + for (URI name : importResult.keySet()) { netName = nameMap.get(name); defNetworkNames.add(netName); newNameMap.put(name, netName); } - - ResultDialog report = new ResultDialog(Cytoscape.getDesktop(), true, newNameMap); + + final ResultDialog report = new ResultDialog(Cytoscape.getDesktop(), + true, newNameMap); report.setLocationRelativeTo(Cytoscape.getDesktop()); report.setVisible(true); newNameMap = report.getNewNames(); - + final Mitab25Mapper mapper = new Mitab25Mapper(); List<CyNetwork> target = new ArrayList<CyNetwork>(); - + // Create parent empty network - final String parentName; - if(query != null) { - parentName = "PSICQUIC Query Result: " + time.toString() + " (" + query +")"; - } else { - parentName = "PSICQUIC Query Result: " + time.toString(); - } - final CyNetwork parentNetwork = Cytoscape.createNetwork(parentName, false); - + String parentName = "PSICQUIC Query Results: " + time.toString(); + if (query != null) + parentName = "PSICQUIC Query Results: " + time.toString() + " (" + + query + ")"; + + final CyNetwork parentNetwork = Cytoscape.createNetwork(parentName, + false); + 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) { + for (QueryResponse qr : res) { builder.append(qr.getResultSet().getMitab()); } - final CyNetwork net = mapper.map(builder.toString(), newNameMap.get(key), parentNetwork); - if(net != null) + final CyNetwork net = mapper.map(builder.toString(), newNameMap + .get(key), parentNetwork); + if (net != null) target.add(net); } - if (Cytoscape.getVisualMappingManager().getCalculatorCatalog() - .getVisualStyle(PSI25VisualStyleBuilder.getDefVS().getName()) == null) - Cytoscape.getVisualMappingManager().getCalculatorCatalog() - .addVisualStyle(PSI25VisualStyleBuilder.getDefVS()); - - for(CyNetwork net: target) { - Cytoscape.getVisualMappingManager().setVisualStyle( - PSI25VisualStyleBuilder.getDefVS()); - Cytoscape.getNetworkView(net.getIdentifier()).setVisualStyle(PSI25VisualStyleBuilder.getDefVS().getName()); - Cytoscape.getNetworkView(net.getIdentifier()).redrawGraph(true, false); + final VisualMappingManager vmm = Cytoscape.getVisualMappingManager(); + final VisualStyle defaultVS = PSI25VisualStyleBuilder.getDefVS(); + if (vmm.getCalculatorCatalog().getVisualStyle(defaultVS.getName()) == null) + vmm.getCalculatorCatalog().addVisualStyle(defaultVS); + + for (CyNetwork net : target) { + vmm.setVisualStyle(defaultVS); + final CyNetworkView targetView = Cytoscape.getNetworkView(net + .getIdentifier()); + targetView.setVisualStyle(defaultVS.getName()); + targetView.redrawGraph(true, false); } - + query = null; queryList = null; + + // Call Advanced Network Merge + if (report.isMerge()) + displayNetworkMerge(); } + /** + * Use reflection to display the AdvancedNetworkMerge plugin. + */ + private void displayNetworkMerge() { + Class<?> advancedNetworkMergeClass; + try { + advancedNetworkMergeClass = Class + .forName("csplugins.network.merge.NetworkMergePlugin"); + } catch (ClassNotFoundException e1) { + CyLogger.getLogger().warn( + "Could not find Advanced Network Merge Plugin!", e1); + e1.printStackTrace(); + return; + } + + Method actionPerformedMethod; + try { + actionPerformedMethod = advancedNetworkMergeClass + .getMethod("invokeAction"); + } catch (SecurityException e2) { + e2.printStackTrace(); + return; + } catch (NoSuchMethodException e2) { + e2.printStackTrace(); + return; + } + + try { + actionPerformedMethod.invoke(null); + } catch (IllegalArgumentException e3) { + e3.printStackTrace(); + return; + } catch (IllegalAccessException e3) { + e3.printStackTrace(); + return; + } catch (InvocationTargetException e3) { + e3.getCause().printStackTrace(); + return; + } + } + // Build interactor list private List<DbRef> buildInteractorList(String query) { List<DbRef> interactorList = new ArrayList<DbRef>(); Modified: csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/ui/ResultDialog.java =================================================================== --- csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/ui/ResultDialog.java 2009-12-09 00:44:53 UTC (rev 18700) +++ csplugins/trunk/ucsd/kono/PSIQUICUniversalClient/src/org/cytoscape/webservice/psicquic/ui/ResultDialog.java 2009-12-09 00:46:15 UTC (rev 18701) @@ -2,34 +2,21 @@ import java.awt.Frame; import java.net.URI; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import java.util.Vector; import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; -import javax.xml.namespace.QName; -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -/* - * PSICQUICResultDialog.java - * - * Created on 2009/01/28, 14:38:03 - */ - /** - * + * Display result of the query. * @author kono */ public class ResultDialog extends javax.swing.JDialog { + private static final long serialVersionUID = 6996385373168492882L; private Map<URI, String> dbNames; private DefaultTableModel model; + + private boolean mergeNetworks; /** Creates new form PSICQUICResultDialog */ public ResultDialog(Frame parent, boolean modal, Map<URI, String> dbNames) { @@ -37,6 +24,7 @@ this.dbNames = dbNames; setTableModel(); initComponents(); + mergeNetworks = false; } private void setTableModel() { @@ -77,7 +65,8 @@ buttonPanel = new javax.swing.JPanel(); okButton = new javax.swing.JButton(); - cancelButton = new javax.swing.JButton(); + mergeButton = new javax.swing.JButton(); + mergeButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); @@ -116,11 +105,11 @@ } }); - cancelButton.setText("Cancel"); - cancelButton.setPreferredSize(new java.awt.Dimension(70, 26)); - cancelButton.addActionListener(new java.awt.event.ActionListener() { + mergeButton.setText("Merge"); + mergeButton.setPreferredSize(new java.awt.Dimension(70, 26)); + mergeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - cancelButtonActionPerformed(evt); + mergeButtonActionPerformed(evt); } }); @@ -137,7 +126,7 @@ .createSequentialGroup() .addContainerGap(491, Short.MAX_VALUE) .add( - cancelButton, + mergeButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) @@ -170,7 +159,7 @@ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add( - cancelButton, + mergeButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) @@ -219,13 +208,17 @@ }// </editor-fold> private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: this.dispose(); } - private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { + private void mergeButtonActionPerformed(java.awt.event.ActionEvent evt) { + mergeNetworks = true; this.dispose(); } + + public boolean isMerge() { + return mergeNetworks; + } public Map<URI, String> getNewNames() { @@ -237,7 +230,7 @@ // Variables declaration - do not modify private javax.swing.JPanel buttonPanel; - private javax.swing.JButton cancelButton; + private javax.swing.JButton mergeButton; private javax.swing.JButton okButton; private javax.swing.JScrollPane resultScrollPane; private javax.swing.JTable resultTable; -- 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.
