@Test public void testEqualsFilterPassed() { frag.setFilterPassed(false); assertFalse(frag.equals(frag2)); frag2.setFilterPassed(false); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsControlNumber() { frag.setControlNumber(314); assertFalse(frag.equals(frag2)); frag2.setControlNumber(314); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsYpos() { frag.setYpos(1234); assertFalse(frag.equals(frag2)); frag2.setYpos(1234); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsRead() { frag.setRead(2); assertFalse(frag.equals(frag2)); frag2.setRead(2); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsTile() { frag.setTile(1000); assertFalse(frag.equals(frag2)); frag2.setTile(1000); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsLane() { frag.setLane(2); assertFalse(frag.equals(frag2)); frag2.setLane(2); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsFlowcellId() { frag.setFlowcellId("id"); assertFalse(frag.equals(frag2)); frag2.setFlowcellId("id"); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsIndexSequence() { frag.setIndexSequence("ABC"); assertFalse(frag.equals(frag2)); frag2.setIndexSequence("ABC"); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsSequence() { frag.getSequence().append("AAAA".getBytes(), 0, 4); assertFalse(frag.equals(frag2)); frag2.getSequence().append("AAAA".getBytes(), 0, 4); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsInstrument() { frag.setInstrument("instrument"); assertFalse(frag.equals(frag2)); frag2.setInstrument("instrument"); assertTrue(frag.equals(frag2)); }
@Test public void testEqualsRunNumber() { frag.setRunNumber(240); assertFalse(frag.equals(frag2)); frag2.setRunNumber(240); assertTrue(frag.equals(frag2)); }
@Test(expected = FormatException.class) public void testConvertQualitySangerUnderRange() { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality(new Text("### ##########################")); SequencedFragment.convertQuality( frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger, FormatConstants.BaseQualityEncoding.Illumina); }
@Test(expected = IllegalArgumentException.class) public void testConvertQualityNoop() { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality(new Text("[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[")); SequencedFragment.convertQuality( frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger, FormatConstants.BaseQualityEncoding.Sanger); }
@Test public void testVerifyQualityIlluminaOutOfRange() { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality(new Text("zzz=zzzzzzzzzzzzzzzzzzzzzzzzzz")); assertEquals( 3, SequencedFragment.verifyQuality( frag.getQuality(), FormatConstants.BaseQualityEncoding.Illumina)); }
@Test public void testVerifyQualitySangerOk() { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality(new Text("##############################")); assertEquals( -1, SequencedFragment.verifyQuality( frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger)); }
@Test public void testConvertQualitySangerToIllumina() { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality(new Text("[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[")); SequencedFragment.convertQuality( frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger, FormatConstants.BaseQualityEncoding.Illumina); assertEquals("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", frag.getQuality().toString()); }
/////////////////////////////////////////////////////////////// // serialization /////////////////////////////////////////////////////////////// private static SequencedFragment cloneBySerialization(SequencedFragment original) throws IOException { ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream(); DataOutputStream dataOutput = new DataOutputStream(outputBuffer); original.write(dataOutput); dataOutput.close(); SequencedFragment newFrag = new SequencedFragment(); newFrag.readFields(new DataInputStream(new ByteArrayInputStream(outputBuffer.toByteArray()))); return newFrag; }
@Test public void testSerializationWithFields() throws IOException { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality(new Text("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")); frag.setInstrument("machine"); frag.setLane(3); frag.setRead(1); frag.setIndexSequence("CAT"); assertEquals(frag, cloneBySerialization(frag)); }
@Test public void testVerifyQualitySangerOutOfRange() { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality( new Text("#############################" + Character.toString((char) 127))); // over range assertEquals( 29, SequencedFragment.verifyQuality( frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger)); frag.setQuality(new Text("##### ########################")); // under range assertEquals( 5, SequencedFragment.verifyQuality( frag.getQuality(), FormatConstants.BaseQualityEncoding.Sanger)); }
@Test(expected = IllegalArgumentException.class) public void testNoNullQuality() { frag.setQuality(null); }
@Test(expected = IllegalArgumentException.class) public void testNoNullSequence() { frag.setSequence(null); }
@Test public void testInitialState() { assertNotNull(frag.getSequence()); assertNotNull(frag.getQuality()); assertNull(frag.getInstrument()); assertNull(frag.getRunNumber()); assertNull(frag.getFlowcellId()); assertNull(frag.getLane()); assertNull(frag.getTile()); assertNull(frag.getXpos()); assertNull(frag.getYpos()); assertNull(frag.getRead()); assertNull(frag.getFilterPassed()); assertNull(frag.getControlNumber()); assertNull(frag.getIndexSequence()); assertNotNull(frag.toString()); }
@Test public void testToString() { String seq = "AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT"; String qual = "##############################"; frag.setSequence(new Text(seq)); frag.setQuality(new Text(qual)); frag.setInstrument("machine"); frag.setRunNumber(123); frag.setFlowcellId("flowcell"); frag.setLane(3); frag.setTile(1001); frag.setXpos(1234); frag.setYpos(4321); frag.setIndexSequence("CAT"); frag.setRead(1); assertEquals( "machine\t123\tflowcell\t3\t1001\t1234\t4321\tCAT\t1\t" + seq + "\t" + qual + "\t1", frag.toString()); }
@Test public void testSerializationWithSeq() throws IOException { frag.setSequence(new Text("AGTAGTAGTAGTAGTAGTAGTAGTAGTAGT")); frag.setQuality(new Text("##############################")); assertEquals(frag, cloneBySerialization(frag)); }