BedRecord { public static BedRecord valueOf(final String value) { checkNotNull(value); List<String> tokens = Splitter.on("\t").trimResults().splitToList(value); if (tokens.size() < 3) { throw new IllegalArgumentException("value must have at least three fields (chrom, start, end)"); } String chrom = tokens.get(0); long start = Long.parseLong(tokens.get(1)); long end = Long.parseLong(tokens.get(2)); if (tokens.size() == 3) { return new BedRecord(chrom, start, end); } else { String name = tokens.get(3); if (tokens.size() == 4) { return new BedRecord(chrom, start, end, name); } else { String score = tokens.get(4); if (tokens.size() == 5) { return new BedRecord(chrom, start, end, name, score); } else { String strand = tokens.get(5); if (tokens.size() == 6) { return new BedRecord(chrom, start, end, name, score, strand); } if (tokens.size() != 12) { throw new IllegalArgumentException("value is not in BED3, BED4, BED5, BED6 or BED12 format"); } long thickStart = Long.parseLong(tokens.get(6)); long thickEnd = Long.parseLong(tokens.get(7)); String itemRgb = tokens.get(8); int blockCount = Integer.parseInt(tokens.get(9)); long[] blockSizes = parseLongArray(tokens.get(10)); long[] blockStarts = parseLongArray(tokens.get(11)); return new BedRecord(chrom, start, end, name, score, strand, thickStart, thickEnd, itemRgb, blockCount, blockSizes, blockStarts); } } } } private  BedRecord(final Format format, final String chrom, final long start, final long end, final String name, final String score, final String strand,
                     final long thickStart, final long thickEnd, final String itemRgb, final int blockCount, final long[] blockSizes, final long[] blockStarts);  BedRecord(final String chrom, final long start, final long end);  BedRecord(final String chrom, final long start, final long end, final String name);  BedRecord(final String chrom, final long start, final long end, final String name, final String score);  BedRecord(final String chrom, final long start, final long end, final String name, final String score, final String strand);  BedRecord(final String chrom, final long start, final long end, final String name, final String score, final String strand,
                     final long thickStart, final long thickEnd, final String itemRgb, final int blockCount, final long[] blockSizes, final long[] blockStarts); String chrom(); long start(); long end(); String name(); String score(); String strand(); long thickStart(); long thickEnd(); String itemRgb(); int blockCount(); long[] blockSizes(); long[] blockStarts(); Format format(); Range<Long> toRange(); @Override int hashCode(); @Override boolean equals(final Object o); @Override String toString(); static BedRecord valueOf(final String value);  }
@Test(expected=IllegalArgumentException.class) public void testValueOfTooShort() { valueOf("chr1\t11873"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfTooLong() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t11873\t0\t3\t354,109,1189,\t0,739,1347,\thi mom"); }
@Test(expected=NumberFormatException.class) public void testValueOfStartNumberFormatException() { valueOf("chr1\tnot a number\t14409"); }
@Test(expected=NumberFormatException.class) public void testValueOfEndNumberFormatException() { valueOf("chr1\t11873\tnot a number"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfStartLessThanZero() { valueOf("chr1\t-1\t14409"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfEndLessThanZero() { valueOf("chr1\t11873\t-1"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfEndLessThanStart() { valueOf("chr1\t11873\t11870"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfThickStartLessThanZero() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t-1\t11873\t0\t3\t354,109,1189,\t0,739,1347,"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfThickEndLessThanZero() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t-1\t0\t3\t354,109,1189,\t0,739,1347,"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfThickEndLessThanThickStart() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t11872\t0\t3\t354,109,1189,\t0,739,1347,"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfInvalidStrand() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t1"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfBlockCountLessThanZero() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t11873\t0\t-1\t354,109,1189,\t0,739,1347,"); }
@Test(expected=NumberFormatException.class) public void testValueOfBlockSizesNumberFormatException() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t11873\t0\t3\t354,not a number,1189,\t0,739,1347,"); }
@Test(expected=NumberFormatException.class) public void testValueOfBlockStartsNumberFormatException() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t11873\t0\t3\t354,109,1189,\t0,739,not a number,"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfTooManyBlockSizes() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t11873\t0\t3\t354,109,1189,42,\t0,739,1347,"); }
@Test(expected=IllegalArgumentException.class) public void testValueOfTooManyBlockStarts() { valueOf("chr1\t11873\t14409\tuc001aaa.3\t0\t+\t11873\t11873\t0\t3\t354,109,1189,\t0,739,1347,42,"); }