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