From 1cb5effd293c65136ba82d611d7a826715010f45 Mon Sep 17 00:00:00 2001 From: Ron Levine Date: Wed, 29 Mar 2017 15:57:14 -0400 Subject: [PATCH 1/2] Make exception message informative --- src/main/java/htsjdk/samtools/BAMRecord.java | 2 +- src/main/java/htsjdk/samtools/BAMRecordCodec.java | 2 +- src/main/java/htsjdk/samtools/SAMUtils.java | 59 ++++++++++++++--------- src/test/java/htsjdk/samtools/SAMUtilsTest.java | 38 +++++++++++++++ 4 files changed, 75 insertions(+), 26 deletions(-) diff --git a/src/main/java/htsjdk/samtools/BAMRecord.java b/src/main/java/htsjdk/samtools/BAMRecord.java index 672e802c3..44a88344a 100644 --- a/src/main/java/htsjdk/samtools/BAMRecord.java +++ b/src/main/java/htsjdk/samtools/BAMRecord.java @@ -342,7 +342,7 @@ private String decodeReadName() { return NULL_SEQUENCE; } final int basesOffset = readNameSize() + cigarSize(); - return SAMUtils.compressedBasesToBytes(mReadLength, mRestOfBinaryData, basesOffset); + return SAMUtils.compressedBasesToBytes(mReadLength, mRestOfBinaryData, basesOffset, getReadName()); } /* methods for computing disk size of variably-sized elements, in order to locate diff --git a/src/main/java/htsjdk/samtools/BAMRecordCodec.java b/src/main/java/htsjdk/samtools/BAMRecordCodec.java index 5b0a408f6..dad327425 100644 --- a/src/main/java/htsjdk/samtools/BAMRecordCodec.java +++ b/src/main/java/htsjdk/samtools/BAMRecordCodec.java @@ -154,7 +154,7 @@ public void encode(final SAMRecord alignment) { // that it is specced as a uint. this.binaryCodec.writeInt(cigarElement); } - this.binaryCodec.writeBytes(SAMUtils.bytesToCompressedBases(alignment.getReadBases())); + this.binaryCodec.writeBytes(SAMUtils.bytesToCompressedBases(alignment.getReadBases(), alignment.getReadName())); byte[] qualities = alignment.getBaseQualities(); if (qualities.length == 0) { qualities = new byte[alignment.getReadLength()]; diff --git a/src/main/java/htsjdk/samtools/SAMUtils.java b/src/main/java/htsjdk/samtools/SAMUtils.java index 25b6799c7..42b5a70f9 100644 --- a/src/main/java/htsjdk/samtools/SAMUtils.java +++ b/src/main/java/htsjdk/samtools/SAMUtils.java @@ -111,46 +111,48 @@ public static final int MAX_PHRED_SCORE = 93; /** - * Convert from a byte array containing =AaCcGgTtNn represented as ASCII, to a byte array half as long, - * with =, A, C, G, T converted to 0, 1, 2, 4, 8, 15. + * Convert from a byte array containing =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb represented as ASCII, to a byte array half as long, + * with fore example, =, A, C, G, T converted to 0, 1, 2, 4, 8, 15. * * @param readBases Bases as ASCII bytes. + * @param readName Name of the read containing the bases, * @return New byte array with bases represented as nybbles, in BAM binary format. */ - static byte[] bytesToCompressedBases(final byte[] readBases) { + static byte[] bytesToCompressedBases(final byte[] readBases, final String readName) { final byte[] compressedBases = new byte[(readBases.length + 1) / 2]; int i; for (i = 1; i < readBases.length; i += 2) { - compressedBases[i / 2] = (byte) (charToCompressedBaseHigh(readBases[i - 1]) | - charToCompressedBaseLow(readBases[i])); + compressedBases[i / 2] = (byte) (charToCompressedBaseHigh(readBases[i - 1], readName) | + charToCompressedBaseLow(readBases[i], readName)); } // Last nybble if (i == readBases.length) { - compressedBases[i / 2] = charToCompressedBaseHigh((char) readBases[i - 1]); + compressedBases[i / 2] = charToCompressedBaseHigh(readBases[i - 1], readName); } return compressedBases; } /** - * Convert from a byte array with basese stored in nybbles, with =, A, C, G, T represented as 0, 1, 2, 4, 8, 15, + * Convert from a byte array with bases stored in nybbles, with fore example,=, A, C, G, T, N represented as 0, 1, 2, 4, 8, 15, * to a a byte array containing =AaCcGgTtNn represented as ASCII. * * @param length Number of bases (not bytes) to convert. * @param compressedBases Bases represented as nybbles, in BAM binary format. + * @param readName Name of the read containing the bases. * @param compressedOffset Byte offset in compressedBases to start. * @return New byte array with bases as ASCII bytes. */ - public static byte[] compressedBasesToBytes(final int length, final byte[] compressedBases, final int compressedOffset) { + public static byte[] compressedBasesToBytes(final int length, final byte[] compressedBases, final int compressedOffset, final String readName) { final byte[] ret = new byte[length]; int i; for (i = 1; i < length; i += 2) { final int compressedIndex = i / 2 + compressedOffset; - ret[i - 1] = compressedBaseToByteHigh(compressedBases[compressedIndex]); - ret[i] = compressedBaseToByteLow(compressedBases[compressedIndex]); + ret[i - 1] = compressedBaseToByteHigh(compressedBases[compressedIndex], readName); + ret[i] = compressedBaseToByteLow(compressedBases[compressedIndex], readName); } // Last nybble if (i == length) { - ret[i - 1] = compressedBaseToByteHigh(compressedBases[i / 2 + compressedOffset]); + ret[i - 1] = compressedBaseToByteHigh(compressedBases[i / 2 + compressedOffset], readName); } return ret; } @@ -158,10 +160,12 @@ /** * Convert from ASCII byte to BAM nybble representation of a base in low-order nybble. * - * @param base One of =AaCcGgTtNn. + * @param base One of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. + * @param readName Name of the read containing the base. * @return Low-order nybble-encoded equivalent. + * @throws IllegalArgumentException if the base is not one of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. */ - private static byte charToCompressedBaseLow(final int base) { + private static byte charToCompressedBaseLow(final byte base, final String readName) { switch (base) { case '=': return COMPRESSED_EQUAL_LOW; @@ -214,17 +218,19 @@ private static byte charToCompressedBaseLow(final int base) { case 'b': return COMPRESSED_B_LOW; default: - throw new IllegalArgumentException("Bad byte passed to charToCompressedBase: " + base); + throw new IllegalArgumentException("Bad base passed to charToCompressedBaseLow: " + Character.toString((char)base) + " in read: " + readName); } } /** * Convert from ASCII byte to BAM nybble representation of a base in high-order nybble. * - * @param base One of =AaCcGgTtNn. + * @param base One of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. + * @param readName Name of the read containing the base. * @return High-order nybble-encoded equivalent. + * @throws IllegalArgumentException if the base is not one of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. */ - private static byte charToCompressedBaseHigh(final int base) { + private static byte charToCompressedBaseHigh(final byte base, final String readName) { switch (base) { case '=': return COMPRESSED_EQUAL_HIGH; @@ -277,20 +283,22 @@ private static byte charToCompressedBaseHigh(final int base) { case 'b': return COMPRESSED_B_HIGH; default: - throw new IllegalArgumentException("Bad byte passed to charToCompressedBase: " + base); + throw new IllegalArgumentException("Bad base passed to charToCompressedBaseHigh: " + Character.toString((char)base) + " in read: " + readName); } } /** * Returns the byte corresponding to a certain nybble * @param base One of COMPRESSED_*_LOW, a low-order nybble encoded base. - * @return ASCII base, one of ACGTN=. + * @param readName Name of the read containing the base. + * @return ASCII base, one of =ACGTNMRSVWYHKDB. + * @throws IllegalArgumentException if the base is not one of =ACGTNMRSVWYHKDB. */ - private static byte compressedBaseToByte(byte base){ + private static byte compressedBaseToByte(byte base, final String readName){ try{ return COMPRESSED_LOOKUP_TABLE[base]; }catch(IndexOutOfBoundsException e){ - throw new IllegalArgumentException("Bad byte passed to charToCompressedBase: " + base); + throw new IllegalArgumentException("Bad base passed to charToCompressedBase: " + Character.toString((char)base) + " in read: " + readName); } } @@ -298,20 +306,22 @@ private static byte compressedBaseToByte(byte base){ * Convert from BAM nybble representation of a base in low-order nybble to ASCII byte. * * @param base One of COMPRESSED_*_LOW, a low-order nybble encoded base. + * @param readName Name of the read containing the base. * @return ASCII base, one of ACGTN=. */ - private static byte compressedBaseToByteLow(final int base) { - return compressedBaseToByte((byte)(base & 0xf)); + private static byte compressedBaseToByteLow(final int base, final String readName) { + return compressedBaseToByte((byte)(base & 0xf), readName); } /** * Convert from BAM nybble representation of a base in high-order nybble to ASCII byte. * * @param base One of COMPRESSED_*_HIGH, a high-order nybble encoded base. + * @param readName Name of the read containing the base. * @return ASCII base, one of ACGTN=. */ - private static byte compressedBaseToByteHigh(final int base) { - return compressedBaseToByte((byte)((base >> 4) & 0xf)); + private static byte compressedBaseToByteHigh(final int base, final String readName) { + return compressedBaseToByte((byte)((base >> 4) & 0xf), readName); } /** @@ -394,6 +404,7 @@ public static char phredToFastq(final int phredScore) { } /** + * * Converts printable qualities in Sanger fastq format to binary phred scores. */ public static void fastqToPhred(final byte[] fastq) { diff --git a/src/test/java/htsjdk/samtools/SAMUtilsTest.java b/src/test/java/htsjdk/samtools/SAMUtilsTest.java index 3be7e390c..69d3ec1c9 100644 --- a/src/test/java/htsjdk/samtools/SAMUtilsTest.java +++ b/src/test/java/htsjdk/samtools/SAMUtilsTest.java @@ -24,8 +24,10 @@ package htsjdk.samtools; import org.testng.Assert; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.util.Arrays; import java.util.List; public class SAMUtilsTest { @@ -244,7 +246,43 @@ public void testOtherCanonicalAlignments() { Assert.assertEquals(other.getAttribute(SAMTagUtil.getSingleton().NM),null); Assert.assertEquals(other.getCigarString(),"8M2S"); Assert.assertEquals(other.getInferredInsertSize(),-91);//100(mate) - 191(other) + } + + @Test() + public void testBytesToCompressedBases() { + final byte[] bases = new byte[]{'=', 'a', 'A', 'c', 'C', 'g', 'G', 't', 'T', 'n', 'N', '.', 'M', 'm', + 'R', 'r', 'S', 's', 'V', 'v', 'W', 'w', 'Y', 'y', 'H', 'h', 'K', 'k', 'D', 'd', 'B', 'b'}; + final byte[] compressedBases = SAMUtils.bytesToCompressedBases(bases, "readName"); + String expectedCompressedBases = "[1, 18, 36, 72, -113, -1, 51, 85, 102, 119, -103, -86, -69, -52, -35, -18]"; + Assert.assertEquals(Arrays.toString(compressedBases), expectedCompressedBases); + } + + @DataProvider + public Object[][] testBadBase() { + return new Object[][]{ + {new byte[]{'>', 'A'}, '>'}, + {new byte[]{'A', '>'} , '>'} + }; + } + @Test(dataProvider = "testBadBase", expectedExceptions = IllegalArgumentException.class) + public void testBytesToCompressedBasesException(final byte[] bases, final char failingBase) { + final String readName = "readName"; + try { + SAMUtils.bytesToCompressedBases(bases, readName); + } catch ( final IllegalArgumentException ex ) { + Assert.assertTrue(ex.getMessage().contains(readName)); + Assert.assertTrue(ex.getMessage().contains(Character.toString(failingBase))); + throw ex; + } } + @Test + public void testCompressedBasesToBytes() { + final byte[] compressedBases = new byte[]{1, 18, 36, 72, -113, -1, 51, 85, 102, 119, -103, -86, -69, -52, -35, -18}; + final byte[] bytes = SAMUtils.compressedBasesToBytes(2*compressedBases.length, compressedBases, 0, "readName"); + final byte[] expectedBases = new byte[]{'=', 'A', 'A', 'C', 'C', 'G', 'G', 'T', 'T', 'N', 'N', 'N', 'M', 'M', + 'R', 'R', 'S', 'S', 'V', 'V', 'W', 'W', 'Y', 'Y', 'H', 'H', 'K', 'K', 'D', 'D', 'B', 'B'}; + Assert.assertEquals(new String(bytes), new String(expectedBases)); + } } From 37a499b1645b67388d9c47ca89aa5a9247b4a11e Mon Sep 17 00:00:00 2001 From: Ron Levine Date: Thu, 30 Mar 2017 15:29:15 -0400 Subject: [PATCH 2/2] Add read name where accessible to the exception message --- src/main/java/htsjdk/samtools/BAMRecord.java | 7 +++- src/main/java/htsjdk/samtools/BAMRecordCodec.java | 7 +++- src/main/java/htsjdk/samtools/SAMUtils.java | 48 ++++++++++------------- src/test/java/htsjdk/samtools/SAMUtilsTest.java | 8 ++-- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/main/java/htsjdk/samtools/BAMRecord.java b/src/main/java/htsjdk/samtools/BAMRecord.java index 44a88344a..14b629595 100644 --- a/src/main/java/htsjdk/samtools/BAMRecord.java +++ b/src/main/java/htsjdk/samtools/BAMRecord.java @@ -342,7 +342,12 @@ private String decodeReadName() { return NULL_SEQUENCE; } final int basesOffset = readNameSize() + cigarSize(); - return SAMUtils.compressedBasesToBytes(mReadLength, mRestOfBinaryData, basesOffset, getReadName()); + try { + return SAMUtils.compressedBasesToBytes(mReadLength, mRestOfBinaryData, basesOffset); + } catch ( final IllegalArgumentException ex ) { + final String msg = ex.getMessage() + " in read: " + getReadName(); + throw new IllegalStateException(msg, ex); + } } /* methods for computing disk size of variably-sized elements, in order to locate diff --git a/src/main/java/htsjdk/samtools/BAMRecordCodec.java b/src/main/java/htsjdk/samtools/BAMRecordCodec.java index dad327425..e363a5b95 100644 --- a/src/main/java/htsjdk/samtools/BAMRecordCodec.java +++ b/src/main/java/htsjdk/samtools/BAMRecordCodec.java @@ -154,7 +154,12 @@ public void encode(final SAMRecord alignment) { // that it is specced as a uint. this.binaryCodec.writeInt(cigarElement); } - this.binaryCodec.writeBytes(SAMUtils.bytesToCompressedBases(alignment.getReadBases(), alignment.getReadName())); + try { + this.binaryCodec.writeBytes(SAMUtils.bytesToCompressedBases(alignment.getReadBases())); + } catch ( final IllegalArgumentException ex ) { + final String msg = ex.getMessage() + " in read: " + alignment.getReadName(); + throw new IllegalStateException(msg, ex); + } byte[] qualities = alignment.getBaseQualities(); if (qualities.length == 0) { qualities = new byte[alignment.getReadLength()]; diff --git a/src/main/java/htsjdk/samtools/SAMUtils.java b/src/main/java/htsjdk/samtools/SAMUtils.java index 42b5a70f9..d439a4a83 100644 --- a/src/main/java/htsjdk/samtools/SAMUtils.java +++ b/src/main/java/htsjdk/samtools/SAMUtils.java @@ -112,47 +112,45 @@ /** * Convert from a byte array containing =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb represented as ASCII, to a byte array half as long, - * with fore example, =, A, C, G, T converted to 0, 1, 2, 4, 8, 15. + * with for example, =, A, C, G, T converted to 0, 1, 2, 4, 8, 15. * * @param readBases Bases as ASCII bytes. - * @param readName Name of the read containing the bases, * @return New byte array with bases represented as nybbles, in BAM binary format. */ - static byte[] bytesToCompressedBases(final byte[] readBases, final String readName) { + static byte[] bytesToCompressedBases(final byte[] readBases) { final byte[] compressedBases = new byte[(readBases.length + 1) / 2]; int i; for (i = 1; i < readBases.length; i += 2) { - compressedBases[i / 2] = (byte) (charToCompressedBaseHigh(readBases[i - 1], readName) | - charToCompressedBaseLow(readBases[i], readName)); + compressedBases[i / 2] = (byte) (charToCompressedBaseHigh(readBases[i - 1]) | + charToCompressedBaseLow(readBases[i])); } // Last nybble if (i == readBases.length) { - compressedBases[i / 2] = charToCompressedBaseHigh(readBases[i - 1], readName); + compressedBases[i / 2] = charToCompressedBaseHigh(readBases[i - 1]); } return compressedBases; } /** - * Convert from a byte array with bases stored in nybbles, with fore example,=, A, C, G, T, N represented as 0, 1, 2, 4, 8, 15, + * Convert from a byte array with bases stored in nybbles, with for example,=, A, C, G, T, N represented as 0, 1, 2, 4, 8, 15, * to a a byte array containing =AaCcGgTtNn represented as ASCII. * * @param length Number of bases (not bytes) to convert. * @param compressedBases Bases represented as nybbles, in BAM binary format. - * @param readName Name of the read containing the bases. * @param compressedOffset Byte offset in compressedBases to start. * @return New byte array with bases as ASCII bytes. */ - public static byte[] compressedBasesToBytes(final int length, final byte[] compressedBases, final int compressedOffset, final String readName) { + public static byte[] compressedBasesToBytes(final int length, final byte[] compressedBases, final int compressedOffset) { final byte[] ret = new byte[length]; int i; for (i = 1; i < length; i += 2) { final int compressedIndex = i / 2 + compressedOffset; - ret[i - 1] = compressedBaseToByteHigh(compressedBases[compressedIndex], readName); - ret[i] = compressedBaseToByteLow(compressedBases[compressedIndex], readName); + ret[i - 1] = compressedBaseToByteHigh(compressedBases[compressedIndex]); + ret[i] = compressedBaseToByteLow(compressedBases[compressedIndex]); } // Last nybble if (i == length) { - ret[i - 1] = compressedBaseToByteHigh(compressedBases[i / 2 + compressedOffset], readName); + ret[i - 1] = compressedBaseToByteHigh(compressedBases[i / 2 + compressedOffset]); } return ret; } @@ -161,11 +159,10 @@ * Convert from ASCII byte to BAM nybble representation of a base in low-order nybble. * * @param base One of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. - * @param readName Name of the read containing the base. * @return Low-order nybble-encoded equivalent. * @throws IllegalArgumentException if the base is not one of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. */ - private static byte charToCompressedBaseLow(final byte base, final String readName) { + private static byte charToCompressedBaseLow(final byte base) { switch (base) { case '=': return COMPRESSED_EQUAL_LOW; @@ -218,7 +215,7 @@ private static byte charToCompressedBaseLow(final byte base, final String readNa case 'b': return COMPRESSED_B_LOW; default: - throw new IllegalArgumentException("Bad base passed to charToCompressedBaseLow: " + Character.toString((char)base) + " in read: " + readName); + throw new IllegalArgumentException("Bad base passed to charToCompressedBaseLow: " + Character.toString((char)base) + "(" + base + ")"); } } @@ -226,11 +223,10 @@ private static byte charToCompressedBaseLow(final byte base, final String readNa * Convert from ASCII byte to BAM nybble representation of a base in high-order nybble. * * @param base One of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. - * @param readName Name of the read containing the base. * @return High-order nybble-encoded equivalent. * @throws IllegalArgumentException if the base is not one of =AaCcGgTtNnMmRrSsVvWwYyHhKkDdBb. */ - private static byte charToCompressedBaseHigh(final byte base, final String readName) { + private static byte charToCompressedBaseHigh(final byte base) { switch (base) { case '=': return COMPRESSED_EQUAL_HIGH; @@ -283,22 +279,21 @@ private static byte charToCompressedBaseHigh(final byte base, final String readN case 'b': return COMPRESSED_B_HIGH; default: - throw new IllegalArgumentException("Bad base passed to charToCompressedBaseHigh: " + Character.toString((char)base) + " in read: " + readName); + throw new IllegalArgumentException("Bad base passed to charToCompressedBaseHigh: " + Character.toString((char)base) + "(" + base + ")"); } } /** * Returns the byte corresponding to a certain nybble * @param base One of COMPRESSED_*_LOW, a low-order nybble encoded base. - * @param readName Name of the read containing the base. * @return ASCII base, one of =ACGTNMRSVWYHKDB. * @throws IllegalArgumentException if the base is not one of =ACGTNMRSVWYHKDB. */ - private static byte compressedBaseToByte(byte base, final String readName){ + private static byte compressedBaseToByte(byte base){ try{ return COMPRESSED_LOOKUP_TABLE[base]; }catch(IndexOutOfBoundsException e){ - throw new IllegalArgumentException("Bad base passed to charToCompressedBase: " + Character.toString((char)base) + " in read: " + readName); + throw new IllegalArgumentException("Bad base passed to charToCompressedBase: " + Character.toString((char)base) + "(" + base + ")"); } } @@ -306,22 +301,20 @@ private static byte compressedBaseToByte(byte base, final String readName){ * Convert from BAM nybble representation of a base in low-order nybble to ASCII byte. * * @param base One of COMPRESSED_*_LOW, a low-order nybble encoded base. - * @param readName Name of the read containing the base. * @return ASCII base, one of ACGTN=. */ - private static byte compressedBaseToByteLow(final int base, final String readName) { - return compressedBaseToByte((byte)(base & 0xf), readName); + private static byte compressedBaseToByteLow(final int base) { + return compressedBaseToByte((byte)(base & 0xf)); } /** * Convert from BAM nybble representation of a base in high-order nybble to ASCII byte. * * @param base One of COMPRESSED_*_HIGH, a high-order nybble encoded base. - * @param readName Name of the read containing the base. * @return ASCII base, one of ACGTN=. */ - private static byte compressedBaseToByteHigh(final int base, final String readName) { - return compressedBaseToByte((byte)((base >> 4) & 0xf), readName); + private static byte compressedBaseToByteHigh(final int base) { + return compressedBaseToByte((byte)((base >> 4) & 0xf)); } /** @@ -404,7 +397,6 @@ public static char phredToFastq(final int phredScore) { } /** - * * Converts printable qualities in Sanger fastq format to binary phred scores. */ public static void fastqToPhred(final byte[] fastq) { diff --git a/src/test/java/htsjdk/samtools/SAMUtilsTest.java b/src/test/java/htsjdk/samtools/SAMUtilsTest.java index 69d3ec1c9..e3fe72656 100644 --- a/src/test/java/htsjdk/samtools/SAMUtilsTest.java +++ b/src/test/java/htsjdk/samtools/SAMUtilsTest.java @@ -252,7 +252,7 @@ public void testOtherCanonicalAlignments() { public void testBytesToCompressedBases() { final byte[] bases = new byte[]{'=', 'a', 'A', 'c', 'C', 'g', 'G', 't', 'T', 'n', 'N', '.', 'M', 'm', 'R', 'r', 'S', 's', 'V', 'v', 'W', 'w', 'Y', 'y', 'H', 'h', 'K', 'k', 'D', 'd', 'B', 'b'}; - final byte[] compressedBases = SAMUtils.bytesToCompressedBases(bases, "readName"); + final byte[] compressedBases = SAMUtils.bytesToCompressedBases(bases); String expectedCompressedBases = "[1, 18, 36, 72, -113, -1, 51, 85, 102, 119, -103, -86, -69, -52, -35, -18]"; Assert.assertEquals(Arrays.toString(compressedBases), expectedCompressedBases); } @@ -267,11 +267,9 @@ public void testBytesToCompressedBases() { @Test(dataProvider = "testBadBase", expectedExceptions = IllegalArgumentException.class) public void testBytesToCompressedBasesException(final byte[] bases, final char failingBase) { - final String readName = "readName"; try { - SAMUtils.bytesToCompressedBases(bases, readName); + SAMUtils.bytesToCompressedBases(bases); } catch ( final IllegalArgumentException ex ) { - Assert.assertTrue(ex.getMessage().contains(readName)); Assert.assertTrue(ex.getMessage().contains(Character.toString(failingBase))); throw ex; } @@ -280,7 +278,7 @@ public void testBytesToCompressedBasesException(final byte[] bases, final char f @Test public void testCompressedBasesToBytes() { final byte[] compressedBases = new byte[]{1, 18, 36, 72, -113, -1, 51, 85, 102, 119, -103, -86, -69, -52, -35, -18}; - final byte[] bytes = SAMUtils.compressedBasesToBytes(2*compressedBases.length, compressedBases, 0, "readName"); + final byte[] bytes = SAMUtils.compressedBasesToBytes(2*compressedBases.length, compressedBases, 0); final byte[] expectedBases = new byte[]{'=', 'A', 'A', 'C', 'C', 'G', 'G', 'T', 'T', 'N', 'N', 'N', 'M', 'M', 'R', 'R', 'S', 'S', 'V', 'V', 'W', 'W', 'Y', 'Y', 'H', 'H', 'K', 'K', 'D', 'D', 'B', 'B'}; Assert.assertEquals(new String(bytes), new String(expectedBases));