Cleaning leading insertions

With the current implementation, a read cannot start with a deletion or an insertion. Maybe this will change in the future, but for now, chop the leading insertion off.
This commit is contained in:
Mauricio Carneiro 2011-09-24 14:33:32 -04:00
parent bb11951255
commit c31f4cb2f6
1 changed files with 17 additions and 2 deletions

View File

@ -1,7 +1,6 @@
package org.broadinstitute.sting.utils.clipreads;
import com.google.java.contract.Requires;
import net.sf.samtools.Cigar;
import net.sf.samtools.CigarElement;
import net.sf.samtools.CigarOperator;
import net.sf.samtools.SAMRecord;
@ -9,7 +8,6 @@ import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.sam.ReadUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@ -185,4 +183,21 @@ public class ReadClipper {
}
}
}
public SAMRecord hardClipLeadingInsertions() {
for(CigarElement cigarElement : read.getCigar().getCigarElements()) {
if (cigarElement.getOperator() != CigarOperator.HARD_CLIP && cigarElement.getOperator() != CigarOperator.SOFT_CLIP &&
cigarElement.getOperator() != CigarOperator.INSERTION && cigarElement.getOperator() != CigarOperator.DELETION)
break;
else if (cigarElement.getOperator() == CigarOperator.INSERTION) {
this.addOp(new ClippingOp(0, cigarElement.getLength() - 1));
}
else if (cigarElement.getOperator() == CigarOperator.DELETION) {
throw new ReviewedStingException("No read should start with a deletion. Aligner bug?");
}
}
return clipRead(ClippingRepresentation.HARDCLIP_BASES);
}
}