X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fcontroller%2FAlignViewController.java;h=d1d61d23bb960d31693ec8aa59e521aca7d51e3c;hb=3f62ab98313f836c9e0cdec277e2ec9a0c194801;hp=e9a0dbf8d01b1894c861e02672f117892abccaaf;hpb=c1fd44e7b1674e9476fd3507d9a6eb0d8f654ca5;p=jalview.git diff --git a/src/jalview/controller/AlignViewController.java b/src/jalview/controller/AlignViewController.java index e9a0dbf..d1d61d2 100644 --- a/src/jalview/controller/AlignViewController.java +++ b/src/jalview/controller/AlignViewController.java @@ -33,6 +33,7 @@ import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.io.DataSourceType; import jalview.io.FeaturesFile; import jalview.util.MessageManager; @@ -237,83 +238,65 @@ public class AlignViewController implements AlignViewControllerI int nseq = 0; for (SequenceI sq : seqs) { - boolean sequenceHasFeature = false; if (sq != null) { - SequenceFeature[] sfs = sq.getSequenceFeatures(); - if (sfs != null) + int ist = sq.findPosition(sqcol.getStartRes()); + int iend = sq.findPosition(sqcol.getEndRes()); // see JAL-2526 + List sfs = sq.getFeatures().findFeatures(ist, + iend, featureType); + boolean overlap = false; + for (SequenceFeature sf : sfs) { - int ist = sq.findIndex(sq.getStart()); - int iend = sq.findIndex(sq.getEnd()); - if (iend < startPosition || ist > endPosition) + // future functionality - featureType == null means mark columns + // containing all displayed features + if (sf != null && (featureType.equals(sf.getType()))) { - // sequence not in region - continue; - } - for (SequenceFeature sf : sfs) - { - // future functionality - featureType == null means mark columns - // containing all displayed features - if (sf != null && (featureType.equals(sf.getType()))) - { - // optimisation - could consider 'spos,apos' like cursor argument - // - findIndex wastes time by starting from first character and - // counting - - int sfStartCol = sq.findIndex(sf.getBegin()); - int sfEndCol = sq.findIndex(sf.getEnd()); - - if (sf.isContactFeature()) - { - /* - * 'contact' feature - check for 'start' or 'end' - * position within the selected region - */ - if (sfStartCol >= startPosition - && sfStartCol <= endPosition) - { - bs.set(sfStartCol - 1); - sequenceHasFeature = true; - } - if (sfEndCol >= startPosition && sfEndCol <= endPosition) - { - bs.set(sfEndCol - 1); - sequenceHasFeature = true; - } - continue; - } + int sfStartCol = sq.findIndex(sf.getBegin()); + int sfEndCol = sq.findIndex(sf.getEnd()); // inefficient - JAL-2526 + if (sf.isContactFeature()) + { /* - * contiguous feature - select feature positions (if any) - * within the selected region + * 'contact' feature - check for 'start' or 'end' + * position within the selected region */ - if (sfStartCol > endPosition || sfEndCol < startPosition) - { - // feature is outside selected region - continue; - } - sequenceHasFeature = true; - if (sfStartCol < startPosition) - { - sfStartCol = startPosition; - } - if (sfStartCol < ist) + if (sfStartCol >= startPosition && sfStartCol <= endPosition) { - sfStartCol = ist; + bs.set(sfStartCol - 1); + overlap = true; } - if (sfEndCol > endPosition) + if (sfEndCol >= startPosition && sfEndCol <= endPosition) { - sfEndCol = endPosition; - } - for (; sfStartCol <= sfEndCol; sfStartCol++) - { - bs.set(sfStartCol - 1); // convert to base 0 + bs.set(sfEndCol - 1); + overlap = true; } + continue; + } + + /* + * contiguous feature - select feature positions (if any) + * within the selected region + */ + if (sfStartCol < startPosition) + { + sfStartCol = startPosition; + } + if (sfStartCol < ist) + { + sfStartCol = ist; + } + if (sfEndCol > endPosition) + { + sfEndCol = endPosition; + } + for (; sfStartCol <= sfEndCol; sfStartCol++) + { + bs.set(sfStartCol - 1); // convert to base 0 + overlap = true; } } } - - if (sequenceHasFeature) + if (overlap) { nseq++; } @@ -370,7 +353,7 @@ public class AlignViewController implements AlignViewControllerI } @Override - public boolean parseFeaturesFile(String file, String protocol, + public boolean parseFeaturesFile(String file, DataSourceType protocol, boolean relaxedIdMatching) { boolean featuresFile = false;