JAL-2490 find features for export as GFF, JAL-2548 respect group
[jalview.git] / src / jalview / analysis / AlignmentSorter.java
index 681d3b7..e7733e9 100755 (executable)
@@ -771,8 +771,25 @@ public class AlignmentSorter
       {
         SequenceFeature sf = it.next();
 
+        /*
+         * double-check feature overlaps columns (JAL-2544)
+         * (could avoid this with a findPositions(fromCol, toCol) method)
+         * findIndex returns base 1 column values, startCol/endCol are base 0
+         */
+        if (seqs[i].findIndex(sf.getBegin()) > endCol + 1
+                || seqs[i].findIndex(sf.getEnd()) < startCol + 1)
+        {
+          it.remove();
+          continue;
+        }
+
+        /*
+         * accept all features with null or empty group, otherwise
+         * check group is one of the currently visible groups
+         */
         String featureGroup = sf.getFeatureGroup();
         if (groups != null && featureGroup != null
+                && !"".equals(featureGroup)
                 && !groups.contains(featureGroup))
         {
           it.remove();