From 035fe333749af8d09b517287b4b83c81d5f25fc7 Mon Sep 17 00:00:00 2001 From: Charles Ofoegbu Date: Tue, 18 Nov 2014 14:39:51 +0000 Subject: [PATCH] JAL-1583 MSA webservice client side validation --- src/jalview/ws/jws2/MsaWSClient.java | 68 +++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 9ddc69a..ebd826e 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -20,19 +20,27 @@ */ package jalview.ws.jws2; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.AlignmentView; +import jalview.datamodel.SequenceI; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.JvSwingUtils; +import jalview.util.MessageManager; +import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.WsParamSetI; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; -import javax.swing.*; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; -import jalview.datamodel.*; -import jalview.gui.*; import compbio.data.msa.MsaWS; import compbio.metadata.Argument; -import jalview.util.MessageManager; -import jalview.ws.jws2.jabaws2.Jws2Instance; -import jalview.ws.params.WsParamSetI; /** * DOCUMENT ME! @@ -161,9 +169,57 @@ public class MsaWSClient extends Jws2Client WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa, submitGaps, preserveOrder, seqdataset); wsInfo.setthisService(msathread); + if (isValidAlignment(alignFrame.getCurrentView().getAlignment())) + { + msathread.start(); + } } + private boolean isValidAlignment(AlignmentI seqdataset) + { + String header = wsInfo.getInfoText() + + "\nValidating submited Alignment..."; + wsInfo.setInfoText(header); + int validSeqCount = 0; + List seqs = seqdataset.getSequences(); + if (seqs.size() < 2) + { + wsInfo.setInfoText(header + + "\nA minimum of two sequences is required to perform this operation"); + return false; + } + + for (SequenceI seq : seqs) + { + + if (seq.getSequenceAsString().matches( + "([(a-zA-Z?)(-?)(.?)]+)?[a-zA-Z]([(a-zA-Z?)(-?)(.?)]+)?")) + { + ++validSeqCount; + } + if (validSeqCount > 1) + { + wsInfo.setInfoText(header + + "\nAlignment sequences was successfully validated"); + return true; + } + } + + wsInfo.setInfoText(header + + "\nA minimum of two sequences with at least one non-gap character in each sequence is required to perform this operation"); + return false; + } + + public static void main(String[] args) + { + System.out + .println("A" + .matches("([(a-zA-Z?)(-?)(.?)]+)?[a-zA-Z]([(a-zA-Z?)(-?)(.?)]+)?")); + } + + + protected String getServiceActionKey() { return "MsaWS"; -- 1.7.10.2