Merge branch 'master' of ssh://gsa2.broadinstitute.org/humgen/gsa-scr1/gsa-engineering/git/unstable
This commit is contained in:
commit
4ea38bbfe8
|
|
@ -37,34 +37,60 @@ public class ClippingOp {
|
||||||
* Clips the bases in read according to this operation's start and stop. Uses the clipping
|
* Clips the bases in read according to this operation's start and stop. Uses the clipping
|
||||||
* representation used is the one provided by algorithm argument.
|
* representation used is the one provided by algorithm argument.
|
||||||
*
|
*
|
||||||
* @param algorithm
|
* @param algorithm clipping algorithm to use
|
||||||
* @param read
|
* @param originalRead the read to be clipped
|
||||||
*/
|
*/
|
||||||
public GATKSAMRecord apply(ClippingRepresentation algorithm, GATKSAMRecord read) {
|
public GATKSAMRecord apply(ClippingRepresentation algorithm, GATKSAMRecord originalRead) {
|
||||||
|
GATKSAMRecord read;
|
||||||
|
try {
|
||||||
|
read = (GATKSAMRecord) originalRead.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
throw new ReviewedStingException("Where did the clone go?");
|
||||||
|
}
|
||||||
byte[] quals = read.getBaseQualities();
|
byte[] quals = read.getBaseQualities();
|
||||||
byte[] bases = read.getReadBases();
|
byte[] bases = read.getReadBases();
|
||||||
|
byte[] newBases = new byte[bases.length];
|
||||||
|
byte[] newQuals = new byte[quals.length];
|
||||||
|
|
||||||
switch (algorithm) {
|
switch (algorithm) {
|
||||||
// important note:
|
// important note:
|
||||||
// it's not safe to call read.getReadBases()[i] = 'N' or read.getBaseQualities()[i] = 0
|
// it's not safe to call read.getReadBases()[i] = 'N' or read.getBaseQualities()[i] = 0
|
||||||
// because you're not guaranteed to get a pointer to the actual array of bytes in the GATKSAMRecord
|
// because you're not guaranteed to get a pointer to the actual array of bytes in the GATKSAMRecord
|
||||||
case WRITE_NS:
|
case WRITE_NS:
|
||||||
for (int i = start; i <= stop; i++)
|
for (int i = 0; i < bases.length; i++) {
|
||||||
bases[i] = 'N';
|
if (i >= start && i <= stop) {
|
||||||
read.setReadBases(bases);
|
newBases[i] = 'N';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newBases[i] = bases[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read.setReadBases(newBases);
|
||||||
break;
|
break;
|
||||||
case WRITE_Q0S:
|
case WRITE_Q0S:
|
||||||
for (int i = start; i <= stop; i++)
|
for (int i = 0; i < quals.length; i++) {
|
||||||
quals[i] = 0;
|
if (i >= start && i <= stop) {
|
||||||
read.setBaseQualities(quals);
|
newQuals[i] = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newQuals[i] = quals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read.setBaseQualities(newQuals);
|
||||||
break;
|
break;
|
||||||
case WRITE_NS_Q0S:
|
case WRITE_NS_Q0S:
|
||||||
for (int i = start; i <= stop; i++) {
|
for (int i = 0; i < bases.length; i++) {
|
||||||
bases[i] = 'N';
|
if (i >= start && i <= stop) {
|
||||||
quals[i] = 0;
|
newQuals[i] = 0;
|
||||||
|
newBases[i] = 'N';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newQuals[i] = quals[i];
|
||||||
|
newBases[i] = bases[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
read.setReadBases(bases);
|
read.setBaseQualities(newBases);
|
||||||
read.setBaseQualities(quals);
|
read.setReadBases(newBases);
|
||||||
break;
|
break;
|
||||||
case HARDCLIP_BASES:
|
case HARDCLIP_BASES:
|
||||||
read = hardClip(read, start, stop);
|
read = hardClip(read, start, stop);
|
||||||
|
|
@ -437,8 +463,8 @@ public class ClippingOp {
|
||||||
* Checks if a hard clipped cigar left a read starting or ending with insertions/deletions
|
* Checks if a hard clipped cigar left a read starting or ending with insertions/deletions
|
||||||
* and cleans it up accordingly.
|
* and cleans it up accordingly.
|
||||||
*
|
*
|
||||||
* @param cigar
|
* @param cigar the original cigar
|
||||||
* @return
|
* @return an object with the shifts (see CigarShift class)
|
||||||
*/
|
*/
|
||||||
private CigarShift cleanHardClippedCigar(Cigar cigar) {
|
private CigarShift cleanHardClippedCigar(Cigar cigar) {
|
||||||
Cigar cleanCigar = new Cigar();
|
Cigar cleanCigar = new Cigar();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue