def _generate_sequence(self, t1, t1_span, t2, t2_span, context_length,
                           covered_spans):
        """Returns an aligned sequence (or None) between extract `t1_span` of
        witness text `t1` and extract `t2_span` of witness text `t2`.

        Adds the span of the aligned sequence, if any, to
        `covered_spans` (which, being mutable, is modified in place
        without needing to be returned).

        This method repeats the alignment process, increasing the
        context length until the alignment score (the measure of how
        much the two sequences align) drops below a certain point or
        it is not possible to increase the context length.

        :param t1: text content of first witness
        :type t1: `str`
        :param t1_span: start and end indices within `t1` to align
        :type t1_span: 2-`tuple` of `int`
        :param t2: text content of second witness
        :type t2: `str`
        :param t2_span: start and end indices within `t2` to align
        :type t2_span: 2-`tuple` of `int`
        :param context_length: length of context on either side of
                               the spans to include in the sequence
        :type context_length: `int`
        :param covered_spans: lists of start and end indices for parts
                              of the texts already covered by a sequence
        :type covered_spans: `list` of two `list`s of 2-`tuple` of `int`

        """
        old_length = 0
        self._logger.debug('Match found; generating new sequence')
        while True:
            s1, span1 = self._get_text_sequence(t1, t1_span, context_length)
            s2, span2 = self._get_text_sequence(t2, t2_span, context_length)
            length = len(s1)
            alignment = pairwise2.align.globalms(
                s1, s2, constants.IDENTICAL_CHARACTER_SCORE,
                constants.DIFFERENT_CHARACTER_SCORE,
                constants.OPEN_GAP_PENALTY, constants.EXTEND_GAP_PENALTY)[0]
            context_length = length
            score = alignment[2] / length
            if not alignment:
                return None
            elif score < constants.SCORE_THRESHOLD or length == old_length:
                break
            else:
                self._logger.debug('Score: {}'.format(score))
            old_length = length
        covered_spans[0].append(span1)
        covered_spans[1].append(span2)
        return Sequence(alignment, self._reverse_substitutes, t1_span[0])
def _generate_sequence ( self , t1 , t1_span , t2 , t2_span , context_length , covered_spans ) : old_length = 0 self . _logger . debug ( 'Match found; generating new sequence' ) while True : s1 , span1 = self . _get_text_sequence ( t1 , t1_span , context_length ) s2 , span2 = self . _get_text_sequence ( t2 , t2_span , context_length ) length = len ( s1 ) alignment = pairwise2 . align . globalms ( s1 , s2 , constants . IDENTICAL_CHARACTER_SCORE , constants . DIFFERENT_CHARACTER_SCORE , constants . OPEN_GAP_PENALTY , constants . EXTEND_GAP_PENALTY ) [ 0 ] context_length = length score = alignment [ 2 ] / length if not alignment : return None elif score < constants . SCORE_THRESHOLD or length == old_length : break else : self . _logger . debug ( 'Score: {}' . format ( score ) ) old_length = length covered_spans [ 0 ] . append ( span1 ) covered_spans [ 1 ] . append ( span2 ) return Sequence ( alignment , self . _reverse_substitutes , t1_span [ 0 ] )
Returns an aligned sequence (or None) between extract `t1_span` of
        witness text `t1` and extract `t2_span` of witness text `t2`.

        Adds the span of the aligned sequence, if any, to
        `covered_spans` (which, being mutable, is modified in place
        without needing to be returned).

        This method repeats the alignment process, increasing the
        context length until the alignment score (the measure of how
        much the two sequences align) drops below a certain point or
        it is not possible to increase the context length.

        :param t1: text content of first witness
        :type t1: `str`
        :param t1_span: start and end indices within `t1` to align
        :type t1_span: 2-`tuple` of `int`
        :param t2: text content of second witness
        :type t2: `str`
        :param t2_span: start and end indices within `t2` to align
        :type t2_span: 2-`tuple` of `int`
        :param context_length: length of context on either side of
                               the spans to include in the sequence
        :type context_length: `int`
        :param covered_spans: lists of start and end indices for parts
                              of the texts already covered by a sequence
        :type covered_spans: `list` of two `list`s of 2-`tuple` of `int`