def _map(self, from_pos, to_pos, pos, base):
pos_i = -<NUM_LIT:1><EOL>while pos_i < len(self.cigar_op) and pos >= from_pos[pos_i + <NUM_LIT:1>]:<EOL><INDENT>pos_i += <NUM_LIT:1><EOL><DEDENT>if pos_i == -<NUM_LIT:1> or pos_i == len(self.cigar_op):<EOL><INDENT>raise HGVSInvalidIntervalError("<STR_LIT>")<EOL><DEDENT>if self.cigar_op[pos_i] in "<STR_LIT>":<EOL><INDENT>mapped_pos = to_pos[pos_i] + (pos - from_pos[pos_i])<EOL>mapped_pos_offset = <NUM_LIT:0><EOL><DEDENT>elif self.cigar_op[pos_i] in "<STR_LIT>":<EOL><INDENT>if base == "<STR_LIT:start>":<EOL><INDENT>mapped_pos = to_pos[pos_i] - <NUM_LIT:1><EOL><DEDENT>elif base == "<STR_LIT:end>":<EOL><INDENT>mapped_pos = to_pos[pos_i]<EOL><DEDENT>mapped_pos_offset = <NUM_LIT:0><EOL><DEDENT>elif self.cigar_op[pos_i] == "<STR_LIT:N>":<EOL><INDENT>if pos - from_pos[pos_i] + <NUM_LIT:1> <= from_pos[pos_i + <NUM_LIT:1>] - pos:<EOL><INDENT>mapped_pos = to_pos[pos_i] - <NUM_LIT:1><EOL>mapped_pos_offset = pos - from_pos[pos_i] + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>mapped_pos = to_pos[pos_i]<EOL>mapped_pos_offset = -(from_pos[pos_i + <NUM_LIT:1>] - pos)<EOL><DEDENT><DEDENT>return mapped_pos, mapped_pos_offset, self.cigar_op[pos_i]<EOL>
Map position between aligned sequences

        Positions in this function are 0-based.