* the last base aligned is computed relative to the end of the read.
*/
int getIndexOfFirstAlignedBase(final SAMRecord rec) {
final List<AlignmentBlock> alignmentBlocks = rec.getAlignmentBlocks();
if (rec.getReadNegativeStrandFlag()) {
final AlignmentBlock alignmentBlock = alignmentBlocks.get(alignmentBlocks.size() - 1);
return rec.getReadLength() - CoordMath.getEnd(alignmentBlock.getReadStart(), alignmentBlock.getLength()) + 1;
} else {
return alignmentBlocks.get(0).getReadStart();
}
}