From: gmungoc Date: Mon, 22 May 2017 13:33:07 +0000 (+0100) Subject: JAL-2544 check feature overlaps selection region X-Git-Tag: Release_2_10_2~3^2~73 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=679516a6afeb014dec5a3d8a346ef5a5583dc5b2 JAL-2544 check feature overlaps selection region --- diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index 6c46a3e..693e794 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -811,17 +811,23 @@ public class AlignmentSorter for (int f = 0; f < sf.length; f++) { // filter for selection criteria - if ( - // ignore features outwith alignment start-stop positions. - (sf[f].end < sstart || sf[f].begin > sstop) || - // or ignore based on selection criteria - (featureLabels != null && !AlignmentSorter - .containsIgnoreCase(sf[f].type, featureLabels)) - || (groupLabels != null - // problem here: we cannot eliminate null feature group features - && (sf[f].getFeatureGroup() != null && !AlignmentSorter - .containsIgnoreCase(sf[f].getFeatureGroup(), - groupLabels)))) + SequenceFeature feature = sf[f]; + + /* + * 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 + */ + boolean noOverlap = seqs[i].findIndex(feature.getBegin()) > stop + 1 + || seqs[i].findIndex(feature.getEnd()) < start + 1; + boolean skipFeatureType = featureLabels != null + && !AlignmentSorter.containsIgnoreCase(feature.type, + featureLabels); + boolean skipFeatureGroup = groupLabels != null + && (feature.getFeatureGroup() != null && !AlignmentSorter + .containsIgnoreCase(feature.getFeatureGroup(), + groupLabels)); + if (noOverlap || skipFeatureType || skipFeatureGroup) { // forget about this feature sf[f] = null; @@ -830,7 +836,7 @@ public class AlignmentSorter else { // or, also take a look at the scores if necessary. - if (!ignoreScore && !Float.isNaN(sf[f].getScore())) + if (!ignoreScore && !Float.isNaN(feature.getScore())) { if (seqScores[i] == 0) { @@ -838,7 +844,7 @@ public class AlignmentSorter } seqScores[i]++; hasScore[i] = true; - scores[i] += sf[f].getScore(); // take the first instance of this + scores[i] += feature.getScore(); // take the first instance of this // score. } }