JAL-1583 MSA webservice validation
authorCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 19 Nov 2014 16:53:36 +0000 (16:53 +0000)
committerCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 19 Nov 2014 16:53:36 +0000 (16:53 +0000)
src/jalview/ws/jws2/MsaWSClient.java

index 76a1c56..d9452a3 100644 (file)
@@ -21,7 +21,6 @@
 package jalview.ws.jws2;
 
 import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
@@ -129,8 +128,10 @@ public class MsaWSClient extends Jws2Client
 
       return;
     }
+
     startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
 
+
   }
 
   public MsaWSClient()
@@ -175,24 +176,23 @@ 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)
+  private boolean isValidAlignment(AlignmentView av)
   {
-    String header = wsInfo.getInfoText()
-            + "\nValidating submited Alignment...";
-    wsInfo.setInfoText(header);
     int validSeqCount = 0;
-    List<SequenceI> seqs = seqdataset.getSequences();
+    List<SequenceI> seqs = av.getVisibleAlignment('c').getSequences(); // .getSequences();
     if (seqs.size() < 2)
     {
-      wsInfo.setInfoText(header
-              + "\nA minimum of two sequences is required to perform this operation");
+      JOptionPane
+              .showMessageDialog(
+                      alignFrame,
+                      "A minimum of two sequences is required to perform this operation",
+                      "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
+
       return false;
     }
 
@@ -206,14 +206,16 @@ public class MsaWSClient extends Jws2Client
       }
       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");
+    JOptionPane
+            .showMessageDialog(
+                    alignFrame,
+                    "A minimum of two sequences with at least one non-gap character \nin each sequence is required to perform this operation",
+                    "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
+
     return false;
   }
 
@@ -300,9 +302,13 @@ public class MsaWSClient extends Jws2Client
         public void actionPerformed(ActionEvent e)
         {
           AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+
+          if (isValidAlignment(msa))
+          {
           new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
                   true, alignFrame.getViewport().getAlignment()
                           .getDataset(), alignFrame);
+          }
 
         }
       });
@@ -321,9 +327,13 @@ public class MsaWSClient extends Jws2Client
           public void actionPerformed(ActionEvent e)
           {
             AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+
+            if (isValidAlignment(msa))
+            {
             new MsaWSClient(service, null, null, true, alignFrame
                     .getTitle(), msa, withGaps, true, alignFrame
                     .getViewport().getAlignment().getDataset(), alignFrame);
+            }
 
           }
         });
@@ -374,9 +384,13 @@ public class MsaWSClient extends Jws2Client
               {
                 AlignmentView msa = alignFrame
                         .gatherSequencesForAlignment();
+
+                if (isValidAlignment(msa))
+                {
                 new MsaWSClient(service, preset, alignFrame.getTitle(),
                         msa, false, true, alignFrame.getViewport()
                                 .getAlignment().getDataset(), alignFrame);
+                }
 
               }