X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Ffeatures%2FSequenceFeatures.java;h=8ac4991d08fe5d6a8e0609e111e73e80d0c16245;hb=10b40b4ec840e5076c95109b0ea518928385821c;hp=1120291dcd3d6e78094b038f88f85555c8f512c8;hpb=3a9c9cd41358438efc1c4f365fecc7491592ca46;p=jalview.git diff --git a/src/jalview/datamodel/features/SequenceFeatures.java b/src/jalview/datamodel/features/SequenceFeatures.java index 1120291..8ac4991 100644 --- a/src/jalview/datamodel/features/SequenceFeatures.java +++ b/src/jalview/datamodel/features/SequenceFeatures.java @@ -20,14 +20,8 @@ */ package jalview.datamodel.features; -import jalview.datamodel.ContiguousI; -import jalview.datamodel.SequenceFeature; -import jalview.io.gff.SequenceOntologyFactory; -import jalview.io.gff.SequenceOntologyI; - import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -35,6 +29,11 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; +import intervalstore.api.IntervalI; +import jalview.datamodel.SequenceFeature; +import jalview.io.gff.SequenceOntologyFactory; +import jalview.io.gff.SequenceOntologyI; + /** * A class that stores sequence features in a way that supports efficient * querying by type and location (overlap). Intended for (but not limited to) @@ -45,30 +44,6 @@ import java.util.TreeMap; */ public class SequenceFeatures implements SequenceFeaturesI { - /** - * a comparator for sorting features by start position ascending - */ - private static Comparator FORWARD_STRAND = new Comparator() - { - @Override - public int compare(ContiguousI o1, ContiguousI o2) - { - return Integer.compare(o1.getBegin(), o2.getBegin()); - } - }; - - /** - * a comparator for sorting features by end position descending - */ - private static Comparator REVERSE_STRAND = new Comparator() - { - @Override - public int compare(ContiguousI o1, ContiguousI o2) - { - return Integer.compare(o2.getEnd(), o1.getEnd()); - } - }; - /* * map from feature type to structured store of features for that type * null types are permitted (but not a good idea!) @@ -435,11 +410,13 @@ public class SequenceFeatures implements SequenceFeaturesI * @param features * @param forwardStrand */ - public static void sortFeatures(List features, + public static void sortFeatures(List features, final boolean forwardStrand) { - Collections.sort(features, forwardStrand ? FORWARD_STRAND - : REVERSE_STRAND); + Collections.sort(features, + forwardStrand + ? IntervalI.COMPARE_BEGIN_ASC_END_DESC + : IntervalI.COMPARE_END_DESC); } /**