Ejemplo n.º 1
0
def split_transfrag(t, boundaries):
    '''
    exons must be sorted in increasing order

    output: (generator) tuples (a,b) reflecting nodes
    '''
    end_ind = 0
    for exon in t.exons:
        # find the indexes into the splice sites list that border the exon.
        start_ind = cbisect.bisect_right(boundaries, exon.start, lo=end_ind)
        end_ind = cbisect.bisect_left(boundaries, exon.end, lo=start_ind)
        # start_ind = bisect.bisect_right(boundaries, exon.start)
        # end_ind = bisect.bisect_left(boundaries, exon.end)
        if start_ind == end_ind:
            yield boundaries[start_ind - 1], boundaries[start_ind]
        else:
            # all the splice sites in between the exon borders must overlap
            for j in xrange(start_ind - 1, end_ind):
                yield boundaries[j], boundaries[j + 1]
Ejemplo n.º 2
0
def split_transfrag(t, boundaries):
    '''
    exons must be sorted in increasing order

    output: (generator) tuples (a,b) reflecting nodes
    '''
    end_ind = 0
    for exon in t.exons:
        # find the indexes into the splice sites list that border the exon.
        start_ind = cbisect.bisect_right(boundaries, exon.start, lo=end_ind)
        end_ind = cbisect.bisect_left(boundaries, exon.end, lo=start_ind)
        # start_ind = bisect.bisect_right(boundaries, exon.start)
        # end_ind = bisect.bisect_left(boundaries, exon.end)
        if start_ind == end_ind:
            yield boundaries[start_ind-1], boundaries[start_ind]
        else:
            # all the splice sites in between the exon borders must overlap
            for j in xrange(start_ind-1, end_ind):
                yield boundaries[j], boundaries[j+1]