Skip to content

Commit

Permalink
Removed support for representing tandem duplications as negative CIGA…
Browse files Browse the repository at this point in the history
…R elements due to API change in htsjdk
  • Loading branch information
d-cameron committed Nov 21, 2017
1 parent 148c8bb commit fa80c18
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>au.edu.wehi</groupId>
<artifactId>gridss</artifactId>
<packaging>jar</packaging>
<version>1.5.0-SNAPSHOT</version>
<version>1.5.0</version>
<name>gridss</name>
<url>https://github.com/PapenfussLab/gridss</url>
<properties>
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/au/edu/wehi/idsv/AssemblyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ 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. "
+ "Sanity check failure: this should not be possible for positional assembly. ");
}
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));
Expand Down Expand Up @@ -199,12 +199,13 @@ private static void truncateAnchorToContigBounds(ProcessingContext processContex
if (r.getAlignmentStart() < 1) {
int basesToTruncate = 1 - r.getAlignmentStart();
ArrayList<CigarElement> 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();
Expand All @@ -221,12 +222,13 @@ private static void truncateAnchorToContigBounds(ProcessingContext processContex
int basesToTruncate = r.getAlignmentEnd() - end;
ArrayList<CigarElement> 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();
Expand Down
1 change: 0 additions & 1 deletion src/test/java/au/edu/wehi/idsv/Manual.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions src/test/java/au/edu/wehi/idsv/sam/CigarUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit fa80c18

Please sign in to comment.