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");
}
}
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());
}
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());
}
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());
}
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));
}
Aggregations