Search in sources :

Example 6 with FastqReader

use of htsjdk.samtools.fastq.FastqReader in project gatk by broadinstitute.

the class SamToFastqIntegrationTest method testTrimming.

@Test(dataProvider = "trimmedData")
public void testTrimming(final String samFilename, final int read1Trim, final int read1MaxBases, final int expectedRead1Length, final int read2Trim, final int read2MaxBases, final int expectedRead2Length) throws IOException {
    final File samFile = new File(TEST_DATA_DIR, samFilename);
    final File pair1File = newTempFastqFile("pair1");
    final File pair2File = newTempFastqFile("pair2");
    convertFile(new String[] { "--input", samFile.getAbsolutePath(), "--FASTQ", pair1File.getAbsolutePath(), "--SECOND_END_FASTQ", pair2File.getAbsolutePath(), "--READ1_TRIM", Integer.toString(read1Trim), "--READ1_MAX_BASES_TO_WRITE", Integer.toString(read1MaxBases), "--READ2_TRIM", Integer.toString(read2Trim), "--READ2_MAX_BASES_TO_WRITE", Integer.toString(read2MaxBases) });
    for (final FastqRecord first : new FastqReader(pair1File)) {
        Assert.assertEquals(first.getReadString().length(), expectedRead1Length, "Incorrect read length");
        Assert.assertEquals(first.getBaseQualityString().length(), expectedRead1Length, "Incorrect quality string length");
    }
    for (final FastqRecord second : new FastqReader(pair2File)) {
        Assert.assertEquals(second.getReadString().length(), expectedRead2Length, "Incorrect read length");
        Assert.assertEquals(second.getBaseQualityString().length(), expectedRead2Length, "Incorrect quality string length");
    }
}
Also used : FastqReader(htsjdk.samtools.fastq.FastqReader) FastqRecord(htsjdk.samtools.fastq.FastqRecord) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Aggregations

FastqReader (htsjdk.samtools.fastq.FastqReader)6 FastqRecord (htsjdk.samtools.fastq.FastqRecord)4 File (java.io.File)3 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)2 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)2 Test (org.testng.annotations.Test)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 BeforeClass (org.testng.annotations.BeforeClass)1