use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class SplitReadEvidenceTest method involvesPrimaryReadAlignment_should_allow_primary_remote.
@Test
public void involvesPrimaryReadAlignment_should_allow_primary_remote() {
List<SingleReadEvidence> list;
SAMRecord r = Read(0, 1, "10M10S");
r.setSupplementaryAlignmentFlag(true);
r.setAttribute("SA", new ChimericAlignment(Read(0, 10, "10S10M")).toString());
list = SingleReadEvidence.createEvidence(SES(), 0, r);
assertTrue(list.stream().allMatch(e -> e.involvesPrimaryReadAlignment()));
}
use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class SplitReadEvidenceTest method isReference_should_be_true_if_either_alignment_could_be_moved_to_the_other_breakend.
@Test
public void isReference_should_be_true_if_either_alignment_could_be_moved_to_the_other_breakend() {
SAMRecord r1 = withSequence("TTTAACAA", Read(0, 10, "3M5S"))[0];
SAMRecord r2 = withSequence("TTTAACAA", Read(0, 20, "3S2M3S"))[0];
r1.setAttribute("SA", new ChimericAlignment(r2).toString());
r2.setAttribute("SA", new ChimericAlignment(r1).toString());
SplitReadEvidence e1 = SplitReadEvidence.create(SES(), r1).get(0);
SplitReadEvidence e2 = SplitReadEvidence.create(SES(), r2).get(0);
Assert.assertTrue(e2.isReference());
Assert.assertTrue(e1.isReference());
}
use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class StubFastqAligner method align.
public StubFastqAligner align(SAMRecord r, BreakendDirection direction, int referenceIndex, int pos, boolean isNegativeStrand, String cigar) {
List<FastqRecord> srs = SplitReadIdentificationHelper.getSplitReadRealignments(r, false, eidgen);
FastqRecord fqr = srs.get(0);
if (srs.size() == 2) {
if (direction == BreakendDirection.Forward ^ r.getReadNegativeStrandFlag()) {
fqr = srs.get(1);
}
}
map.put(fqr.getReadName(), new ChimericAlignment(r.getHeader().getSequenceDictionary().getSequence(referenceIndex).getSequenceName(), pos, isNegativeStrand, TextCigarCodec.decode(cigar), 40, 0));
nameLookup.put(fqr.getReadName(), r);
return this;
}
use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class StubFastqAligner method align.
@Override
public void align(File fastq, File output, File reference, int threads) throws IOException {
SAMFileHeader header = context.getBasicSamHeader();
try (FastqReader reader = new FastqReader(fastq)) {
try (SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(header, true, output)) {
for (FastqRecord fqr : reader) {
SAMRecord source = nameLookup.get(fqr.getReadName());
SAMRecord r = new SAMRecord(header);
r.setReadName(fqr.getReadName());
r.setReadBases(fqr.getReadString().getBytes());
r.setBaseQualities(SAMUtils.fastqToPhred(fqr.getBaseQualityString()));
if (source == null) {
r.setReadUnmappedFlag(true);
} else {
ChimericAlignment aln = map.get(fqr.getReadName());
r.setReferenceName(aln.rname);
r.setAlignmentStart(aln.pos);
r.setCigar(aln.cigar);
r.setMappingQuality(aln.mapq);
r.setAttribute("NM", aln.nm);
if (aln.isNegativeStrand) {
SequenceUtil.reverseComplement(r.getReadBases());
ArrayUtils.reverse(r.getBaseQualities());
}
}
writer.addAlignment(r);
}
}
}
}
use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class ExtractSVReadsTest method hasReadAlignmentConsistentWithReference_should_consider_SA_alignments.
/*
@Test
public void should_not_extract_unclipped_alignment_overlapping_blacklist() {
createInput();
IntervalBed blacklist = new IntervalBed(getSequenceDictionary(), new PaddedLinearGenomicCoordinate(getSequenceDictionary()));
blacklist.addInterval(0, 2, 2);
ExtractSVReads extract = new ExtractSVReads();
extract.INPUT = input;
extract.OUTPUT = output;
extract.setBlacklist(blacklist);
extract.setup(getHeader(), extract.INPUT);
extract.acceptFragment(ImmutableList.of(Read(0, 1, "1M1S")), null); // Soft clip breakpoint position overlaps
extract.acceptFragment(ImmutableList.of(Read(0, 2, "1M1S")), null); // overlaps
extract.acceptFragment(ImmutableList.of(Read(0, 3, "1M1S")), null);
extract.acceptFragment(ImmutableList.of(Read(0, 4, "1M1S")), null);
extract.acceptFragment(ImmutableList.of(Read(0, 3, "1S1M")), null); // overlaps
extract.finish();
List<SAMRecord> out = getRecords(output);
assertEquals(2, out.size());
}
@Test
public void should_not_extract_any_read_from_fragment_overlapping_read_pair_breakend() {
createInput();
IntervalBed blacklist = new IntervalBed(getSequenceDictionary(), new PaddedLinearGenomicCoordinate(getSequenceDictionary()));
blacklist.addInterval(0, 2, 2);
ExtractSVReads extract = new ExtractSVReads();
extract.INPUT = input;
extract.OUTPUT = output;
extract.FIXED_READ_PAIR_CONCORDANCE_MAX_FRAGMENT_SIZE = 2;
extract.FIXED_READ_PAIR_CONCORDANCE_MIN_FRAGMENT_SIZE = 2;
extract.READ_PAIR_CONCORDANCE_METHOD = ReadPairConcordanceMethod.FIXED;
extract.setBlacklist(blacklist);
extract.setup(getHeader(), extract.INPUT);
extract.acceptFragment(Lists.newArrayList(DP(0, 1, "1M", true, 1, 1, "1M", false)), null); // breakend overlaps
extract.acceptFragment(Lists.newArrayList(DP(0, 1, "1M", false, 1, 1, "1M", false)), null); // other direction = no overlap
extract.acceptFragment(Lists.newArrayList(DP(0, 2, "1M", true, 1, 1, "1M", false)), null); // read overlaps
extract.acceptFragment(Lists.newArrayList(DP(0, 2, "1M", false, 1, 1, "1M", false)), null); // read overlaps
extract.acceptFragment(Lists.newArrayList(DP(0, 3, "1M", true, 1, 1, "1M", false)), null); // other direction = no overlap
extract.acceptFragment(Lists.newArrayList(DP(0, 3, "1M", false, 1, 1, "1M", false)), null); // breakend overlaps
extract.finish();
List<SAMRecord> out = getRecords(output);
assertEquals(2 * 2, out.size());
}
@Test
public void should_not_extract_any_split_reads_overlapping_blacklist() {
fail();
}
*/
@Test
public void hasReadAlignmentConsistentWithReference_should_consider_SA_alignments() {
SAMRecord r = Read(0, 1, "5M5S");
r.setAttribute("SA", new ChimericAlignment(Read(0, 1, "10M")).toString());
Assert.assertTrue(ExtractSVReads.hasReadAlignmentConsistentWithReference(ImmutableList.of(r))[0]);
}
Aggregations