Skip to content

Commit

Permalink
ready to go
Browse files Browse the repository at this point in the history
  • Loading branch information
SHuang-Broad committed Sep 5, 2017
1 parent f70bfd5 commit 897ef07
Showing 1 changed file with 15 additions and 8 deletions.
Expand Up @@ -76,7 +76,6 @@ public boolean test(final AlignedContig contig) {
/**
* Removes overlap from a designated alignment interval, so that the inverted duplicated reference span is minimal.
* If the two alignment intervals are NOT overlapping, return the original aligned contig.
* For algorithm {@see <a href="https://github.com/broadinstitute/dsde-methods-sv/pull/8"}
*/
private static AlignedContig removeOverlap(final AlignedContig contig) {
final int overlapOnRead = AlignmentInterval.overlapOnContig(contig.alignmentIntervals.get(0),
Expand All @@ -86,12 +85,12 @@ private static AlignedContig removeOverlap(final AlignedContig contig) {
} else {
final AlignmentInterval one = contig.alignmentIntervals.get(0),
two = contig.alignmentIntervals.get(1);
// js is for "the shoot-off reference location of a jump that linked to alignment intervals", and
// jl is for "that jump's landing reference location"
final int js = one.referenceSpan.getEnd(),
jl = two.referenceSpan.getStart();
// jumpStart is for "the starting reference location of a jump that linked two alignment intervals", and
// jumpLandingRefLoc is for "that jump's landing reference location"
final int jumpStartRefLoc = one.referenceSpan.getEnd(),
jumpLandingRefLoc = two.referenceSpan.getStart();
final AlignmentInterval reconstructedOne, reconstructedTwo;
if (js <= jl ^ one.forwardStrand) {
if (jumpStartRefLoc <= jumpLandingRefLoc ^ one.forwardStrand) {
reconstructedOne = one;
reconstructedTwo = clipAlignmentInterval(two, overlapOnRead, false);
} else {
Expand Down Expand Up @@ -167,8 +166,16 @@ static Tuple2<SimpleInterval, Cigar> computeNewRefSpanAndCigar(final AlignmentIn

// deal with cigar first
newMiddleSection.add( new CigarElement(clipLengthOnRead, CigarOperator.S) );
final int a = readBasesConsumed + ce.getLength() - clipLengthOnRead;
if (a!=0) newMiddleSection.add( new CigarElement(a, ce.getOperator().isAlignment() ? CigarOperator.M : CigarOperator.S) );
// # of bases left, for the current operation, after requested clipping is done,
// may be 0 because we probably don't need the entire current operation to have the requested
// number of read bases clipped, e.g. we only 15 more bases from the current operation,
// but its length is 20, then 5 bases should be "left over"
final int leftOverBasesForCurrOp = readBasesConsumed + ce.getLength() - clipLengthOnRead;
if (leftOverBasesForCurrOp!=0) {
newMiddleSection.add(// again note that here we can have only either 'M' or 'I'
new CigarElement(leftOverBasesForCurrOp, ce.getOperator().isAlignment() ? CigarOperator.M
: CigarOperator.S) );
}
newMiddleSection.addAll( cigarElements.subList(idx+1, cigarElements.size()) );

// then deal with ref span
Expand Down

0 comments on commit 897ef07

Please sign in to comment.