Search in sources :

Example 6 with FastqRecord

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

the class SamToFastqIntegrationTest method testClipping.

@Test(dataProvider = "clippingTests")
public void testClipping(final String clippingAction, final String bases1_1, final String quals1_1, final String bases1_2, final String quals1_2, final String bases2_1, final String quals2_1, final String bases2_2, final String quals2_2, final String testName) throws IOException {
    final File samFile = new File(TEST_DATA_DIR, CLIPPING_TEST_DATA);
    final File f1 = BaseTest.createTempFile("clippingtest1", "fastq");
    final File f2 = BaseTest.createTempFile("clippingtest2", "fastq");
    if (clippingAction != null) {
        convertFile(new String[] { "-input", samFile.getAbsolutePath(), "--FASTQ", f1.getAbsolutePath(), "--SECOND_END_FASTQ", f2.getAbsolutePath(), "--CLIPPING_ACTION", clippingAction, "--CLIPPING_ATTRIBUTE", "XT" });
    } else {
        convertFile(new String[] { "--input", samFile.getAbsolutePath(), "--FASTQ", f1.getAbsolutePath(), "--SECOND_END_FASTQ", f2.getAbsolutePath() });
    }
    Iterator<FastqRecord> it = new FastqReader(f1).iterator();
    FastqRecord first = it.next();
    Assert.assertEquals(first.getReadString(), bases1_1, testName);
    Assert.assertEquals(first.getBaseQualityString(), quals1_1, testName);
    FastqRecord second = it.next();
    Assert.assertEquals(second.getReadString(), bases1_2, testName);
    Assert.assertEquals(second.getBaseQualityString(), quals1_2, testName);
    it = new FastqReader(f2).iterator();
    first = it.next();
    Assert.assertEquals(first.getReadString(), bases2_1, testName);
    Assert.assertEquals(first.getBaseQualityString(), quals2_1, testName);
    second = it.next();
    Assert.assertEquals(second.getReadString(), bases2_2, testName);
    Assert.assertEquals(second.getBaseQualityString(), quals2_2, testName);
}
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)

Example 7 with FastqRecord

use of htsjdk.samtools.fastq.FastqRecord 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

FastqRecord (htsjdk.samtools.fastq.FastqRecord)7 FastqReader (htsjdk.samtools.fastq.FastqReader)4 File (java.io.File)2 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)2 ProgressLogger (org.broadinstitute.hellbender.utils.runtime.ProgressLogger)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 UserException (org.broadinstitute.hellbender.exceptions.UserException)1