Search in sources :

Example 26 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)

Example 27 with FastqRecord

use of htsjdk.samtools.fastq.FastqRecord in project gridss by PapenfussLab.

the class SplitReadIdentificationHelperTest method getSplitReadRealignments_should_split_end.

@Test
public void getSplitReadRealignments_should_split_end() {
    SAMRecord r = Read(0, 1, "3M3S");
    r.setReadBases(B("ACGTTC"));
    r.setBaseQualities(B("123456"));
    List<FastqRecord> result = SplitReadIdentificationHelper.getSplitReadRealignments(r, false, getContext().getEvidenceIDGenerator());
    assertEquals(1, result.size());
    assertEquals("TTC", result.get(0).getReadString());
    assertEquals(SAMUtils.phredToFastq(B("456")), result.get(0).getBaseQualityString());
}
Also used : SAMRecord(htsjdk.samtools.SAMRecord) FastqRecord(htsjdk.samtools.fastq.FastqRecord) Test(org.junit.Test)

Example 28 with FastqRecord

use of htsjdk.samtools.fastq.FastqRecord in project gridss by PapenfussLab.

the class SplitReadIdentificationHelperTest method getSplitReadRealignments_name_should_encode_offset_from_start_of_read.

@Test
public void getSplitReadRealignments_name_should_encode_offset_from_start_of_read() {
    SAMRecord r = Read(0, 1, "2S1M3S");
    r.setReadBases(B("ACGTTC"));
    r.setBaseQualities(B("123456"));
    r.setReadName("r");
    List<FastqRecord> result = SplitReadIdentificationHelper.getSplitReadRealignments(r, false, getContext().getEvidenceIDGenerator());
    assertEquals(2, result.size());
    assertEquals(getContext().getEvidenceIDGenerator().getAlignmentUniqueName(r) + "#0", result.get(0).getReadName());
    assertEquals(getContext().getEvidenceIDGenerator().getAlignmentUniqueName(r) + "#3", result.get(1).getReadName());
}
Also used : SAMRecord(htsjdk.samtools.SAMRecord) FastqRecord(htsjdk.samtools.fastq.FastqRecord) Test(org.junit.Test)

Example 29 with FastqRecord

use of htsjdk.samtools.fastq.FastqRecord in project gridss by PapenfussLab.

the class SplitReadIdentificationHelperTest method getSplitReadRealignments_should_chain_realignments.

@Test
public void getSplitReadRealignments_should_chain_realignments() {
    // HHHMSS cigar
    // ???CGT read
    // ???321 base qualities
    // 012345 offset
    SAMRecord r = Read(0, 1, "1M2S");
    r.setReadName("unique#3");
    r.setReadBases(B("CGT"));
    r.setBaseQualities(B("321"));
    List<FastqRecord> result = SplitReadIdentificationHelper.getSplitReadRealignments(r, true, getContext().getEvidenceIDGenerator());
    assertEquals(1, result.size());
    assertEquals("unique#4", result.get(0).getReadName());
    assertEquals("GT", result.get(0).getReadString());
    assertEquals(SAMUtils.phredToFastq(B("21")), result.get(0).getBaseQualityString());
}
Also used : SAMRecord(htsjdk.samtools.SAMRecord) FastqRecord(htsjdk.samtools.fastq.FastqRecord) Test(org.junit.Test)

Example 30 with FastqRecord

use of htsjdk.samtools.fastq.FastqRecord in project gridss by PapenfussLab.

the class StructuralVariationCallBuilderTest method breakpoint_assembly_should_be_local.

@Test
public void breakpoint_assembly_should_be_local() {
    ProcessingContext pc = getContext();
    String seq = "CATTAATCGCAAGAGCGGGTTGTATTCGcCGCCAAGTCAGCTGAAGCACCATTACCCGAtCAAAACATATCAGAAATGATTGACGTATCACAAGCCGGATTTTGTTTACAGCCTGTCTTATATCCTGAATAACGCACCGCCTATTCG";
    int anchor = 78;
    SAMRecord ass = AssemblyFactory.createAnchoredBreakend(getContext(), AES(), new SequentialIdGenerator("asm"), FWD, null, 6, 78, anchor, B(seq), B(40, seq.length()));
    SAMRecord remote = withQual(B(40, seq.length() - anchor), Read(2, anchor + 1, String.format("%dM", seq.length() - anchor)))[0];
    incorporateRealignment(AES(), ass, remote);
    StructuralVariationCallBuilder builder = new StructuralVariationCallBuilder(pc, (VariantContextDirectedEvidence) new IdsvVariantContextBuilder(getContext()) {

        {
            breakpoint(new BreakpointSummary(2, BWD, 79, 6, FWD, 78), "");
            phredScore(50);
        }
    }.make());
    builder.addEvidence(asAssemblyEvidence(remote));
    VariantContextDirectedEvidence e = builder.make();
    FastqRecord fr = e.getBreakendAssemblyFastq();
    assertEquals(null, fr);
    assertEquals(null, e.getAttribute(VcfSvConstants.BREAKPOINT_ID_KEY));
}
Also used : SAMRecord(htsjdk.samtools.SAMRecord) FastqRecord(htsjdk.samtools.fastq.FastqRecord) Test(org.junit.Test)

Aggregations

FastqRecord (htsjdk.samtools.fastq.FastqRecord)40 SAMRecord (htsjdk.samtools.SAMRecord)16 Test (org.junit.Test)12 FastqReader (htsjdk.samtools.fastq.FastqReader)8 File (java.io.File)6 SAMFileHeader (htsjdk.samtools.SAMFileHeader)4 FastqReader (com.github.lindenb.jvarkit.util.picard.FastqReader)3 FourLinesFastqReader (com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader)3 SAMFileWriter (htsjdk.samtools.SAMFileWriter)3 IOException (java.io.IOException)3 Test (org.testng.annotations.Test)3 BufferedReferenceSequenceFile (au.edu.wehi.idsv.picard.BufferedReferenceSequenceFile)2 ChimericAlignment (au.edu.wehi.idsv.sam.ChimericAlignment)2 SAMSequenceDictionaryProgress (com.github.lindenb.jvarkit.util.picard.SAMSequenceDictionaryProgress)2 Cigar (htsjdk.samtools.Cigar)2 CigarElement (htsjdk.samtools.CigarElement)2 SAMFileWriterFactory (htsjdk.samtools.SAMFileWriterFactory)2 SAMRecordIterator (htsjdk.samtools.SAMRecordIterator)2 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)2 ProgressLogger (org.broadinstitute.hellbender.utils.runtime.ProgressLogger)2