Merge branch 'Release_2_8_2_Branch' of https://source.jalview.org/git/jalview.git...
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 27 Nov 2014 11:53:50 +0000 (11:53 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 27 Nov 2014 11:53:50 +0000 (11:53 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/ws/jws2/MsaWSClient.java

index 07c4a54..2a804ad 100644 (file)
@@ -4184,6 +4184,21 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
        */
       msa = viewport.getAlignmentView(true);
     }
+    else if (viewport.getSelectionGroup() != null
+            && viewport.getSelectionGroup().getSize() == 1)
+    {
+      int option = JOptionPane
+              .showConfirmDialog(
+this,
+                      "More than one sequece group selection is required for this Job, click \n'Cancel' to edit your selection or 'Ok' to submit the entire sequence.",
+                      "Invalid selection",
+                      JOptionPane.OK_CANCEL_OPTION);
+      if (option == JOptionPane.OK_OPTION)
+      {
+        msa = viewport.getAlignmentView(false);
+      }
+
+    }
     else
     {
       /*
index 09a6d8d..39be454 100644 (file)
@@ -22,6 +22,7 @@ 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;
@@ -127,8 +128,10 @@ public class MsaWSClient extends Jws2Client
 
       return;
     }
+
     startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
 
+
   }
 
   public MsaWSClient()
@@ -173,9 +176,55 @@ public class MsaWSClient extends Jws2Client
             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)
+    {
+      JOptionPane
+              .showMessageDialog(
+                      alignFrame,
+                      "A minimum of two sequences is required to perform this operation",
+                      "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
+
+      return false;
+    }
+
+    for (SequenceI seq : seqs)
+    {
+
+      if (seq.getSequenceAsString().matches("(-*[a-zA-Z]-*){3}[a-zA-Z-]*"))
+      {
+        ++validSeqCount;
+      }
+      if (validSeqCount > 1)
+      {
+        return true;
+      }
+    }
+
+    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)
+  {
+    System.out.println("A".matches("(-*[a-zA-Z]-*){1}[a-zA-Z-]*"));
+  }
+
+
+
   protected String getServiceActionKey()
   {
     return "MsaWS";
@@ -250,9 +299,13 @@ public class MsaWSClient extends Jws2Client
         public void actionPerformed(ActionEvent e)
         {
           AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+
+          if (msa != null && isValidAlignment(msa))
+          {
           new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
                   true, alignFrame.getViewport().getAlignment()
                           .getDataset(), alignFrame);
+          }
 
         }
       });
@@ -271,9 +324,13 @@ public class MsaWSClient extends Jws2Client
           public void actionPerformed(ActionEvent e)
           {
             AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+
+            if (msa != null && isValidAlignment(msa))
+            {
             new MsaWSClient(service, null, null, true, alignFrame
                     .getTitle(), msa, withGaps, true, alignFrame
                     .getViewport().getAlignment().getDataset(), alignFrame);
+            }
 
           }
         });
@@ -324,9 +381,13 @@ public class MsaWSClient extends Jws2Client
               {
                 AlignmentView msa = alignFrame
                         .gatherSequencesForAlignment();
+
+                if (msa != null && isValidAlignment(msa))
+                {
                 new MsaWSClient(service, preset, alignFrame.getTitle(),
                         msa, false, true, alignFrame.getViewport()
                                 .getAlignment().getDataset(), alignFrame);
+                }
 
               }