@Test(expected=FormatException.class) public void testSangerQualities() throws IOException { writeToTempQseq(sangerQseq); split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, sangerQseq.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); reader.next(key, fragment); }
private void qualityConfigTest() throws IOException { writeToTempQseq(sangerQseq); split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, sangerQseq.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); assertTrue(reader.next(key, fragment)); assertEquals("###########################################################################################", fragment.getQuality().toString()); }
@Test public void testNs() throws IOException { writeToTempQseq(nQseq); split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, nQseq.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); boolean found = reader.next(key, fragment); assertTrue(found); assertEquals("NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", fragment.getSequence().toString()); }
@Test public void testIlluminaMetaInfo() throws IOException { writeToTempQseq(illuminaQseq); split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, illuminaQseq.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); boolean found = reader.next(key, fragment); assertTrue(found); assertEquals("EAS139", fragment.getInstrument()); assertEquals(136, fragment.getRunNumber().intValue()); assertNull("flowcell id not null", fragment.getFlowcellId()); assertEquals(2, fragment.getLane().intValue()); assertEquals(5, fragment.getTile().intValue()); assertEquals(1000, fragment.getXpos().intValue()); assertEquals(12850, fragment.getYpos().intValue()); assertEquals(1, fragment.getRead().intValue()); assertEquals(false, fragment.getFilterPassed().booleanValue()); assertNull("control number not null", fragment.getControlNumber()); assertEquals("ATCACG", fragment.getIndexSequence()); }
@Test public void testGzCompressedInput() throws IOException { // write gzip-compressed data GzipCodec codec = new GzipCodec(); PrintWriter qseqOut = new PrintWriter( new BufferedOutputStream( codec.createOutputStream( new FileOutputStream(tempGz) ) ) ); qseqOut.write(twoQseq); qseqOut.close(); // now try to read it split = new FileSplit(new Path(tempGz.toURI().toString()), 0, twoQseq.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); boolean retval = reader.next(key, fragment); assertTrue(retval); assertEquals("ERR020229:10880:1:1:1373:2042:1", key.toString()); assertEquals("TTGGATGATAGGGATTATTTGACTCGAATATTGGAAATAGCTGTTTATATTTTTTAAAAATGGTCTGTAACTGGTGACAGGACGCTTCGAT", fragment.getSequence().toString()); retval = reader.next(key, fragment); assertTrue(retval); assertEquals("ERR020229:10883:1:1:1796:2044:2", key.toString()); assertEquals("TGAGCAGATGTGCTAAAGCTGCTTCTCCCCTAGGATCATTTGTACCTACCAGACTCAGGGAAAGGGGTGAGAATTGGGCCGTGGGGCAAGG", fragment.getSequence().toString()); }
@Test public void testReadStartInMiddle() throws IOException { writeToTempQseq(twoQseq); split = new FileSplit(new Path(tempQseq.toURI().toString()), 10, twoQseq.length() - 10, null); QseqRecordReader reader = new QseqRecordReader(conf, split); assertEquals(oneQseq.length() + 1, reader.getPos()); // The start of the second record. We +1 for the \n that is not in oneQseq assertEquals(0.0, reader.getProgress(), 0.01); boolean retval = reader.next(key, fragment); assertTrue(retval); assertEquals("ERR020229:10883:1:1:1796:2044:2", key.toString()); assertEquals("TGAGCAGATGTGCTAAAGCTGCTTCTCCCCTAGGATCATTTGTACCTACCAGACTCAGGGAAAGGGGTGAGAATTGGGCCGTGGGGCAAGG", fragment.getSequence().toString()); assertEquals("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", fragment.getQuality().toString()); assertEquals(twoQseq.length(), reader.getPos()); // now should be at the end of the data assertEquals(1.0, reader.getProgress(), 0.01); retval = reader.next(key, fragment); assertFalse(retval); }
@Test public void testReadFromStart() throws IOException { QseqRecordReader reader = createReaderForOneQseq(); assertEquals(0, reader.getPos()); assertEquals(0.0, reader.getProgress(), 0.01); boolean retval = reader.next(key, fragment); assertTrue(retval); //System.err.println("in testReadFromStart quality: " + fragment.getQuality().toString()); assertEquals("ERR020229:10880:1:1:1373:2042:1", key.toString()); assertEquals("TTGGATGATAGGGATTATTTGACTCGAATATTGGAAATAGCTGTTTATATTTTTTAAAAATGGTCTGTAACTGGTGACAGGACGCTTCGAT", fragment.getSequence().toString()); assertEquals("###########################################################################################", fragment.getQuality().toString()); assertEquals(oneQseq.length(), reader.getPos()); assertEquals(1.0, reader.getProgress(), 0.01); retval = reader.next(key, fragment); assertFalse(retval); }
@Test public void testProgress() throws IOException { writeToTempQseq(twoQseq); split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, twoQseq.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); assertEquals(0.0, reader.getProgress(), 0.01); reader.next(key, fragment); assertEquals(0.5, reader.getProgress(), 0.01); reader.next(key, fragment); assertEquals(1.0, reader.getProgress(), 0.01); }
@Test public void testSliceEndsBeforeEndOfFile() throws IOException { writeToTempQseq(twoQseq); // slice ends at position 10--i.e. somewhere in the first record. The second record should not be read. split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, 10, null); QseqRecordReader reader = new QseqRecordReader(conf, split); boolean retval = reader.next(key, fragment); assertTrue(retval); assertEquals("ERR020229:10880:1:1:1373:2042:1", key.toString()); assertFalse("QseqRecordReader is reading a record that starts after the end of the slice", reader.next(key, fragment)); }
/** * Added to use mapreduce API. */ public boolean nextKeyValue() throws IOException, InterruptedException { return next(currentKey, currentValue); }
@Test public void testConvertDotInIndexSequence() throws IOException { writeToTempQseq(indexWithUnknown); split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, indexWithUnknown.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); boolean found = reader.next(key, fragment); assertTrue(found); assertEquals("ATCNNG", fragment.getIndexSequence()); }
/** * Added to use mapreduce API. */ public boolean nextKeyValue() throws IOException, InterruptedException { return next(currentKey, currentValue); }
private void verifySkipFailedQC() throws IOException { writeToTempQseq(twoQseq); split = new FileSplit(new Path(tempQseq.toURI().toString()), 0, twoQseq.length(), null); QseqRecordReader reader = new QseqRecordReader(conf, split); boolean found = reader.next(key, fragment); assertTrue(found); assertEquals(2, (int)fragment.getRead()); found = reader.next(key, fragment); assertFalse(found); }
/** * Added to use mapreduce API. */ public boolean nextKeyValue() throws IOException, InterruptedException { return next(currentKey, currentValue); }