JAL-3187 findFeaturesAtResidue answer in render order (tests TODO)
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 21 Jan 2019 14:32:17 +0000 (14:32 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 21 Jan 2019 14:32:17 +0000 (14:32 +0000)
src/jalview/api/FeatureRenderer.java
src/jalview/datamodel/features/SequenceFeatures.java
src/jalview/datamodel/features/SequenceFeaturesI.java
src/jalview/renderer/seqfeatures/FeatureRenderer.java
src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java

index 861f337..59e3e61 100644 (file)
@@ -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
index 8f965b4..08f3847 100644 (file)
@@ -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<FeatureStore> types = new ArrayList<>();
-    List<String> args = Arrays.asList(type);
-    for (Entry<String, FeatureStore> 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;
index ca0283e..7213cba 100644 (file)
@@ -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
index fc8731d..d833a19 100644 (file)
@@ -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;
         }
index 821f7f4..7faf7ea 100644 (file)
@@ -1016,8 +1016,7 @@ public abstract class FeatureRendererModel
      * displayed, and feature group is null or the empty string
      * or marked for display
      */
-    Set<String> visibleFeatures = getFeaturesDisplayed()
-            .getVisibleFeatures();
+    List<String> visibleFeatures = getDisplayedFeatureTypes();
     String[] visibleTypes = visibleFeatures
             .toArray(new String[visibleFeatures.size()]);
     List<SequenceFeature> features = sequence.getFeatures().findFeatures(