Alignments { public static List<Range<Long>> mismatches(final AlignmentPair alignmentPair) { checkNotNull(alignmentPair); List<Range<Long>> mismatches = new ArrayList<Range<Long>>(); int mismatchStart = -1; for (int i = 1, length = alignmentPair.length() + 1; i < length; i++) { if (isMismatchSymbol(alignmentPair.symbolAt(i))) { if (mismatchStart < 0) { mismatchStart = i; } } else { if (mismatchStart > 0) { mismatches.add(Range.closedOpen(Long.valueOf(mismatchStart - 1L), Long.valueOf(i - 1L))); mismatchStart = -1; } } } if (mismatchStart > 0) { mismatches.add(Range.closedOpen(Long.valueOf(mismatchStart - 1L), Long.valueOf(alignmentPair.length()))); } return mismatches; } private  Alignments(); static long length(final Range<Long> range); static List<Long> lengths(final Iterable<Range<Long>> ranges); static long length(final Iterable<Range<Long>> ranges); static long maximumLength(final Iterable<Range<Long>> ranges); static int count(final Iterable<Range<Long>> ranges); static List<Long> starts(final Iterable<Range<Long>> ranges); static List<Long> ends(final Iterable<Range<Long>> ranges); static List<Range<Long>> gaps(final GappedSymbolList gappedSymbols); static List<Range<Long>> matches(final AlignmentPair alignmentPair); static List<Range<Long>> mismatches(final AlignmentPair alignmentPair);  }
@Test(expected=NullPointerException.class) public void testMismatchesNull() { mismatches(null); }
@Test public void testMismatchesNoMismatches() throws Exception { AlignmentPair allMatches = new AlignmentPair(subject, subject, substitutionMatrix); assertEquals(Collections.<Range<Long>>emptyList(), mismatches(allMatches)); }
@Test public void testMismatchesAllMismatches() throws Exception { GappedSequence mismatch = DNATools.createGappedDNASequence("gggggggggggggggggggg", "mismatch"); AlignmentPair allMismatches = new AlignmentPair(mismatch, subject, substitutionMatrix); List<Range<Long>> mismatches = mismatches(allMismatches); assertEquals(1, mismatches.size()); assertEquals(Range.closedOpen(0L, 20L), mismatches.get(0)); }
@Test public void testMismatches() { List<Range<Long>> mismatches = mismatches(alignmentPair); assertEquals(1, mismatches.size()); assertEquals(Range.closedOpen(4L, 8L), mismatches.get(0)); }