use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class SplitReadEvidenceTest method involvesPrimaryReadAlignment_should_allow_primary_local.
@Test
public void involvesPrimaryReadAlignment_should_allow_primary_local() {
List<SingleReadEvidence> list;
SAMRecord r = Read(0, 1, "10M10S");
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 SplitReadEvidence method getRemoteEvidenceID.
@Override
public String getRemoteEvidenceID() {
SAMRecord remote = this.getSAMRecord().deepCopy();
remote.setReferenceName(remoteAlignment.rname);
remote.setAlignmentStart(remoteAlignment.pos);
remote.setReadUnmappedFlag(false);
remote.setReadNegativeStrandFlag(remoteAlignment.isNegativeStrand);
remote.setCigar(remoteAlignment.cigar);
remote.setAttribute(SAMTag.SA.name(), new ChimericAlignment(this.getSAMRecord()).toString());
SplitReadEvidence remoteEvidence = SplitReadEvidence.create(source, remote).get(0);
return source.getContext().getEvidenceIDGenerator().getEvidenceID(remoteEvidence);
}
use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class SplitReadEvidence method getBreakpointQual.
@Override
public float getBreakpointQual() {
if (AssemblyAttributes.isAssembly(getSAMRecord())) {
return scoreAssembly();
}
int softClipLength = getBreakendSequence().length;
if (getSAMRecord().getSupplementaryAlignmentFlag()) {
ChimericAlignment caThis = new ChimericAlignment(getSAMRecord());
// The first record should be the primary
ChimericAlignment caPrimary = ChimericAlignment.getChimericAlignments(getSAMRecord()).get(0);
// before
BreakendDirection primaryDirectionTowardThis = caThis.getFirstAlignedBaseReadOffset() < caPrimary.getFirstAlignedBaseReadOffset() ^ caPrimary.isNegativeStrand ? BreakendDirection.Backward : BreakendDirection.Forward;
softClipLength = SAMRecordUtil.getSoftClipLength(caPrimary.cigar.getCigarElements(), primaryDirectionTowardThis);
}
return (float) getEvidenceSource().getContext().getConfig().getScoring().getModel().scoreSplitRead(getEvidenceSource().getMetrics(), softClipLength, getLocalMapq(), getRemoteMapq());
}
use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class ExtractSVReadsTest method regression_should_extract_split_read_alignments_as_group.
// @Test
@Category(Hg38Tests.class)
public void regression_should_extract_split_read_alignments_as_group() throws IOException {
File ref = Hg38Tests.findHg38Reference();
ReferenceLookup lookup = new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref));
Files.copy(new File("src/test/resources/sa.split/test1.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());
}
*/
Assert.assertEquals(records.stream().map(r -> r.getSecondOfPairFlag()).collect(Collectors.toList()), result);
lookup.close();
}
use of au.edu.wehi.idsv.sam.ChimericAlignment in project gridss by PapenfussLab.
the class ExtractSVReadsTest method hasReadPairingConsistentWithReference_should_use_primary_alignment_for_split_alignments.
@Test
public void hasReadPairingConsistentWithReference_should_use_primary_alignment_for_split_alignments() {
SAMRecord r = Read(0, 1, "5M5S");
r.setAttribute("SA", new ChimericAlignment(Read(1, 50, "10M")).toString());
r.setMateAlignmentStart(100);
r.setMateNegativeStrandFlag(true);
r.setMateReferenceIndex(1);
r.setReadPairedFlag(true);
r.setMateUnmappedFlag(false);
r.setSupplementaryAlignmentFlag(true);
Assert.assertTrue(ExtractSVReads.hasReadPairingConsistentWithReference(new FixedSizeReadPairConcordanceCalculator(0, 100), ImmutableList.of(r)));
}
Aggregations