def _offset_to_gcoord(read, gcoord):
    """Identify the offset from the 5' end of a pysam.AlignedRead corresponding to a specified coordinate"""
    if read.is_reverse:
        return next((len(read.positions)-idx-1 for (idx, pos) in enumerate(read.positions) if pos == gcoord), None)
    else:
        return next((idx for (idx, pos) in enumerate(read.positions) if pos == gcoord), None)