Search in sources :

Example 1 with FastqRecord

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

the class SamToFastqIntegrationTest method createFastqReadHeaderSet.

private Set<String> createFastqReadHeaderSet(final File file) {
    final Set<String> set = new HashSet<>();
    final FastqReader freader = new FastqReader(file);
    while (freader.hasNext()) {
        final FastqRecord frec = freader.next();
        set.add(frec.getReadName());
    }
    return set;
}
Also used : FastqReader(htsjdk.samtools.fastq.FastqReader) FastqRecord(htsjdk.samtools.fastq.FastqRecord)

Example 2 with FastqRecord

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

the class FastqToSam method doUnpaired.

/** Creates a simple SAM file from a single fastq file. */
protected int doUnpaired(final FastqReader freader, final SAMFileWriter writer) {
    int readCount = 0;
    final ProgressLogger progress = new ProgressLogger(LOG);
    for (; freader.hasNext(); readCount++) {
        final FastqRecord frec = freader.next();
        final SAMRecord srec = createSamRecord(writer.getFileHeader(), getReadName(frec.getReadName(), false), frec, false);
        srec.setReadPairedFlag(false);
        writer.addAlignment(srec);
        progress.record(srec);
    }
    writer.close();
    return readCount;
}
Also used : FastqRecord(htsjdk.samtools.fastq.FastqRecord) ProgressLogger(org.broadinstitute.hellbender.utils.runtime.ProgressLogger)

Example 3 with FastqRecord

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

the class SplitReadIdentificationHelperTest method getSplitReadRealignments_should_consider_strand.

@Test
public void getSplitReadRealignments_should_consider_strand() {
    SAMRecord r = Read(0, 1, "2S1M3S");
    r.setReadBases(B("ACGTTC"));
    r.setBaseQualities(B("123456"));
    r.setReadName("r");
    r.setReadNegativeStrandFlag(true);
    List<FastqRecord> result = SplitReadIdentificationHelper.getSplitReadRealignments(r, false, getContext().getEvidenceIDGenerator());
    assertEquals(2, result.size());
    // SSSMSS cigar
    // GAACGT read
    // 654321 base qualities
    // 012345 offset
    assertEquals(getContext().getEvidenceIDGenerator().getAlignmentUniqueName(r) + "#4", result.get(0).getReadName());
    assertEquals("GT", result.get(0).getReadString());
    assertEquals(SAMUtils.phredToFastq(B("21")), result.get(0).getBaseQualityString());
    assertEquals(getContext().getEvidenceIDGenerator().getAlignmentUniqueName(r) + "#0", result.get(1).getReadName());
    assertEquals("GAA", result.get(1).getReadString());
    assertEquals(SAMUtils.phredToFastq(B("654")), result.get(1).getBaseQualityString());
}
Also used : SAMRecord(htsjdk.samtools.SAMRecord) FastqRecord(htsjdk.samtools.fastq.FastqRecord) Test(org.junit.Test)

Example 4 with FastqRecord

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

the class SplitReadIdentificationHelperTest method getSplitReadRealignments_should_split_start.

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

Example 5 with FastqRecord

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

the class SplitReadIdentificationHelperTest method getSplitReadRealignments_should_split_both_ends.

@Test
public void getSplitReadRealignments_should_split_both_ends() {
    SAMRecord r = Read(0, 1, "2S1M3S");
    r.setReadBases(B("ACGTTC"));
    r.setBaseQualities(B("123456"));
    List<FastqRecord> result = SplitReadIdentificationHelper.getSplitReadRealignments(r, false, getContext().getEvidenceIDGenerator());
    assertEquals(2, result.size());
    assertEquals("AC", result.get(0).getReadString());
    assertEquals(SAMUtils.phredToFastq(B("12")), result.get(0).getBaseQualityString());
    assertEquals("TTC", result.get(1).getReadString());
    assertEquals(SAMUtils.phredToFastq(B("456")), result.get(1).getBaseQualityString());
}
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