/** * Indicates whether there are more than one kmerSize in the set. * * @return {@code true} iff there is more than one kmerSize assembly in the set. */ public boolean hasMultipleKmerSizes() { return kmerSizes.size() > 1; }
@Override public boolean isEmpty() { return size() == 0; }
@Override public String toString() { final StringBuilder sb = new StringBuilder(2 + size() * 10); sb.append('{'); for (int i = 0; i < size; i++) sb.append(elements[i]).append(','); sb.replace(sb.length()-1,sb.length(),"}"); return sb.toString(); }
/** * Returns the maximum kmerSize available. * * @throws IllegalStateException if no assembly-result was added to the set, thus there is no kmerSize. * * @return greater than 0. */ public int getMaximumKmerSize() { if (kmerSizes.size() == 0) throw new IllegalStateException("there is yet no kmerSize in this assembly result set"); return kmerSizes.max(); }
/** * Returns the minimum kmerSize available. * * @throws IllegalStateException if no assembly-result was added to the set, thus there is no kmerSize. * * @return greater than 0. */ public int getMinimumKmerSize() { if (kmerSizes.size() == 0) throw new IllegalStateException("there is yet no kmerSize in this assembly result set"); return kmerSizes.min(); }
/** * Determines how much we can clip away from the right side of a set of path without loosing accuracy when comparing * likelihood vs the read. * * @param readEnd exclusive position right after the last one of the region considered. * @param pathBases bases of possible path in the same event block. * @param readBases full length read bases. * @param pathSizes path size set. * * @return 0 or greater. */ private int calculateRightClipping(final int readEnd, final byte[][] pathBases, final byte[] readBases, final CountSet pathSizes) { final int maxClipping = pathSizes.size() > 1 ? 0 : Math.min(pathSizes.min(), kmerSize - 1); int rightClipping = 0; while (rightClipping < maxClipping) { final byte readBase = readBases[readEnd - rightClipping - 1]; boolean dontGoFurther = false; for (int i = 0; !dontGoFurther && i < pathBases.length; i++) if (pathBases[i][pathBases[i].length - rightClipping - 1] != readBase) dontGoFurther = true; if (dontGoFurther) break; rightClipping++; } return rightClipping; }
@Test(dataProvider="capacities") public void testSize(final int capacity) { final CountSet empty = new CountSet(capacity); Assert.assertEquals(empty.size(), 0); CountSet nonEmpty = new CountSet(capacity); for (int i = 0; i < capacity * 3; i++) { nonEmpty.add(i); Assert.assertEquals(nonEmpty.size(),i + 1); } }
@Test void testSetToArrayOfValues() { final int CAPACITY = 10; final CountSet subject = new CountSet(CAPACITY); final int REPEATS = 1000; final Random rnd = new Random(13); final int[] values = new int[REPEATS]; for (int i = 0; i < REPEATS; i++) { int newInt = rnd.nextInt(Integer.MAX_VALUE) * (rnd.nextBoolean() ? -1 : 1); values[i] = newInt; } subject.setTo(values); Arrays.sort(values); Assert.assertEquals(subject.size(),REPEATS); Assert.assertEquals(subject.min(),values[0]); Assert.assertEquals(subject.max(),values[REPEATS - 1]); }
@Test public void testAddRange() { final CountSet subject = new CountSet(10); subject.addRange(10,21); Assert.assertEquals(subject.size(),12); for (int i = 10; i < 22; i++) Assert.assertTrue(subject.contains(i)); for (int i = -1; i < 10; i++) Assert.assertFalse(subject.contains(i)); for (int i = 22; i < 31; i++) Assert.assertFalse(subject.contains(i)); }
@Test public void testSingleValueAdd() { final int CAPACITY = 10; final CountSet subject = new CountSet(CAPACITY); final HashSet<Integer> reasuranceSet = new HashSet<>(CAPACITY); final int REPEATS = 1000; final Random rnd = new Random(13); for (int i = 0; i < REPEATS; i++) { int newInt = rnd.nextInt(500); boolean expectedResult = reasuranceSet.add(newInt); boolean result = subject.add(newInt); Assert.assertEquals(result,expectedResult); Assert.assertEquals(subject.size(),reasuranceSet.size()); } for (final int j : reasuranceSet) Assert.assertTrue(subject.contains(j)); for (int j = 0; j < 501; j++) Assert.assertEquals(subject.contains(j),reasuranceSet.contains(j)); }
@Test public void testSetToSingleValue() { final CountSet subject = new CountSet(10); subject.setTo(-31); Assert.assertEquals(subject.size(),1); Assert.assertEquals(subject.min(),-31); Assert.assertEquals(subject.max(),-31); Assert.assertTrue(subject.contains(-31)); Assert.assertFalse(subject.contains(-21)); }
@Test public void testArrayValueAdd() { final int CAPACITY = 10; final CountSet subject = new CountSet(CAPACITY); final HashSet<Integer> reasuranceSet = new HashSet<>(CAPACITY); final int REPEATS = 1000; final Random rnd = new Random(13); final int[] values = new int[REPEATS]; final Integer[] valueWrappers = new Integer[REPEATS]; for (int i = 0; i < REPEATS; i++) { int newInt = rnd.nextInt(500); values[i] = newInt; valueWrappers[i] = newInt; } boolean expectedResult = reasuranceSet.addAll(Arrays.asList(valueWrappers)); boolean result = subject.addAll(values); Assert.assertEquals(result,expectedResult); Assert.assertEquals(subject.size(),reasuranceSet.size()); for (final int j : reasuranceSet) Assert.assertTrue(subject.contains(j)); for (int j = 0; j < 501; j++) Assert.assertEquals(subject.contains(j),reasuranceSet.contains(j)); }
final int maxClipping = pathSizes.size() <= 1 ? blockLength : pathSizes.min(); MultiDeBruijnVertex clippingEnd = backwards ? anchoring.rightAnchorVertex : anchoring.leftAnchorVertex; while (!possibleClippingPoints.isEmpty()) {