JAL-3140 reduced coupling to intervalstore.jar feature/intervalStoreJ
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 1 Mar 2019 09:23:11 +0000 (09:23 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 1 Mar 2019 09:23:11 +0000 (09:23 +0000)
.classpath
lib/intervalstore-src-v0.4.jar [new file with mode: 0644]
lib/intervalstore-v0.4.jar [moved from lib/intervalstore-v0.3.jar with 66% similarity]
src/jalview/datamodel/features/SequenceFeatures.java
test/jalview/datamodel/SequenceTest.java
test/jalview/ext/ensembl/EnsemblSeqProxyTest.java

index 141510b..71ea399 100644 (file)
@@ -70,6 +70,6 @@
        <classpathentry kind="lib" path="lib/htsjdk-2.12.0.jar"/>
        <classpathentry kind="lib" path="lib/groovy-all-2.4.12-indy.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
-       <classpathentry kind="lib" path="lib/intervalstore-v0.3.jar"/>
+       <classpathentry kind="lib" path="lib/intervalstore-v0.4.jar"/>
        <classpathentry kind="output" path="classes"/>
 </classpath>
diff --git a/lib/intervalstore-src-v0.4.jar b/lib/intervalstore-src-v0.4.jar
new file mode 100644 (file)
index 0000000..3feafbb
Binary files /dev/null and b/lib/intervalstore-src-v0.4.jar differ
similarity index 66%
rename from lib/intervalstore-v0.3.jar
rename to lib/intervalstore-v0.4.jar
index 506fc93..4f6101c 100644 (file)
Binary files a/lib/intervalstore-v0.3.jar and b/lib/intervalstore-v0.4.jar differ
index bd102f6..5390975 100644 (file)
@@ -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<IntervalI> FORWARD_STRAND = new Comparator<IntervalI>()
-  {
-    @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<IntervalI> REVERSE_STRAND = new Comparator<IntervalI>()
-  {
-    @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<SequenceFeature> features,
+  public static void sortFeatures(List<? extends IntervalI> features,
           final boolean forwardStrand)
   {
-    Collections.sort(features, forwardStrand ? FORWARD_STRAND
-            : REVERSE_STRAND);
+    IntervalI.sortIntervals(features, forwardStrand);
   }
 
   /**
index 787179b..216635d 100644 (file)
@@ -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
index 69b2ad4..17e92c8 100644 (file)
@@ -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<SequenceFeature> 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);
-  }
 }