From b2c4d6c467255b5e30caf4cac1be372b89db0eea Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 4 Nov 2011 16:58:24 +0000 Subject: [PATCH] (JAL-975) ensure AACons is only run on protein sequences. (note - should really fix JAL-536 here) --- src/jalview/ws/jws2/AAConsClient.java | 2 +- .../ws/jws2/SequenceAnnotationWSClient.java | 63 +++++++++++++------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/jalview/ws/jws2/AAConsClient.java b/src/jalview/ws/jws2/AAConsClient.java index 7aaa2fe..054c9ab 100644 --- a/src/jalview/ws/jws2/AAConsClient.java +++ b/src/jalview/ws/jws2/AAConsClient.java @@ -135,7 +135,7 @@ public class AAConsClient extends AlignCalcWorker int aWidth = -1; - if (alignment == null || (aWidth = alignment.getWidth()) < 0) + if (alignment == null || (aWidth = alignment.getWidth()) < 0 || alignment.isNucleotide()) { calcMan.workerComplete(this); return; diff --git a/src/jalview/ws/jws2/SequenceAnnotationWSClient.java b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java index 3e4cbe1..fea8f2a 100644 --- a/src/jalview/ws/jws2/SequenceAnnotationWSClient.java +++ b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java @@ -9,12 +9,15 @@ import java.util.List; import javax.swing.JMenu; import javax.swing.JMenuItem; +import javax.swing.JOptionPane; import compbio.metadata.Argument; import jalview.api.AlignCalcWorkerI; import jalview.datamodel.AlignmentView; import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.JalviewDialog; import jalview.gui.JvSwingUtils; import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.params.WsParamSetI; @@ -38,37 +41,54 @@ public class SequenceAnnotationWSClient extends Jws2Client AlignFrame alignFrame, WsParamSetI preset, boolean editParams) { super(alignFrame, preset, null); - List clnts = alignFrame.getViewport() - .getCalcManager() - .getRegisteredWorkersOfClass(AAConsClient.class); - if (clnts == null || clnts.size() == 0) + if (sh.serviceType.toLowerCase().contains("aaconws")) { - if (!processParams(sh, editParams)) + // Build an AACons client + if (alignFrame.getViewport().getAlignment().isNucleotide()) { + JOptionPane + .showMessageDialog( + Desktop.desktop, + "AACons can only be used\nfor amino acid alignments.\nSorry about that!", + "Wrong type of sequences!", + JOptionPane.WARNING_MESSAGE); return; + } - alignFrame - .getViewport() + List clnts = alignFrame.getViewport() .getCalcManager() - .registerWorker( - new AAConsClient(sh, alignFrame, preset, paramset)); - } - else - { - AAConsClient worker = (AAConsClient) clnts.get(0); - if (editParams) + .getRegisteredWorkersOfClass(AAConsClient.class); + if (clnts == null || clnts.size() == 0) { - paramset = worker.getArguments(); - preset = worker.getPreset(); + if (!processParams(sh, editParams)) + { + return; + } + alignFrame + .getViewport() + .getCalcManager() + .registerWorker( + new AAConsClient(sh, alignFrame, preset, paramset)); } + else + { + AAConsClient worker = (AAConsClient) clnts.get(0); + if (editParams) + { + paramset = worker.getArguments(); + preset = worker.getPreset(); + } - if (!processParams(sh, editParams, true)) - return; - // reinstate worker if it was blacklisted (might have happened due to invalid parameters) - alignFrame.getViewport().getCalcManager().workerMayRun(worker); - worker.updateParameters(preset, paramset); + if (!processParams(sh, editParams, true)) + return; + // reinstate worker if it was blacklisted (might have happened due to + // invalid parameters) + alignFrame.getViewport().getCalcManager().workerMayRun(worker); + worker.updateParameters(preset, paramset); + } } + } /* @@ -84,7 +104,6 @@ public class SequenceAnnotationWSClient extends Jws2Client { boolean hasparams = service.hasParameters(); String calcName = "AACons"; - System.out.println("Making an aacons client!"); JMenuItem aacons = new JMenuItem("AACons Defaults"); aacons.addActionListener(new ActionListener() { -- 1.7.10.2