def alignment_to_sequence_coords(self, seq_name, start, end, trim=False):
start = <NUM_LIT:1> if start < <NUM_LIT:1> and trim else start<EOL>end = self.size() + <NUM_LIT:1> if (end > self.size() + <NUM_LIT:1>) and trim else end<EOL>if (start < <NUM_LIT:1> or end > (self.size() + <NUM_LIT:1>)):<EOL><INDENT>msg = "<STR_LIT>" + str(start) +"<STR_LIT:U+002CU+0020>" + str(end)<EOL>raise InvalidAlignmentCoordinatesError(msg)<EOL><DEDENT>if (end < <NUM_LIT:1> or start > self.size() + <NUM_LIT:1>):<EOL><INDENT>msg = "<STR_LIT>" + str(start) +"<STR_LIT:U+002CU+0020>" + str(end)<EOL>raise InvalidAlignmentCoordinatesError(msg)<EOL><DEDENT>if (end <= start):<EOL><INDENT>msg = "<STR_LIT>" + str(start) + "<STR_LIT:U+002CU+0020>" + str(end)<EOL>raise InvalidAlignmentCoordinatesError(msg)<EOL><DEDENT>seq = self[seq_name]<EOL>pos_strand = seq.is_positive_strand()<EOL>non_gaps = <NUM_LIT:0><EOL>r_start = None<EOL>r_end = None<EOL>l_start = <NUM_LIT:0> if pos_strand else self.size() - <NUM_LIT:1><EOL>l_end = end - <NUM_LIT:1> if pos_strand else start - <NUM_LIT:2><EOL>l_step = <NUM_LIT:1> if pos_strand else -<NUM_LIT:1><EOL>for i in range(l_start, l_end, l_step):<EOL><INDENT>if seq[i] != GAP_CHAR:<EOL><INDENT>non_gaps += <NUM_LIT:1><EOL>if ((pos_strand and r_start is None and (i + <NUM_LIT:1>) >= start) or<EOL>(not pos_strand and r_start is None and (i + <NUM_LIT:1>) < end)):<EOL><INDENT>r_start = non_gaps + seq.start - <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>if r_start is None:<EOL><INDENT>return None<EOL><DEDENT>r_end = non_gaps + seq.start<EOL>return (r_start, r_end)<EOL>
convert an interval in the alignmnet into co-ordinates in one of the
sequences. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
length of the alignment (number of columns). Sequence coords follow the
same conventions: one-based, inclusive of start but not end.

:param seq_name: which sequence are the start and end coords for?
:param start:    start of the interval in alignment co-ordinates
:param end:      end of the interval in alignment co-ordinates
:param trim:     if true, trim coordinates that fall partially outside
                 the alignment
:return: a tuple with the start and end sequence coords, in that order;
         None if the interval in the alignment defined by (start, end)
         contains only gaps in the specified sequence. start < end always,
         even if the sequence is reverse complement.
:raises AlignmentError: if the sequence number specifies a sequence not
                        in this alignment, or the coordinates fall
                        entirely outside the alignment (or partially
                        outside and trim == false), or they are not a valid
                        interval (start >= end)