use of au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter in project gridss by PapenfussLab.
the class ExtractSVReadsTest method regression_should_extract_split_read_alignments_as_group_2.
// @Test
@Category(Hg38Tests.class)
public void regression_should_extract_split_read_alignments_as_group_2() throws IOException {
File ref = Hg38Tests.findHg38Reference();
ReferenceLookup lookup = new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref));
Files.copy(new File("src/test/resources/sa.split/test2.sam"), input);
ExtractSVReads extract = new ExtractSVReads();
// new ProcessingContext(getFSContext(), ref, lookup, null, getConfig());
extract.setReference(lookup);
extract.MIN_CLIP_LENGTH = 4;
extract.INSERT_SIZE_METRICS = new File("src/test/resources/sa.split/test.insert_size_metrics");
extract.READ_PAIR_CONCORDANCE_METHOD = ReadPairConcordanceMethod.PERCENTAGE;
extract.OUTPUT = output;
extract.INPUT = input;
try (SamReader reader = SamReaderFactory.make().open(input)) {
extract.setup(reader.getFileHeader(), input);
}
List<SAMRecord> records = getRecords(input);
List<Boolean> result = records.stream().map(r -> extract.shouldExtract(ImmutableList.of(r), lookup)[0]).collect(Collectors.toList());
/*
for (int i = 0; i < records.size(); i++) {
SAMRecord r = records.get(i);
System.out.print(r.getSupplementaryAlignmentFlag() ? "S" : " ");
System.out.print(r.getFirstOfPairFlag() ? "1" : "2");
System.out.print(" Extracted=" + (result.get(i) ? "y" : "n"));
System.out.print(" HasConcPair=" + (ExtractSVReads.hasReadPairingConsistentWithReference(extract.getReadPairConcordanceCalculator(), ImmutableList.of(r)) ? "y" : "n"));
boolean[] ra = ExtractSVReads.hasReadAlignmentConsistentWithReference(ImmutableList.of(r));
System.out.print(" HasConcRead=" + (ra[0] ? "y" : "n") + (ra[1] ? "y" : "n"));
System.out.println(" " + new ChimericAlignment(r).toString());
}*/
// primary read pair alignment implies an unexpected library fragment size = extract them all
Assert.assertEquals(ImmutableList.of(true, true, true, true), result);
lookup.close();
}
use of au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter in project gridss by PapenfussLab.
the class SingleReadEvidenceTest method assembly_scoring_should_be_symmetrical.
@Test
@Category(Hg19Tests.class)
public void assembly_scoring_should_be_symmetrical() throws FileNotFoundException {
File sam = new File("src/test/resources/assembly_score_mismatch.sam");
File ref = Hg19Tests.findHg19Reference();
ProcessingContext pc = new ProcessingContext(getFSContext(), ref, new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref)), null, getConfig());
SAMEvidenceSource ses = SES(pc);
SamReader sr = SamReaderFactory.make().open(sam);
List<SAMRecord> in = Lists.newArrayList(sr.iterator());
List<SingleReadEvidence> sreList = in.stream().flatMap(record -> SingleReadEvidence.createEvidence(ses, 0, record).stream()).collect(Collectors.toList());
ImmutableListMultimap<String, SingleReadEvidence> mm = Multimaps.index(sreList, sre -> sre.getSAMRecord().getReadName());
for (Entry<String, Collection<SingleReadEvidence>> entry : mm.asMap().entrySet()) {
float bequal = entry.getValue().iterator().next().getBreakendQual();
float bpqual = ((SplitReadEvidence) entry.getValue().iterator().next()).getBreakpointQual();
for (SingleReadEvidence sre : entry.getValue()) {
assertEquals(bequal, sre.getBreakendQual(), 0);
assertEquals(bpqual, ((SplitReadEvidence) sre).getBreakpointQual(), 0);
}
}
}
use of au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter in project gridss by PapenfussLab.
the class SplitReadEvidenceTest method indel_mismapping_false_positive_assembly_should_not_throw_homology_error.
@Test
@Category(Hg19Tests.class)
public void indel_mismapping_false_positive_assembly_should_not_throw_homology_error() throws IOException {
File ref = Hg19Tests.findHg19Reference();
IndexedFastaSequenceFile indexed = new IndexedFastaSequenceFile(ref);
TemporaryFolder folder = new TemporaryFolder();
folder.create();
ProcessingContext pc = new ProcessingContext(new FileSystemContext(folder.getRoot(), folder.getRoot(), 500000), ref, new SynchronousReferenceLookupAdapter(indexed), new ArrayList<Header>(), getConfig());
// File bam = new File(folder.getRoot(), "input.bam");
// Files.copy(new File("src/test/resources/indel_mismapping_false_positive_assembly.sv.bam"), bam);
SAMEvidenceSource ses = new MockSAMEvidenceSource(pc);
List<SAMRecord> records = IntermediateFilesTest.getRecords(new File("src/test/resources/indel_mismapping_false_positive_assembly.sv.bam"));
for (SAMRecord r : records) {
if ("asm5".equals(r.getReadName())) {
for (SplitReadEvidence e : SplitReadEvidence.create(ses, r)) {
assertTrue(e.isReference());
}
}
}
folder.delete();
}
use of au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter in project gridss by PapenfussLab.
the class SAMEvidenceSourceTest method regression_indel_should_not_throw_exception.
// @Test
@Category(Hg38Tests.class)
public void regression_indel_should_not_throw_exception() throws IOException {
File ref = Hg38Tests.findHg38Reference();
ProcessingContext pc = new ProcessingContext(getFSContext(), ref, new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref)), null, getConfig());
Files.copy(new File("src/test/resources/indelerror.bam"), input);
SAMEvidenceSource source = new SAMEvidenceSource(pc, input, null, 0);
Lists.newArrayList(source.iterator());
}
use of au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter in project gridss by PapenfussLab.
the class Manual method should_not_include_concordant_read_pairs.
// @Test
@Category(Hg38Tests.class)
public void should_not_include_concordant_read_pairs() throws FileNotFoundException {
File sam = new File("W:/hg38debug/D1_S1_L001_R1_001.bam.gridss.working/D1_S1_L001_R1_001.bam");
File ref = Hg38Tests.findHg38Reference();
ProcessingContext pc = new ProcessingContext(getFSContext(), ref, new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref)), null, getConfig());
SAMEvidenceSource ses = new SAMEvidenceSource(pc, sam, null, 0, 0.995);
List<DirectedEvidence> list = ses.iterator().stream().collect(Collectors.toList());
List<DirectedEvidence> reads = list.stream().filter(e -> e instanceof DiscordantReadPair).map(e -> (DiscordantReadPair) e).filter(e -> e.getLocalledMappedRead().getReadName().equals("D00360:95:H2YWMBCXX:1:2107:5758:68093")).collect(Collectors.toList());
Assert.assertEquals(0, reads.size());
}
Aggregations