def build_coordinate_families(self, paired_aligns):
        '''Given a stream of paired aligns, return a list of pairs that share
        same coordinates (coordinate family).  Flushes families in progress
        when any of:
        a) incoming right start > family end
        b) incoming chrom != current chrom
        c) incoming align stream is exhausted'''
        rightmost_start = None
        current_chrom = None
        def _new_coordinate(pair):
            return pair.right.reference_start != rightmost_start
        def _new_chrom(pair):
            return current_chrom != pair.right.reference_name

        for pair in paired_aligns:
            if rightmost_start is None:
                rightmost_start = pair.right.reference_start
                current_chrom = pair.right.reference_name
            if _new_chrom(pair):
                self._right_coords_in_progress[current_chrom].clear()
                rightmost_start = None
                current_chrom = None
                for family in self._remaining_families():
                    yield family
            elif _new_coordinate(pair):
                right = pair.right
                for family in self._completed_families(right.reference_name,
                                                       right.reference_start):
                    yield family
            self._add(pair)

        for family in self._remaining_families():
            yield family
def build_coordinate_families ( self , paired_aligns ) : rightmost_start = None current_chrom = None def _new_coordinate ( pair ) : return pair . right . reference_start != rightmost_start def _new_chrom ( pair ) : return current_chrom != pair . right . reference_name for pair in paired_aligns : if rightmost_start is None : rightmost_start = pair . right . reference_start current_chrom = pair . right . reference_name if _new_chrom ( pair ) : self . _right_coords_in_progress [ current_chrom ] . clear ( ) rightmost_start = None current_chrom = None for family in self . _remaining_families ( ) : yield family elif _new_coordinate ( pair ) : right = pair . right for family in self . _completed_families ( right . reference_name , right . reference_start ) : yield family self . _add ( pair ) for family in self . _remaining_families ( ) : yield family
Given a stream of paired aligns, return a list of pairs that share
        same coordinates (coordinate family).  Flushes families in progress
        when any of:
        a) incoming right start > family end
        b) incoming chrom != current chrom
        c) incoming align stream is exhausted