JAL-2629 fix incorrect hmmbuild on groups behaviour
authortva <tva@10.205.251.175>
Wed, 10 Jul 2019 13:41:40 +0000 (14:41 +0100)
committertva <tva@10.205.251.175>
Wed, 10 Jul 2019 13:41:40 +0000 (14:41 +0100)
src/jalview/gui/AlignFrame.java
src/jalview/hmmer/HMMBuild.java

index 18000bd..a429ece 100644 (file)
@@ -1198,13 +1198,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public boolean alignmentIsSufficient(int required)
   {
-    if (getViewport().getAlignment().getSequences().size() < required)
-    {
-      JOptionPane.showMessageDialog(this,
-              MessageManager.getString("label.not_enough_sequences"));
-      return false;
-    }
-    return true;
+      if (getViewport().getSequenceSelection().length < required)
+      {
+        JOptionPane.showMessageDialog(this,
+                MessageManager.getString("label.not_enough_sequences"));
+        return false;
+      }
+      return true;
   }
 
   /**
index 7c14858..0c47c1d 100644 (file)
@@ -4,7 +4,6 @@ import jalview.api.AlignViewportI;
 import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
-import jalview.datamodel.AlignmentView;
 import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.ResidueCount;
 import jalview.datamodel.SequenceGroup;
@@ -116,20 +115,18 @@ public class HMMBuild extends HmmerCommand
         else if (MessageManager.getString("label.groups_and_alignment")
                 .equals(value))
         {
-          AlignmentView av = viewport.getAlignmentView(true);
-          runBuildFor.add(av.getVisibleAlignment('-'));
-          runBuildFor.addAll(av.getVisibleGroups('-'));
+          runBuildFor.add(viewport.getAlignmentView(false)
+                  .getVisibleAlignment('-'));
+          runBuildFor.addAll(viewport.getAlignment().getGroups());
         }
         else if (MessageManager.getString("label.groups").equals(value))
         {
-          AlignmentView av = viewport.getAlignmentView(false);
-          runBuildFor.addAll(av.getVisibleGroups('-'));
+          runBuildFor.addAll(viewport.getAlignment().getGroups());
         }
         else if (MessageManager.getString("label.selected_group")
                 .equals(value))
         {
-          AlignmentView av = viewport.getAlignmentView(true);
-          runBuildFor.add(av.getVisibleAlignment('-'));
+          runBuildFor.add(viewport.getSelectionGroup());
         }
       }
       else if (MessageManager.getString("label.use_reference")
@@ -193,7 +190,10 @@ public class HMMBuild extends HmmerCommand
                                                .getSelectionAsNewSequences((AlignmentI) ac.getContext());
         for (SequenceI seq : sel)
         {
-          copy.add(seq);
+          if (seq != null)
+          {
+            copy.add(seq);
+          }
         }
       }
       // TODO rather than copy alignment data we should anonymize in situ -
@@ -337,6 +337,9 @@ public class HMMBuild extends HmmerCommand
     HMMFile file = new HMMFile(
             new FileParse(hmmFile.getAbsolutePath(), DataSourceType.FILE));
     SequenceI hmmSeq = file.getHMM().getConsensusSequence();
+
+
+
     ResidueCount counts = new ResidueCount(alignment.getSequences());
     hmmSeq.getHMM().setBackgroundFrequencies(counts);