Merge branch 'develop' into bug/JAL-2541cutRelocateFeatures
authorJim Procter <jprocter@issues.jalview.org>
Mon, 17 Dec 2018 11:54:21 +0000 (11:54 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 17 Dec 2018 11:54:21 +0000 (11:54 +0000)
1  2 
src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceI.java
src/jalview/datamodel/features/SequenceFeatures.java
src/jalview/datamodel/features/SequenceFeaturesI.java
src/jalview/ws/DBRefFetcher.java
test/jalview/datamodel/SequenceTest.java
test/jalview/datamodel/features/SequenceFeaturesTest.java

Simple merge
Simple merge
Simple merge
@@@ -261,63 -265,31 +265,86 @@@ public class SequenceTes
      // beyond end returns last residue column
      sq.sequenceChanged();
      assertEquals(13, sq.findIndex(99));
+     /*
+      * residue before sequence 'end' but beyond end of sequence returns 
+      * length of sequence (last column) (rightly or wrongly!)
+      */
+     sq = new Sequence("test/8-15", "A-B-C-"); // trailing gap case
+     assertEquals(6, sq.getLength());
+     sq.sequenceChanged();
+     assertEquals(sq.getLength(), sq.findIndex(14));
+     sq = new Sequence("test/8-99", "-A--B-C-D"); // trailing residue case
+     sq.sequenceChanged();
+     assertEquals(sq.getLength(), sq.findIndex(65));
+     /*
+      * residue after sequence 'start' but before first residue returns 
+      * zero (before first column) (rightly or wrongly!)
+      */
+     sq = new Sequence("test/8-15", "-A-B-C-"); // leading gap case
+     sq.sequenceChanged();
+     assertEquals(0, sq.findIndex(3));
+     sq = new Sequence("test/8-15", "A-B-C-"); // leading residue case
+     sq.sequenceChanged();
+     assertEquals(0, sq.findIndex(2));
    }
  
 +  @Test(groups = { "Functional" })
 +  public void testFindPositions()
 +  {
 +    SequenceI sq = new Sequence("test/8-13", "-ABC---DE-F--");
 +
 +    /*
 +     * invalid inputs
 +     */
 +    assertNull(sq.findPositions(6, 5));
 +    assertNull(sq.findPositions(0, 5));
 +    assertNull(sq.findPositions(-1, 5));
 +
 +    /*
 +     * all gapped ranges
 +     */
 +    assertNull(sq.findPositions(1, 1)); // 1-based columns
 +    assertNull(sq.findPositions(5, 5));
 +    assertNull(sq.findPositions(5, 6));
 +    assertNull(sq.findPositions(5, 7));
 +
 +    /*
 +     * all ungapped ranges
 +     */
 +    assertEquals(new Range(8, 8), sq.findPositions(2, 2)); // A
 +    assertEquals(new Range(8, 9), sq.findPositions(2, 3)); // AB
 +    assertEquals(new Range(8, 10), sq.findPositions(2, 4)); // ABC
 +    assertEquals(new Range(9, 10), sq.findPositions(3, 4)); // BC
 +
 +    /*
 +     * gap to ungapped range
 +     */
 +    assertEquals(new Range(8, 10), sq.findPositions(1, 4)); // ABC
 +    assertEquals(new Range(11, 12), sq.findPositions(6, 9)); // DE
 +
 +    /*
 +     * ungapped to gapped range
 +     */
 +    assertEquals(new Range(10, 10), sq.findPositions(4, 5)); // C
 +    assertEquals(new Range(9, 13), sq.findPositions(3, 11)); // BCDEF
 +
 +    /*
 +     * ungapped to ungapped enclosing gaps
 +     */
 +    assertEquals(new Range(10, 11), sq.findPositions(4, 8)); // CD
 +    assertEquals(new Range(8, 13), sq.findPositions(2, 11)); // ABCDEF
 +
 +    /*
 +     * gapped to gapped enclosing ungapped
 +     */
 +    assertEquals(new Range(8, 10), sq.findPositions(1, 5)); // ABC
 +    assertEquals(new Range(11, 12), sq.findPositions(5, 10)); // DE
 +    assertEquals(new Range(8, 13), sq.findPositions(1, 13)); // the lot
 +    assertEquals(new Range(8, 13), sq.findPositions(1, 99));
 +  }
 +
    /**
     * Tests for the method that returns a dataset sequence position (start..) for
     * an aligned column position (base 0).
    }
  
    @Test(groups = { "Functional" })
 -  public void testFindPositions()
 -  {
 -    SequenceI sq = new Sequence("test/8-13", "-ABC---DE-F--");
 -
 -    /*
 -     * invalid inputs
 -     */
 -    assertNull(sq.findPositions(6, 5));
 -    assertNull(sq.findPositions(0, 5));
 -    assertNull(sq.findPositions(-1, 5));
 -
 -    /*
 -     * all gapped ranges
 -     */
 -    assertNull(sq.findPositions(1, 1)); // 1-based columns
 -    assertNull(sq.findPositions(5, 5));
 -    assertNull(sq.findPositions(5, 6));
 -    assertNull(sq.findPositions(5, 7));
 -
 -    /*
 -     * all ungapped ranges
 -     */
 -    assertEquals(new Range(8, 8), sq.findPositions(2, 2)); // A
 -    assertEquals(new Range(8, 9), sq.findPositions(2, 3)); // AB
 -    assertEquals(new Range(8, 10), sq.findPositions(2, 4)); // ABC
 -    assertEquals(new Range(9, 10), sq.findPositions(3, 4)); // BC
 -
 -    /*
 -     * gap to ungapped range
 -     */
 -    assertEquals(new Range(8, 10), sq.findPositions(1, 4)); // ABC
 -    assertEquals(new Range(11, 12), sq.findPositions(6, 9)); // DE
 -
 -    /*
 -     * ungapped to gapped range
 -     */
 -    assertEquals(new Range(10, 10), sq.findPositions(4, 5)); // C
 -    assertEquals(new Range(9, 13), sq.findPositions(3, 11)); // BCDEF
 -
 -    /*
 -     * ungapped to ungapped enclosing gaps
 -     */
 -    assertEquals(new Range(10, 11), sq.findPositions(4, 8)); // CD
 -    assertEquals(new Range(8, 13), sq.findPositions(2, 11)); // ABCDEF
 -
 -    /*
 -     * gapped to gapped enclosing ungapped
 -     */
 -    assertEquals(new Range(8, 10), sq.findPositions(1, 5)); // ABC
 -    assertEquals(new Range(11, 12), sq.findPositions(5, 10)); // DE
 -    assertEquals(new Range(8, 13), sq.findPositions(1, 13)); // the lot
 -    assertEquals(new Range(8, 13), sq.findPositions(1, 99));
 -  }
 -
 -  @Test(groups = { "Functional" })
+   public void testGapBitset()
+   {
+     SequenceI sq = new Sequence("test/8-13", "-ABC---DE-F--");
+     BitSet bs = sq.gapBitset();
+     BitSet expected = new BitSet();
+     expected.set(0);
+     expected.set(4, 7);
+     expected.set(9);
+     expected.set(11, 13);
+     assertTrue(bs.equals(expected));
+   }
    public void testFindFeatures_largeEndPos()
    {
      /*