merge commit
authorCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 19 Nov 2014 12:20:50 +0000 (12:20 +0000)
committerCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 19 Nov 2014 12:20:50 +0000 (12:20 +0000)
src/jalview/ws/jws2/MsaWSClient.java

index 09a6d8d..76a1c56 100644 (file)
@@ -21,7 +21,9 @@
 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;
@@ -173,9 +175,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<SequenceI> 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";