Merge branch 'master' of ssh://gsa1/humgen/gsa-scr1/gsa-engineering/git/unstable
This commit is contained in:
commit
bb11951255
|
|
@ -59,7 +59,7 @@ public class LowMemoryIntervalSharder implements Iterator<FilePointer> {
|
||||||
*/
|
*/
|
||||||
public FilePointer next() {
|
public FilePointer next() {
|
||||||
FilePointer current = wrappedIterator.next();
|
FilePointer current = wrappedIterator.next();
|
||||||
while(wrappedIterator.hasNext() && current.minus(wrappedIterator.peek()) == 0)
|
while(wrappedIterator.hasNext() && current.isRegionUnmapped == wrappedIterator.peek().isRegionUnmapped && current.minus(wrappedIterator.peek()) == 0)
|
||||||
current = current.combine(parser,wrappedIterator.next());
|
current = current.combine(parser,wrappedIterator.next());
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,9 @@ public class ClippingOp {
|
||||||
|
|
||||||
for (int i = 1; i <= 2; i++) {
|
for (int i = 1; i <= 2; i++) {
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
|
int totalHardClip = 0;
|
||||||
boolean readHasStarted = false;
|
boolean readHasStarted = false;
|
||||||
|
boolean addedHardClips = false;
|
||||||
|
|
||||||
while(!cigarStack.empty()) {
|
while(!cigarStack.empty()) {
|
||||||
CigarElement cigarElement = cigarStack.pop();
|
CigarElement cigarElement = cigarStack.pop();
|
||||||
|
|
@ -408,14 +410,33 @@ public class ClippingOp {
|
||||||
cigarElement.getOperator() != CigarOperator.DELETION &&
|
cigarElement.getOperator() != CigarOperator.DELETION &&
|
||||||
cigarElement.getOperator() != CigarOperator.HARD_CLIP)
|
cigarElement.getOperator() != CigarOperator.HARD_CLIP)
|
||||||
readHasStarted = true;
|
readHasStarted = true;
|
||||||
|
|
||||||
|
else if ( !readHasStarted && cigarElement.getOperator() == CigarOperator.HARD_CLIP)
|
||||||
|
totalHardClip += cigarElement.getLength();
|
||||||
|
|
||||||
else if ( !readHasStarted && cigarElement.getOperator() == CigarOperator.INSERTION)
|
else if ( !readHasStarted && cigarElement.getOperator() == CigarOperator.INSERTION)
|
||||||
shift += cigarElement.getLength();
|
shift += cigarElement.getLength();
|
||||||
|
|
||||||
if (readHasStarted || cigarElement.getOperator() == CigarOperator.HARD_CLIP) {
|
else if ( !readHasStarted && cigarElement.getOperator() == CigarOperator.DELETION)
|
||||||
if (i==1)
|
totalHardClip += cigarElement.getLength();
|
||||||
|
|
||||||
|
if (readHasStarted) {
|
||||||
|
if (i==1) {
|
||||||
|
if (!addedHardClips) {
|
||||||
|
if (totalHardClip > 0)
|
||||||
|
inverseCigarStack.push(new CigarElement(totalHardClip, CigarOperator.HARD_CLIP));
|
||||||
|
addedHardClips = true;
|
||||||
|
}
|
||||||
inverseCigarStack.push(cigarElement);
|
inverseCigarStack.push(cigarElement);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
if (!addedHardClips) {
|
||||||
|
if (totalHardClip > 0)
|
||||||
|
cleanCigar.add(new CigarElement(totalHardClip, CigarOperator.HARD_CLIP));
|
||||||
|
addedHardClips = true;
|
||||||
|
}
|
||||||
cleanCigar.add(cigarElement);
|
cleanCigar.add(cigarElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// first pass (i=1) is from end to start of the cigar elements
|
// first pass (i=1) is from end to start of the cigar elements
|
||||||
|
|
@ -434,7 +455,6 @@ public class ClippingOp {
|
||||||
private int calculateAlignmentStartShift(Cigar oldCigar, Cigar newCigar) {
|
private int calculateAlignmentStartShift(Cigar oldCigar, Cigar newCigar) {
|
||||||
int newShift = 0;
|
int newShift = 0;
|
||||||
int oldShift = 0;
|
int oldShift = 0;
|
||||||
int deletionShift = 0;
|
|
||||||
|
|
||||||
for (CigarElement cigarElement : newCigar.getCigarElements()) {
|
for (CigarElement cigarElement : newCigar.getCigarElements()) {
|
||||||
if (cigarElement.getOperator() == CigarOperator.HARD_CLIP || cigarElement.getOperator() == CigarOperator.SOFT_CLIP)
|
if (cigarElement.getOperator() == CigarOperator.HARD_CLIP || cigarElement.getOperator() == CigarOperator.SOFT_CLIP)
|
||||||
|
|
@ -449,34 +469,19 @@ public class ClippingOp {
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return newShift - oldShift;
|
||||||
int basesClipped = 0;
|
|
||||||
for (CigarElement cigarElement : oldCigar.getCigarElements()) {
|
|
||||||
if (basesClipped > newShift) // are we beyond the clipped region?
|
|
||||||
break;
|
|
||||||
|
|
||||||
else if (cigarElement.getOperator() == CigarOperator.DELETION) // if this is a deletion, we have to adjust the starting shift
|
|
||||||
deletionShift += cigarElement.getLength();
|
|
||||||
|
|
||||||
else
|
|
||||||
basesClipped += cigarElement.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
return newShift - oldShift + deletionShift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateHardClippingAlignmentShift(CigarElement cigarElement, int clippedLength) {
|
private int calculateHardClippingAlignmentShift(CigarElement cigarElement, int clippedLength) {
|
||||||
if (cigarElement.getOperator() == CigarOperator.INSERTION) {
|
// Insertions should be discounted from the total hard clip count
|
||||||
int cigarElementLength = cigarElement.getLength();
|
if (cigarElement.getOperator() == CigarOperator.INSERTION)
|
||||||
if (clippedLength >= cigarElementLength)
|
return -clippedLength;
|
||||||
return -cigarElement.getLength();
|
|
||||||
else
|
|
||||||
return -clippedLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (cigarElement.getOperator() == CigarOperator.DELETION)
|
// Deletions should be added to the total hard clip count
|
||||||
// return cigarElement.getLength();
|
else if (cigarElement.getOperator() == CigarOperator.DELETION)
|
||||||
|
return cigarElement.getLength();
|
||||||
|
|
||||||
|
// There is no shift if we are not clipping an indel
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue