def select_snps(mirna, snp, out):
with open(out, '<STR_LIT:w>') as out_handle:<EOL><INDENT>print(_create_header(mirna, snp, out), file=out_handle, end="<STR_LIT>")<EOL>snp_in_mirna = pybedtools.BedTool(snp).intersect(pybedtools.BedTool(mirna), wo=True)<EOL>for single in snp_in_mirna:<EOL><INDENT>if single[<NUM_LIT:10>] == "<STR_LIT>" and len(single[<NUM_LIT:3>]) + len(single[<NUM_LIT:4>]) == <NUM_LIT:2>:<EOL><INDENT>line = []<EOL>rel_p = _lift_positions(single)<EOL>line.append(_get_mirna_name(single[<NUM_LIT:16>]))<EOL>line.append(str(rel_p))<EOL>line.append(single[<NUM_LIT:2>])<EOL>line.append(_complement(single[<NUM_LIT:3>], single[<NUM_LIT>]))<EOL>line.append(_complement(single[<NUM_LIT:4>], single[<NUM_LIT>]))<EOL>line.append(single[<NUM_LIT:5>])<EOL>line.append(single[<NUM_LIT:6>])<EOL>line.append(single[<NUM_LIT:7>])<EOL>print("<STR_LIT:\t>".join(line), file=out_handle, end="<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>return out<EOL>
Use bedtools to intersect coordinates