From fa80c1827af5d319f9e344ea42005f55938595fb Mon Sep 17 00:00:00 2001 From: d-cameron Date: Tue, 21 Nov 2017 15:25:34 +1100 Subject: [PATCH] Removed support for representing tandem duplications as negative CIGAR elements due to API change in htsjdk --- pom.xml | 2 +- src/main/java/au/edu/wehi/idsv/AssemblyFactory.java | 12 +++++++----- src/test/java/au/edu/wehi/idsv/Manual.java | 1 - .../idsv/debruijn/positional/KmerEvidenceTest.java | 2 +- .../java/au/edu/wehi/idsv/sam/CigarUtilTest.java | 8 +------- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 1764231f0..3cf738669 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ au.edu.wehi gridss jar - 1.5.0-SNAPSHOT + 1.5.0 gridss https://github.com/PapenfussLab/gridss diff --git a/src/main/java/au/edu/wehi/idsv/AssemblyFactory.java b/src/main/java/au/edu/wehi/idsv/AssemblyFactory.java index 4dc04e82a..04320ad8b 100644 --- a/src/main/java/au/edu/wehi/idsv/AssemblyFactory.java +++ b/src/main/java/au/edu/wehi/idsv/AssemblyFactory.java @@ -160,7 +160,6 @@ private static SAMRecord createAssemblySAMRecord( c.add(new CigarElement(insSize, CigarOperator.INSERTION)); } if (delSize != 0) { - c.add(new CigarElement(delSize, CigarOperator.DELETION)); if (delSize < 0) { if (!MessageThrottler.Current.shouldSupress(log, "negative deletion")) { log.warn("Negative deletions not supported by SAM specs. Breakpoint assembly has been converted to breakend. " @@ -168,6 +167,7 @@ private static SAMRecord createAssemblySAMRecord( } return createAssemblySAMRecord(processContext, assemblyIdGenerator, evidence, samFileHeader, source, bp.localBreakend(), startAnchoredBaseCount, 0, baseCalls, baseQuals); } + c.add(new CigarElement(delSize, CigarOperator.DELETION)); } c.add(new CigarElement(endAnchoredBaseCount, CigarOperator.MATCH_OR_MISMATCH)); record.setCigar(new Cigar(c)); @@ -199,12 +199,13 @@ private static void truncateAnchorToContigBounds(ProcessingContext processContex if (r.getAlignmentStart() < 1) { int basesToTruncate = 1 - r.getAlignmentStart(); ArrayList cigar = new ArrayList<>(r.getCigar().getCigarElements()); - cigar.set(0, new CigarElement(cigar.get(0).getLength() - basesToTruncate, cigar.get(0).getOperator())); - if (cigar.get(0).getLength() < 0) { + int len = cigar.get(0).getLength() - basesToTruncate; + if (len < 0) { if (!MessageThrottler.Current.shouldSupress(log, "truncating assembly to contig bounds")) { log.warn(String.format("Attempted to truncate %d bases from start of %s with CIGAR %s", basesToTruncate, r.getReadName(), r.getCigarString())); } } else { + cigar.set(0, new CigarElement(len, cigar.get(0).getOperator())); r.setAlignmentStart(1); r.setCigar(new Cigar(cigar)); byte[] b = r.getReadBases(); @@ -221,12 +222,13 @@ private static void truncateAnchorToContigBounds(ProcessingContext processContex int basesToTruncate = r.getAlignmentEnd() - end; ArrayList cigar = new ArrayList<>(r.getCigar().getCigarElements()); CigarElement ce = cigar.get(cigar.size() - 1); - ce = new CigarElement(ce.getLength() - basesToTruncate, ce.getOperator()); - if (ce.getLength() < 1) { + int len = ce.getLength() - basesToTruncate; + if (len < 1) { if (!MessageThrottler.Current.shouldSupress(log, "truncating assembly to contig bounds")) { log.warn(String.format("Attempted to truncate %d bases from end of %s with CIGAR %s", basesToTruncate, r.getReadName(), r.getCigarString())); } } else { + ce = new CigarElement(len, ce.getOperator()); cigar.set(cigar.size() - 1, ce); r.setCigar(new Cigar(cigar)); byte[] b = r.getReadBases(); diff --git a/src/test/java/au/edu/wehi/idsv/Manual.java b/src/test/java/au/edu/wehi/idsv/Manual.java index 8954a4451..427df0fed 100644 --- a/src/test/java/au/edu/wehi/idsv/Manual.java +++ b/src/test/java/au/edu/wehi/idsv/Manual.java @@ -10,7 +10,6 @@ import org.apache.commons.configuration.ConfigurationException; import org.junit.Assert; -import org.junit.Test; import org.junit.experimental.categories.Category; import au.edu.wehi.idsv.configuration.GridssConfiguration; diff --git a/src/test/java/au/edu/wehi/idsv/debruijn/positional/KmerEvidenceTest.java b/src/test/java/au/edu/wehi/idsv/debruijn/positional/KmerEvidenceTest.java index 73ab97b46..2f2fb6a89 100644 --- a/src/test/java/au/edu/wehi/idsv/debruijn/positional/KmerEvidenceTest.java +++ b/src/test/java/au/edu/wehi/idsv/debruijn/positional/KmerEvidenceTest.java @@ -306,7 +306,7 @@ public void readpair_breakpoint_contig_bounds_truncation_should_not_affect_kmer_ assertEquals(-3, e.endPosition()); } @Test(expected=NotImplementedException.class) - public void does_not_handling_XNX_unanchored_clips() { + public void does_not_handle_XNX_unanchored_clips() { KmerEvidence.create(2, SCE(BWD, Read(0, 1, "10S1X10N1X"))); } @Test diff --git a/src/test/java/au/edu/wehi/idsv/sam/CigarUtilTest.java b/src/test/java/au/edu/wehi/idsv/sam/CigarUtilTest.java index 1e6317594..d3cb10c59 100644 --- a/src/test/java/au/edu/wehi/idsv/sam/CigarUtilTest.java +++ b/src/test/java/au/edu/wehi/idsv/sam/CigarUtilTest.java @@ -12,7 +12,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import htsjdk.samtools.Cigar; @@ -120,12 +119,7 @@ public void commonReferenceBases_should_count_common() { } @Test public void commonReferenceBases_should_match_unencoded_and_decoded_negative_deletions() { - Cigar c1 = new Cigar(ImmutableList.of( - new CigarElement(2, CigarOperator.M), - new CigarElement(-2, CigarOperator.D), - new CigarElement(2, CigarOperator.M) - )); - assertEquals(4, CigarUtil.commonReferenceBases(c1, new Cigar(C("2M5P5N5P2M")))); + assertEquals(4, CigarUtil.commonReferenceBases(new Cigar(C("2M5D2M")), new Cigar(C("2M2D2M")))); } //@Test public void test_realign_anchor_direction_changing_na12878() throws IOException {