use of au.edu.wehi.idsv.NonReferenceReadPair 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.NonReferenceReadPair in project gridss by PapenfussLab.
the class CallVariantsTest method test_sr_rp_assembly.
@Test
public void test_sr_rp_assembly() throws IOException {
List<DirectedEvidence> in = new ArrayList<DirectedEvidence>();
in.add(SCE(FWD, withSequence("AACCGGTTCTA", Read(0, 15, "5M6S"))));
in.add(SCE(FWD, withSequence("AACCGGTTCTA", Read(0, 15, "6M5S"))));
in.add(NRRP(withSequence("AACCGGTTCTA", DP(0, 1, "11M", true, 1, 100, "11M", false))));
in.add(NRRP(withSequence("AACCGGTTCTA", DP(0, 2, "11M", true, 1, 100, "11M", false))));
List<SAMRecord> insam = in.stream().flatMap(de -> {
if (de instanceof SoftClipEvidence)
return ImmutableList.<SAMRecord>of(((SoftClipEvidence) de).getSAMRecord()).stream();
if (de instanceof NonReferenceReadPair)
return ImmutableList.<SAMRecord>of(((NonReferenceReadPair) de).getNonReferenceRead(), ((NonReferenceReadPair) de).getLocalledMappedRead()).stream();
throw new RuntimeException("NYI");
}).collect(Collectors.toList());
insam.addAll(Lists.newArrayList(RP(0, 1, 100, 10)));
createInput(insam);
File propfile = testFolder.newFile("custom.properties");
try (BufferedWriter writer = new BufferedWriter(new FileWriter(propfile))) {
writer.write("assembly.k=5\n");
writer.write("softclip.minLength=1\n");
writer.write("minAnchorShannonEntropy=0\n");
writer.write("softclip.minAnchorIdentity=0\n");
writer.write("softclip.minAverageQual=0\n");
writer.write("realignment.aligner=\n");
}
File assembly = new File(testFolder.getRoot(), "assembly.bam");
String[] args = new String[] { "INPUT=" + input.toString(), "ASSEMBLY=" + assembly.toString(), "REFERENCE_SEQUENCE=" + reference.toString(), "OUTPUT=" + output.toString(), "TMP_DIR=" + super.testFolder.getRoot().toString(), "WORKING_DIR=" + super.testFolder.getRoot().toString(), "CONFIGURATION_FILE=" + propfile.toString(), "INPUT_MIN_FRAGMENT_SIZE=10", "INPUT_MAX_FRAGMENT_SIZE=100" };
assertEquals(0, new CallVariants().instanceMain(args));
List<SAMRecord> breakendAssemblies = getRecords(assembly);
assertEquals(1, breakendAssemblies.size());
assembly.delete();
}
use of au.edu.wehi.idsv.NonReferenceReadPair in project gridss by PapenfussLab.
the class CallVariantsTest method should_handle_unpaired_libraries.
@Test
public void should_handle_unpaired_libraries() throws IOException {
List<DirectedEvidence> in = new ArrayList<DirectedEvidence>();
in.add(SCE(FWD, withSequence("AACCGGTTCTA", Read(0, 15, "5M6S"))));
List<SAMRecord> insam = in.stream().flatMap(de -> {
if (de instanceof SoftClipEvidence)
return ImmutableList.<SAMRecord>of(((SoftClipEvidence) de).getSAMRecord()).stream();
if (de instanceof NonReferenceReadPair)
return ImmutableList.<SAMRecord>of(((NonReferenceReadPair) de).getNonReferenceRead(), ((NonReferenceReadPair) de).getLocalledMappedRead()).stream();
throw new RuntimeException("NYI");
}).collect(Collectors.toList());
createInput(insam);
File assembly = new File(testFolder.getRoot(), "assembly.bam");
createBAM(assembly, SortOrder.coordinate);
String[] args = new String[] { "INPUT=" + input.toString(), "ASSEMBLY=" + assembly.toString(), "REFERENCE_SEQUENCE=" + reference.toString(), "OUTPUT=" + output.toString(), "TMP_DIR=" + super.testFolder.getRoot().toString(), "WORKING_DIR=" + super.testFolder.getRoot().toString() };
assertEquals(0, new CallVariants().instanceMain(args));
assertTrue(output.exists());
assembly.delete();
}
use of au.edu.wehi.idsv.NonReferenceReadPair in project gridss by PapenfussLab.
the class NonReferenceContigAssemblerTest method should_assembly_UM_into_anchor.
@Test
public void should_assembly_UM_into_anchor() {
ProcessingContext pc = getContext();
pc.getAssemblyParameters().k = 4;
pc.getAssemblyParameters().includePairAnchors = true;
pc.getAssemblyParameters().pairAnchorMismatchIgnoreEndBases = 0;
SAMRecord[] rp = OEA(0, 100, "10M", true);
rp[0].setReadBases(B(S(RANDOM).substring(0, 10)));
rp[1].setReadBases(B(S(RANDOM).substring(2, 12)));
rp[1].setReadNegativeStrandFlag(true);
NonReferenceReadPair nrrp = NRRP(SES(1, 100), rp);
List<SAMRecord> output = go(pc, false, nrrp);
assertEquals(S(RANDOM).substring(0, 12), S(output.get(0).getReadBases()));
assertEquals(0, (int) output.get(0).getReferenceIndex());
assertEquals(100, output.get(0).getAlignmentStart());
assertEquals("10M2S", output.get(0).getCigarString());
}
use of au.edu.wehi.idsv.NonReferenceReadPair in project gridss by PapenfussLab.
the class PathNodeIteratorTest method should_assembly_UM_into_anchor.
@Test
public void should_assembly_UM_into_anchor() {
SAMRecord[] rp = OEA(0, 100, "10M", true);
rp[0].setReadBases(B(S(RANDOM).substring(0, 10)));
rp[1].setReadBases(B(S(RANDOM).substring(5, 15)));
NonReferenceReadPair nrrp = NRRP(SES(1, 100), rp);
List<KmerPathNode> result = asCheckedKPN(4, 100, true, nrrp);
assertCompleteGraph(result, 4);
}
Aggregations