HighScoringPair { public static HighScoringPair valueOf(final String value) { checkNotNull(value); List<String> tokens = Splitter.on("\t").trimResults().splitToList(value); if (tokens.size() != 12) { throw new IllegalArgumentException("value must have twelve fields"); } String source = tokens.get(0).trim(); String target = tokens.get(1).trim(); double percentIdentity = Double.parseDouble(tokens.get(2).trim()); long alignmentLength = Long.parseLong(tokens.get(3).trim()); int mismatches = Integer.parseInt(tokens.get(4).trim()); int gapOpens = Integer.parseInt(tokens.get(5).trim()); long sourceStart = Long.parseLong(tokens.get(6).trim()); long sourceEnd = Long.parseLong(tokens.get(7).trim()); long targetStart = Long.parseLong(tokens.get(8).trim()); long targetEnd = Long.parseLong(tokens.get(9).trim()); double evalue = Double.parseDouble(tokens.get(10).trim()); double bitScore = Double.parseDouble(tokens.get(11).trim()); return new HighScoringPair(source, target, percentIdentity, alignmentLength, mismatches, gapOpens, sourceStart, sourceEnd, targetStart, targetEnd, evalue, bitScore); } HighScoringPair(final String source,
                    final String target,
                    final double percentIdentity,
                    final long alignmentLength,
                    final int mismatches,
                    final int gapOpens,
                    final long sourceStart,
                    final long sourceEnd,
                    final long targetStart,
                    final long targetEnd,
                    final double evalue,
                    final double bitScore); String source(); String target(); double percentIdentity(); long alignmentLength(); int mismatches(); int gapOpens(); long sourceStart(); long sourceEnd(); long targetStart(); long targetEnd(); double evalue(); double bitScore(); @Override String toString(); static HighScoringPair valueOf(final String value);  }
@Test(expected=NullPointerException.class) public void testValueOfNull() { valueOf(null); }
@Test(expected=IllegalArgumentException.class) public void testValueOfInvalid() { valueOf("not\tenough\tcolumns"); }
@Test(expected=NumberFormatException.class) public void testValueOfIllegalNumber() { valueOf("source\ttarget\t99.0\t100\t1\t2\t1\t100\t2\t101\t0.1\tnot-a-number"); }
@Test public void testValueOf() { HighScoringPair highScoringPair = valueOf("source\ttarget\t99.0\t100\t1\t2\t1\t100\t2\t101\t0.1\t1.0"); assertEquals("source", highScoringPair.source()); assertEquals("target", highScoringPair.target()); assertEquals(99.0d, highScoringPair.percentIdentity(), 0.1d); assertEquals(100L, highScoringPair.alignmentLength()); assertEquals(1, highScoringPair.mismatches()); assertEquals(2, highScoringPair.gapOpens()); assertEquals(1L, highScoringPair.sourceStart()); assertEquals(100L, highScoringPair.sourceEnd()); assertEquals(2L, highScoringPair.targetStart()); assertEquals(101L, highScoringPair.targetEnd()); assertEquals(0.1d, highScoringPair.evalue(), 0.1d); assertEquals(1.0d, highScoringPair.bitScore(), 0.1d); assertNotNull(highScoringPair.toString()); }