JAL-1583 back out original fix and simply check MSAWSThread.hasValidInput flag before...
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 28 Nov 2014 14:04:16 +0000 (14:04 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 28 Nov 2014 14:04:16 +0000 (14:04 +0000)
resources/lang/Messages.properties
src/jalview/ws/jws2/MsaWSClient.java

index 795dfa0..9207ff8 100644 (file)
@@ -1104,6 +1104,8 @@ info.invalid_jnet_job_result_data ={0}\n{1}\nInvalid JNet job result data\!\n{2}
 info.failed_to_submit_sequences_for_alignment = Failed to submit sequences for alignment.\nIt is most likely that there is a problem with the server.\nJust close the window\n
 info.alignment_object_method_notes = \nAlignment Object Method Notes\n
 info.server_exception = \n{0} Server exception\!\n{1}
+info.invalid_msa_input_mininfo = Need at least two sequences with at least 3 residues each, with no hidden regions between them.  
+info.invalid_msa_notenough = Not enough sequence data to align
 status.processing_commandline_args = Processing commandline arguments...
 status.das_features_being_retrived = DAS features being retrieved...
 status.searching_for_sequences_from = Searching for sequences from {0}
index 39be454..e7301a6 100644 (file)
@@ -22,7 +22,6 @@ package jalview.ws.jws2;
 
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentView;
-import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.gui.Desktop;
 import jalview.gui.JvSwingUtils;
@@ -175,47 +174,20 @@ public class MsaWSClient extends Jws2Client
     MsaWSThread msathread = new MsaWSThread(server, preset, paramset,
             WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
             submitGaps, preserveOrder, seqdataset);
-    wsInfo.setthisService(msathread);
-
-    msathread.start();
-
-  }
-
-  private boolean isValidAlignment(AlignmentView av)
-  {
-    int validSeqCount = 0;
-    List<SequenceI> seqs = av.getVisibleAlignment('c').getSequences(); // .getSequences();
-    if (seqs.size() < 2)
+    if (msathread.hasValidInput())
     {
-      JOptionPane
-              .showMessageDialog(
-                      alignFrame,
-                      "A minimum of two sequences is required to perform this operation",
-                      "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
-
-      return false;
+      wsInfo.setthisService(msathread);
+      wsInfo.setVisible(true);
+      msathread.start();
     }
-
-    for (SequenceI seq : seqs)
+    else
     {
-
-      if (seq.getSequenceAsString().matches("(-*[a-zA-Z]-*){3}[a-zA-Z-]*"))
-      {
-        ++validSeqCount;
-      }
-      if (validSeqCount > 1)
-      {
-        return true;
-      }
+      JOptionPane.showMessageDialog(alignFrame,
+              MessageManager.getString("info.invalid_msa_input_mininfo"),
+              MessageManager.getString("info.invalid_msa_notenough"),
+              JOptionPane.INFORMATION_MESSAGE);
+      wsInfo.setVisible(false);
     }
-
-    JOptionPane
-            .showMessageDialog(
-                    alignFrame,
-                    "All selected sequence for this job must have a  minimum of \nthree non-gap character to perform this operation",
-                    "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
-
-    return false;
   }
 
   public static void main(String[] args)
@@ -300,7 +272,7 @@ public class MsaWSClient extends Jws2Client
         {
           AlignmentView msa = alignFrame.gatherSequencesForAlignment();
 
-          if (msa != null && isValidAlignment(msa))
+          if (msa != null)
           {
           new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
                   true, alignFrame.getViewport().getAlignment()
@@ -324,10 +296,9 @@ public class MsaWSClient extends Jws2Client
           public void actionPerformed(ActionEvent e)
           {
             AlignmentView msa = alignFrame.gatherSequencesForAlignment();
-
-            if (msa != null && isValidAlignment(msa))
+            if (msa != null)
             {
-            new MsaWSClient(service, null, null, true, alignFrame
+              new MsaWSClient(service, null, null, true, alignFrame
                     .getTitle(), msa, withGaps, true, alignFrame
                     .getViewport().getAlignment().getDataset(), alignFrame);
             }
@@ -382,9 +353,10 @@ public class MsaWSClient extends Jws2Client
                 AlignmentView msa = alignFrame
                         .gatherSequencesForAlignment();
 
-                if (msa != null && isValidAlignment(msa))
+                if (msa != null)
                 {
-                new MsaWSClient(service, preset, alignFrame.getTitle(),
+                  MsaWSClient msac = new MsaWSClient(service, preset,
+                          alignFrame.getTitle(),
                         msa, false, true, alignFrame.getViewport()
                                 .getAlignment().getDataset(), alignFrame);
                 }