From: gmungoc Date: Mon, 21 Jan 2019 14:32:17 +0000 (+0000) Subject: JAL-3187 findFeaturesAtResidue answer in render order (tests TODO) X-Git-Tag: Release_2_11_1_0~73 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4ffae060863956975d45807b6776dc7a5cf337b8;p=jalview.git JAL-3187 findFeaturesAtResidue answer in render order (tests TODO) --- diff --git a/src/jalview/api/FeatureRenderer.java b/src/jalview/api/FeatureRenderer.java index 861f337..59e3e61 100644 --- a/src/jalview/api/FeatureRenderer.java +++ b/src/jalview/api/FeatureRenderer.java @@ -162,7 +162,9 @@ public interface FeatureRenderer /** * Returns features at the specified residue positions on the given sequence. - * Non-positional features are not included. + * Non-positional features are not included. Features are returned in render + * order of their feature type (last is on top). Within feature type, ordering + * is undefined. * * @param sequence * @param fromResNo diff --git a/src/jalview/datamodel/features/SequenceFeatures.java b/src/jalview/datamodel/features/SequenceFeatures.java index 8f965b4..08f3847 100644 --- a/src/jalview/datamodel/features/SequenceFeatures.java +++ b/src/jalview/datamodel/features/SequenceFeatures.java @@ -26,7 +26,6 @@ import jalview.io.gff.SequenceOntologyFactory; import jalview.io.gff.SequenceOntologyI; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; @@ -228,7 +227,9 @@ public class SequenceFeatures implements SequenceFeaturesI /** * A convenience method that converts a vararg for feature types to an - * Iterable over matched feature sets in key order + * Iterable over matched feature sets. If no types are specified, all feature + * sets are returned. If one or more types are specified, feature sets for + * those types are returned, preserving the order of the types. * * @param type * @return @@ -244,12 +245,11 @@ public class SequenceFeatures implements SequenceFeaturesI } List types = new ArrayList<>(); - List args = Arrays.asList(type); - for (Entry featureType : featureStore.entrySet()) + for (String theType : type) { - if (args.contains(featureType.getKey())) + if (featureStore.containsKey(theType)) { - types.add(featureType.getValue()); + types.add(featureStore.get(theType)); } } return types; diff --git a/src/jalview/datamodel/features/SequenceFeaturesI.java b/src/jalview/datamodel/features/SequenceFeaturesI.java index ca0283e..7213cba 100644 --- a/src/jalview/datamodel/features/SequenceFeaturesI.java +++ b/src/jalview/datamodel/features/SequenceFeaturesI.java @@ -42,7 +42,8 @@ public interface SequenceFeaturesI /** * Returns a (possibly empty) list of features, optionally restricted to * specified types, which overlap the given (inclusive) sequence position - * range + * range. If types are specified, features are returned in the order of the + * types given. * * @param from * @param to diff --git a/src/jalview/renderer/seqfeatures/FeatureRenderer.java b/src/jalview/renderer/seqfeatures/FeatureRenderer.java index fc8731d..d833a19 100644 --- a/src/jalview/renderer/seqfeatures/FeatureRenderer.java +++ b/src/jalview/renderer/seqfeatures/FeatureRenderer.java @@ -317,7 +317,7 @@ public class FeatureRenderer extends FeatureRendererModel if (featureColour == null) { /* - * feature excluded by visibility settings, filters, or colour threshold + * feature excluded by filters, or colour threshold */ continue; } diff --git a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java index 821f7f4..7faf7ea 100644 --- a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java +++ b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java @@ -1016,8 +1016,7 @@ public abstract class FeatureRendererModel * displayed, and feature group is null or the empty string * or marked for display */ - Set visibleFeatures = getFeaturesDisplayed() - .getVisibleFeatures(); + List visibleFeatures = getDisplayedFeatureTypes(); String[] visibleTypes = visibleFeatures .toArray(new String[visibleFeatures.size()]); List features = sequence.getFeatures().findFeatures(