Fixed hard clipped cigar and alignment start
* Hard clipped Cigar now includes all insertions that were hard clipped and not the deletions. * The alignment start is now recalculated according to the new hard clipped cigar representation
This commit is contained in:
parent
4e9020c9f7
commit
1acf7945c5
|
|
@ -458,7 +458,7 @@ public class ClippingOp {
|
|||
else if (cigarElement.getOperator() == CigarOperator.DELETION) // if this is a deletion, we have to adjust the starting shift
|
||||
deletionShift += cigarElement.getLength();
|
||||
|
||||
else if (cigarElement.getOperator() != CigarOperator.INSERTION) // if it's not an insertion or deletion, than it counts as hard clipped base.
|
||||
else
|
||||
basesClipped += cigarElement.getLength();
|
||||
}
|
||||
|
||||
|
|
@ -474,8 +474,8 @@ public class ClippingOp {
|
|||
return -clippedLength;
|
||||
}
|
||||
|
||||
if (cigarElement.getOperator() == CigarOperator.DELETION)
|
||||
return cigarElement.getLength();
|
||||
// if (cigarElement.getOperator() == CigarOperator.DELETION)
|
||||
// return cigarElement.getLength();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,21 +71,21 @@ public class ReadClipper {
|
|||
|
||||
private SAMRecord hardClipByReferenceCoordinates(int refStart, int refStop) {
|
||||
int start = (refStart < 0) ? 0 : ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStart);
|
||||
int stop = (refStop < 0) ? read.getReadLength() - 1: ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStop);
|
||||
int stop = (refStop < 0) ? read.getReadLength() - 1 : ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStop);
|
||||
|
||||
if (start < 0 || stop > read.getReadLength() - 1 + numDeletions(read))
|
||||
if (start < 0 || stop > read.getReadLength() - 1)
|
||||
throw new ReviewedStingException("Trying to clip before the start or after the end of a read");
|
||||
|
||||
// TODO add check in the Hardclip function
|
||||
if ( start > stop )
|
||||
stop = ReadUtils.getReadCoordinateForReferenceCoordinate(read, ReadUtils.getRefCoordSoftUnclippedEnd(read));
|
||||
|
||||
if ( start > stop ) {
|
||||
// stop = ReadUtils.getReadCoordinateForReferenceCoordinate(read, ReadUtils.getRefCoordSoftUnclippedEnd(read));
|
||||
throw new ReviewedStingException("START > STOP -- this should never happen -- call Mauricio!");
|
||||
}
|
||||
|
||||
//This tries to fix the bug where the deletion is counted a read base and as a result, the hardCLipper runs into
|
||||
//an endless loop when hard clipping the cigar string because the read coordinates are not covered by the read
|
||||
stop -= numDeletions(read);
|
||||
if ( start > stop )
|
||||
start -= numDeletions(read);
|
||||
// stop -= numDeletions(read);
|
||||
// if ( start > stop )
|
||||
// start -= numDeletions(read);
|
||||
|
||||
|
||||
//System.out.println("Clipping start/stop: " + start + "/" + stop);
|
||||
|
|
|
|||
Loading…
Reference in New Issue