@@ -0,0 +1,2027 @@
+#!/usr/bin/env python%0Aimport sys%0Aimport numpy as np%0Afrom optparse import OptionParser%0A%0Adef interval_to_bedpe(size, call, sv_type, i):%0A    half = size/2%0A    chrom,interval = call.split(':')%0A    start,end = %5Bint(x) for x in interval.split('-')%5D%0A    length = end-start%0A%0A    bedpe = '%5Ct'.join(%5Bchrom,%0A                      str( max(1,start-half)),%0A                      str( start+half),%0A                      chrom,%0A                      str( max(1,end-half)),%0A                      str( end+half),%0A                      str(i),%0A                      str(length),%0A                      '+',%0A                      '+',%0A                      'TYPE:' + sv_type%5D)%0A%0A    return bedpe%0A%0Aparser = OptionParser()%0A%0Aparser.add_option(%22-c%22,%0A    %22--cnv_calls%22,%0A    dest=%22cnv_calls%22,%0A    help=%22Output file from CNVanator%22)%0A%0Aparser.add_option(%0A    %22--del_o%22,%0A    dest=%22del_o%22,%0A    help=%22Deletion output bedpe file name%22)%0A%0Aparser.add_option(%0A    %22--dup_o%22,%0A    dest=%22dup_o%22,%0A    help=%22Duplication output bedpe file name%22)%0A%0Aparser.add_option(%22-b%22,%0A    %22--breakpoint_size%22,%0A    dest=%22breakpoint_size%22,%0A    type=%22int%22,%0A    help=%22The total size of the resulting breakpoint, %22 + %5C%0A            %22centered on the call edge%22)%0A%0A(options, args) = parser.parse_args()%0A%0Aif not options.cnv_calls:%0A    parser.error('CNVanator calls not given')%0A%0Aif not options.del_o:%0A    parser.error('Deletion output file not given')%0A%0Aif not options.dup_o:%0A    parser.error('Duplication output file not given')%0A%0Aif not options.breakpoint_size:%0A    parser.error('Breakpoint size not given')%0A%0A%0Af = open(options.cnv_calls,'r')%0A%0Adel_f = open(options.del_o,'w')%0Adup_f = open(options.dup_o,'w')%0A%0Ai = 1%0Afor l in f:%0A    A = l.rstrip().split('%5Ct')%0A%0A    if A%5B0%5D == 'deletion':%0A        bedpe = interval_to_bedpe(options.breakpoint_size, A%5B1%5D,'DELETION',i)%0A        del_f.write(bedpe + '%5Cn')%0A    elif A%5B0%5D == 'duplication':%0A        bedpe = interval_to_bedpe(options.breakpoint_size, A%5B1%5D,'DUPLICATION',i)%0A        dup_f.write(bedpe + '%5Cn')%0A%0A    i += 1%0A%0A%0Af.close()%0Adel_f.close()%0Adup_f.close()%0A

add cnvnator to bedpe