From: gmungoc Date: Fri, 1 Mar 2019 09:23:11 +0000 (+0000) Subject: JAL-3140 reduced coupling to intervalstore.jar X-Git-Tag: Release_2_11_0~17^2~91^2^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=daae26d77ca41f38972dfcada536e95bdfb5c753;p=jalview.git JAL-3140 reduced coupling to intervalstore.jar --- diff --git a/.classpath b/.classpath index 141510b..71ea399 100644 --- a/.classpath +++ b/.classpath @@ -70,6 +70,6 @@ - + diff --git a/lib/intervalstore-src-v0.4.jar b/lib/intervalstore-src-v0.4.jar new file mode 100644 index 0000000..3feafbb Binary files /dev/null and b/lib/intervalstore-src-v0.4.jar differ diff --git a/lib/intervalstore-v0.3.jar b/lib/intervalstore-v0.4.jar similarity index 66% rename from lib/intervalstore-v0.3.jar rename to lib/intervalstore-v0.4.jar index 506fc93..4f6101c 100644 Binary files a/lib/intervalstore-v0.3.jar and b/lib/intervalstore-v0.4.jar differ diff --git a/src/jalview/datamodel/features/SequenceFeatures.java b/src/jalview/datamodel/features/SequenceFeatures.java index bd102f6..5390975 100644 --- a/src/jalview/datamodel/features/SequenceFeatures.java +++ b/src/jalview/datamodel/features/SequenceFeatures.java @@ -26,8 +26,6 @@ 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; import java.util.List; import java.util.Map; @@ -47,29 +45,6 @@ import intervalstore.api.IntervalI; */ 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(IntervalI o1, IntervalI 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(IntervalI o1, IntervalI o2) - { - return Integer.compare(o2.getEnd(), o1.getEnd()); - } - }; /* * map from feature type to structured store of features for that type @@ -436,11 +411,10 @@ 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); + IntervalI.sortIntervals(features, forwardStrand); } /** diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index 787179b..216635d 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -48,7 +48,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import intervalstore.impl.Range; import junit.extensions.PA; public class SequenceTest diff --git a/test/jalview/ext/ensembl/EnsemblSeqProxyTest.java b/test/jalview/ext/ensembl/EnsemblSeqProxyTest.java index 69b2ad4..17e92c8 100644 --- a/test/jalview/ext/ensembl/EnsemblSeqProxyTest.java +++ b/test/jalview/ext/ensembl/EnsemblSeqProxyTest.java @@ -234,30 +234,4 @@ public class EnsemblSeqProxyTest // verify attributes string is updated with reverse complement assertEquals("x=y,z;alleles=" + revcomp + ";a=b,c", sf.getAttributes()); } - - @Test(groups = "Functional") - public void testSortFeatures() - { - SequenceFeature sf1 = new SequenceFeature("", "", 10, 15, 0f, null); - SequenceFeature sf2 = new SequenceFeature("", "", 8, 12, 0f, null); - SequenceFeature sf3 = new SequenceFeature("", "", 8, 13, 0f, null); - SequenceFeature sf4 = new SequenceFeature("", "", 11, 11, 0f, null); - List sfs = Arrays.asList(new SequenceFeature[] { sf1, - sf2, sf3, sf4 }); - - // sort by start position ascending (forward strand) - // sf2 and sf3 tie and should not be reordered by sorting - SequenceFeatures.sortFeatures(sfs, true); - assertSame(sfs.get(0), sf2); - assertSame(sfs.get(1), sf3); - assertSame(sfs.get(2), sf1); - assertSame(sfs.get(3), sf4); - - // sort by end position descending (reverse strand) - SequenceFeatures.sortFeatures(sfs, false); - assertSame(sfs.get(0), sf1); - assertSame(sfs.get(1), sf3); - assertSame(sfs.get(2), sf2); - assertSame(sfs.get(3), sf4); - } }