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