use of au.edu.wehi.idsv.SingleReadEvidence in project gridss by PapenfussLab.
the class SupportNodeIterator method addSupport.
private boolean addSupport(List<KmerSupportNode> supportNodes, DirectedEvidence de, KmerEvidence e) {
boolean hasNonReference = false;
if (e != null) {
for (int i = 0; i < e.length(); i++) {
KmerSupportNode support = e.node(i);
if (support != null) {
// make sure that we are actually able to resort into kmer order
if (support.firstStart() < de.getBreakendSummary().start - maxSupportStartPositionOffset) {
SAMRecord read = null;
if (de instanceof SingleReadEvidence) {
read = ((SingleReadEvidence) de).getSAMRecord();
} else if (de instanceof NonReferenceReadPair) {
read = ((NonReferenceReadPair) de).getLocalledMappedRead();
}
String readString = "";
if (read != null) {
readString = read.getReadName();
if (!read.getReadUnmappedFlag()) {
readString += String.format(" (%s:%d %s)", read.getReferenceName(), read.getStart(), read.getCigarString());
}
}
String msg = String.format("Error: kmer in evidence %s of read %s out of bounds." + " Kmer support starts at %d which is more than %d before the breakpoint start position at %s", de.getEvidenceID(), readString, support.firstStart(), maxSupportStartPositionOffset, de.getBreakendSummary());
log.error(msg);
// Try to continue
// throw new RuntimeException(msg);
} else if (support.weight() <= 0) {
String msg = String.format("Invalid support weight of %d for evidence %s", support.weight(), de.getEvidenceID());
log.error(msg);
throw new RuntimeException(msg);
} else {
supportNodes.add(support);
hasNonReference |= !support.isReference();
}
}
}
}
return hasNonReference;
}
use of au.edu.wehi.idsv.SingleReadEvidence in project gridss by PapenfussLab.
the class PositionalAssemblerTest method should_assemble_simple_forward_soft_clips.
@Test
public void should_assemble_simple_forward_soft_clips() {
ProcessingContext pc = getContext();
pc.getAssemblyParameters().anchorLength = 1;
AssemblyEvidenceSource aes = AES(pc);
pc.getAssemblyParameters().k = 4;
List<DirectedEvidence> input = new ArrayList<DirectedEvidence>();
// 12345678901234567890
// ACGTTGGTTA
// MMMMMSSSSS
// GCAACGTTGGTTAA
// MMMMMMMMSSSSSS
input.add(SCE(FWD, withSequence("ACGTTGGTTA", Read(0, 10, "5M5S"))[0]));
input.add(SCE(FWD, withSequence("TTTTTGCAACGTTGGTTAA", Read(0, 2, "13M6S"))[0]));
input.sort(DirectedEvidenceOrder.ByStartEnd);
List<SingleReadEvidence> r = asAssemblyEvidence(aes, Lists.newArrayList(new PositionalAssembler(pc, aes, new SequentialIdGenerator("asm"), input.iterator())));
assertEquals(1, r.size());
assertEquals(new BreakendSummary(0, FWD, 14), r.get(0).getBreakendSummary());
// anchor length to match breakend length
assertEquals("AACGTT", S(r.get(0).getAnchorSequence()));
assertEquals("GGTTAA", S(r.get(0).getBreakendSequence()));
assertEquals("AACGTTGGTTAA", S(r.get(0).getSAMRecord().getReadBases()));
}
use of au.edu.wehi.idsv.SingleReadEvidence in project gridss by PapenfussLab.
the class PositionalAssemblerTest method rp_anchor_should_set_non_reference_bases_as_anchoring.
@Test
public void rp_anchor_should_set_non_reference_bases_as_anchoring() {
ProcessingContext pc = getContext();
pc.getAssemblyParameters().anchorLength = 1;
AssemblyEvidenceSource aes = AES(pc);
pc.getAssemblyParameters().k = 4;
List<DirectedEvidence> input = new ArrayList<DirectedEvidence>();
// 12345678901234567890
// ACGTTGGTTA
// MMMMMSSSSS
// GCAACGTTGGTTAA
// MMMMMMMMSSSSSS
// TTTTTGCAACGTTGGTTAA
input.add(SCE(FWD, withSequence("ACGTTGGTTA", Read(0, 10, "5M5S"))[0]));
input.add(SCE(FWD, withSequence("TTTTTGCAACGTTGGTTAA", Read(0, 2, "13M6S"))[0]));
input.add(NRRP(withSequence("TTTTTGCAACGTTGGTTAA", DP(0, 2, "13M6S", true, 1, 1, "19M", false))));
input.sort(DirectedEvidenceOrder.ByStartEnd);
List<SingleReadEvidence> r = asAssemblyEvidence(aes, Lists.newArrayList(new PositionalAssembler(pc, aes, new SequentialIdGenerator("asm"), input.iterator())));
assertEquals(2, r.size());
// race condition w.r.t which assembly returns first
assertEquals(new BreakendSummary(0, FWD, 14), r.get(0).getBreakendSummary());
// anchor length to match breakend length
assertEquals("AACGTT", S(r.get(0).getAnchorSequence()));
assertEquals("GGTTAA", S(r.get(0).getBreakendSequence()));
assertEquals("AACGTTGGTTAA", S(r.get(0).getSAMRecord().getReadBases()));
}
use of au.edu.wehi.idsv.SingleReadEvidence in project gridss by PapenfussLab.
the class AnnotateVariants method writeAssemblyBreakends.
public static void writeAssemblyBreakends(File file, AssemblyEvidenceSource assemblyEvidence) throws IOException {
log.info("Writing breakend assembly support.");
File tmp = gridss.Defaults.OUTPUT_TO_TEMP_FILE ? FileSystemContext.getWorkingFileFor(file) : file;
try (BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(tmp))) {
try (CloseableIterator<DirectedEvidence> it = assemblyEvidence.iterator()) {
while (it.hasNext()) {
SingleReadEvidence ass = (SingleReadEvidence) it.next();
if (!ass.getSAMRecord().isSecondaryOrSupplementary()) {
writer.write('>');
writer.write(ass.getEvidenceID().getBytes(StandardCharsets.US_ASCII));
writer.write('\n');
if (ass.getBreakendSummary().direction == BreakendDirection.Forward) {
writer.write(ass.getAnchorSequence(), 0, ass.getAnchorSequence().length);
writer.write(ass.getBreakendSequence(), 0, ass.getBreakendSequence().length);
} else {
writer.write(ass.getBreakendSequence(), 0, ass.getBreakendSequence().length);
writer.write(ass.getAnchorSequence(), 0, ass.getAnchorSequence().length);
}
writer.write('\n');
}
}
}
}
if (tmp != file) {
Files.move(tmp, file);
}
log.info("Writing breakend assembly support complete.");
}
Aggregations