find introns by searching Rfam intron databse using cmscan
    # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]]

def find_introns(fa, seqs, sequences, threads):
    """
    find introns by searching Rfam intron databse using cmscan
    # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]]
    """
    db = '%s/rfam/Rfam.cm.1_1.introns' % (os.environ['databases'])
    out = '%s.rfam-introns.cmscan' % (fa)
    tblout = '%s.rfam-introns.cmscan-tblout' % (fa)
    if os.path.exists(tblout) is False:
        p = subprocess.Popen('cmscan --cpu %s --tblout %s %s %s > %s'\
                % (threads, tblout, db, fa, out), shell = True)
        p.communicate()
    for line in open(tblout):
        if line.startswith('#'):
            continue
        line = line.strip().split()
        if line[16] == '?': # does not pass inclusion threshold
            continue
        id = line[2]
        type, start, stop, strand = line[0], int(line[7]), int(line[8]), line[9]
        if 'intron' not in type.lower():
            continue
        pos = sorted([start, stop])
        if id not in seqs:
            continue
        for i, ins in enumerate(seqs[id][2]):
            if check_overlap(pos, ins, 0.25) is True:
                seqs[id][2][i][5].append(['>%s_%s %s %s %s-%s' % (id, (i + 1), type, strand, start, stop), sequences[id][1][pos[0]-1:pos[1]]])
    return seqs