def parse_rRNA(insertion, seq, gff):
    """
    parse rRNA to gff format
    """
    offset = insertion['offset']
    strand = insertion['strand']
    for rRNA in parse_masked(seq, 0)[0]:
        rRNA = ''.join(rRNA)
        Start = seq[1].find(rRNA) + 1
        End = Start + len(rRNA) - 1
        if strand == '-':
            Start, End = End - 2, Start - 2
        pos = (abs(Start + offset) - 1, abs(End + offset) - 1)
        Start, End = min(pos), max(pos)
        source = insertion['source']
        annot = '%s rRNA' % (source.split('from', 1)[0])
        gff['#seqname'].append(insertion['ID'])
        gff['source'].append(source)
        gff['feature'].append('rRNA')
        gff['start'].append(Start)
        gff['end'].append(End)
        gff['score'].append('.')
        gff['strand'].append(strand)
        gff['frame'].append('.')
        gff['attribute'].append('Name=%s' % (annot))
    return gff
def parse_rRNA ( insertion , seq , gff ) : offset = insertion [ 'offset' ] strand = insertion [ 'strand' ] for rRNA in parse_masked ( seq , 0 ) [ 0 ] : rRNA = '' . join ( rRNA ) Start = seq [ 1 ] . find ( rRNA ) + 1 End = Start + len ( rRNA ) - 1 if strand == '-' : Start , End = End - 2 , Start - 2 pos = ( abs ( Start + offset ) - 1 , abs ( End + offset ) - 1 ) Start , End = min ( pos ) , max ( pos ) source = insertion [ 'source' ] annot = '%s rRNA' % ( source . split ( 'from' , 1 ) [ 0 ] ) gff [ '#seqname' ] . append ( insertion [ 'ID' ] ) gff [ 'source' ] . append ( source ) gff [ 'feature' ] . append ( 'rRNA' ) gff [ 'start' ] . append ( Start ) gff [ 'end' ] . append ( End ) gff [ 'score' ] . append ( '.' ) gff [ 'strand' ] . append ( strand ) gff [ 'frame' ] . append ( '.' ) gff [ 'attribute' ] . append ( 'Name=%s' % ( annot ) ) return gff
parse rRNA to gff format