import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
}
@Override
+ public BitSet getInsertionsAsBits()
+ {
+ BitSet map = new BitSet();
+ int lastj = -1, j = 0;
+ int pos = start;
+ int seqlen = sequence.length;
+ while ((j < seqlen))
+ {
+ if (jalview.util.Comparison.isGap(sequence[j]))
+ {
+ if (lastj == -1)
+ {
+ lastj = j;
+ }
+ }
+ else
+ {
+ if (lastj != -1)
+ {
+ map.set(lastj, j - 1);
+ lastj = -1;
+ }
+ }
+ j++;
+ }
+ if (lastj != -1)
+ {
+ map.set(lastj, j - 1);
+ lastj = -1;
+ }
+ return map;
+ }
+
+ @Override
public void deleteChars(int i, int j)
{
int newstart = start, newend = end;
*/
package jalview.datamodel;
+import java.util.BitSet;
import java.util.List;
import java.util.Vector;
* list
*/
public List<DBRefEntry> getPrimaryDBRefs();
+
+ /**
+ *
+ * @return BitSet corresponding to index [0,length) where Comparison.isGap()
+ * returns true.
+ */
+ BitSet getInsertionsAsBits();
}
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.List;
import java.util.Vector;
assertEquals("Gap interval 1 end wrong", 4, gapInt.get(0)[1]);
assertEquals("Gap interval 2 start wrong", 6, gapInt.get(1)[0]);
assertEquals("Gap interval 2 end wrong", 8, gapInt.get(1)[1]);
+
+ BitSet gapfield = aseq.getInsertionsAsBits();
+ BitSet expectedgaps = new BitSet();
+ expectedgaps.set(2, 4);
+ expectedgaps.set(6, 8);
+
+ assertEquals("getInsertionsAsBits not correct.", expectedgaps, gapfield);
}
@Test(groups = ("Functional"))