Added low quality clipping
Clips both tails of a read if the tails are below a given quality threshold (default Q2). *Added special treatment for reads that get completely clipped.
This commit is contained in:
parent
993ecb85da
commit
b135565183
|
|
@ -76,8 +76,8 @@ public class ReadClipper {
|
||||||
int rightClipIndex = read.getReadLength() - 1;
|
int rightClipIndex = read.getReadLength() - 1;
|
||||||
|
|
||||||
// check how far we can clip both sides
|
// check how far we can clip both sides
|
||||||
while (quals[rightClipIndex] <= lowQual) rightClipIndex--;
|
while (rightClipIndex >= 0 && quals[rightClipIndex] <= lowQual) rightClipIndex--;
|
||||||
while (quals[leftClipIndex] <= lowQual) leftClipIndex++;
|
while (leftClipIndex < read.getReadLength() && quals[leftClipIndex] <= lowQual) leftClipIndex++;
|
||||||
|
|
||||||
// if the entire read should be clipped, then return an empty read. (--todo: maybe null is better? testing this for now)
|
// if the entire read should be clipped, then return an empty read. (--todo: maybe null is better? testing this for now)
|
||||||
if (leftClipIndex > rightClipIndex)
|
if (leftClipIndex > rightClipIndex)
|
||||||
|
|
|
||||||
|
|
@ -630,26 +630,51 @@ public class ReadUtils {
|
||||||
* @return the overlap type as described by ReadAndIntervalOverlap enum (see above)
|
* @return the overlap type as described by ReadAndIntervalOverlap enum (see above)
|
||||||
*/
|
*/
|
||||||
public static ReadAndIntervalOverlap getReadAndIntervalOverlapType(SAMRecord read, GenomeLoc interval) {
|
public static ReadAndIntervalOverlap getReadAndIntervalOverlapType(SAMRecord read, GenomeLoc interval) {
|
||||||
|
|
||||||
|
int start = getSoftUnclippedStart(read);
|
||||||
|
int stop = getSoftUnclippedStop(read);
|
||||||
|
|
||||||
if ( (!read.getReferenceName().equals(interval.getContig())) ||
|
if ( (!read.getReferenceName().equals(interval.getContig())) ||
|
||||||
(read.getUnclippedEnd() < interval.getStart()) ||
|
(stop < interval.getStart()) ||
|
||||||
(read.getUnclippedStart() > interval.getStop()) )
|
(start > interval.getStop()) )
|
||||||
return ReadAndIntervalOverlap.NO_OVERLAP;
|
return ReadAndIntervalOverlap.NO_OVERLAP;
|
||||||
|
|
||||||
else if ( (read.getUnclippedStart() >= interval.getStart()) &&
|
else if ( (start >= interval.getStart()) &&
|
||||||
(read.getUnclippedEnd() <= interval.getStop()) )
|
(stop <= interval.getStop()) )
|
||||||
return ReadAndIntervalOverlap.CONTAINED;
|
return ReadAndIntervalOverlap.CONTAINED;
|
||||||
|
|
||||||
else if ( (read.getUnclippedStart() < interval.getStart()) &&
|
else if ( (start < interval.getStart()) &&
|
||||||
(read.getUnclippedEnd() > interval.getStop()) )
|
(stop > interval.getStop()) )
|
||||||
return ReadAndIntervalOverlap.FULL_OVERLAP;
|
return ReadAndIntervalOverlap.FULL_OVERLAP;
|
||||||
|
|
||||||
else if ( (read.getAlignmentStart() < interval.getStart()) )
|
else if ( (start < interval.getStart()) )
|
||||||
return ReadAndIntervalOverlap.LEFT_OVERLAP;
|
return ReadAndIntervalOverlap.LEFT_OVERLAP;
|
||||||
|
|
||||||
else
|
else
|
||||||
return ReadAndIntervalOverlap.RIGHT_OVERLAP;
|
return ReadAndIntervalOverlap.RIGHT_OVERLAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getSoftUnclippedStart(SAMRecord read) {
|
||||||
|
int start = read.getUnclippedStart();
|
||||||
|
for (CigarElement cigarElement : read.getCigar().getCigarElements()) {
|
||||||
|
if (cigarElement.getOperator() == CigarOperator.HARD_CLIP)
|
||||||
|
start += cigarElement.getLength();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getSoftUnclippedStop(SAMRecord read) {
|
||||||
|
int stop = getSoftUnclippedStart(read);
|
||||||
|
for (CigarElement cigarElement : read.getCigar().getCigarElements())
|
||||||
|
if (cigarElement.getOperator().consumesReadBases())
|
||||||
|
stop += cigarElement.getLength();
|
||||||
|
return stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Requires({"refCoord >= read.getAlignmentStart()", "refCoord <= read.getAlignmentEnd()"})
|
@Requires({"refCoord >= read.getAlignmentStart()", "refCoord <= read.getAlignmentEnd()"})
|
||||||
@Ensures({"result >= 0", "result < read.getReadLength()"})
|
@Ensures({"result >= 0", "result < read.getReadLength()"})
|
||||||
public static int getReadCoordinateForReferenceCoordinate(SAMRecord read, int refCoord) {
|
public static int getReadCoordinateForReferenceCoordinate(SAMRecord read, int refCoord) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue