@@ -18,20 +18,20 @@ def process_cnv(cpath):
18
18
root = os .path .basename (cpath )
19
19
temp_filtered_fname = root + ".CNVs_0.05_filtered.bed"
20
20
with open (out_dir + temp_filtered_fname , "w" ) as temp_filtered :
21
- in_cnv = open (cpath )
22
- head = next (in_cnv )
23
- header = head .rstrip ('\n ' ).split ('\t ' )
24
- wilcox_idx = header .index ('WilcoxonRankSumTestPvalue' )
25
- ks_idx = header .index ('KolmogorovSmirnovPvalue' )
26
- for cnv in in_cnv :
27
- ct_dict ["total_cnvs" ] += 1
28
- cnv_data = cnv .rstrip ("\n " ).split ("\t " )
29
- if cnv_data [wilcox_idx ] == "NA" or cnv_data [ks_idx ] == "NA" :
30
- ct_dict ["NA" ] += 1
31
- elif float (cnv_data [wilcox_idx ]) < 0.05 and float (cnv_data [ks_idx ]) < 0.05 :
32
- print ("\t " .join (cnv_data [0 :5 ]), file = temp_filtered )
33
- else :
34
- ct_dict ["p_value_filter" ] += 1
21
+ with open (cpath ) as in_cnv :
22
+ head = next (in_cnv )
23
+ header = head .rstrip ('\n ' ).split ('\t ' )
24
+ wilcox_idx = header .index ('WilcoxonRankSumTestPvalue' )
25
+ ks_idx = header .index ('KolmogorovSmirnovPvalue' )
26
+ for cnv in in_cnv :
27
+ ct_dict ["total_cnvs" ] += 1
28
+ cnv_data = cnv .rstrip ("\n " ).split ("\t " )
29
+ if cnv_data [wilcox_idx ] == "NA" or cnv_data [ks_idx ] == "NA" :
30
+ ct_dict ["NA" ] += 1
31
+ elif float (cnv_data [wilcox_idx ]) < 0.05 and float (cnv_data [ks_idx ]) < 0.05 :
32
+ print ("\t " .join (cnv_data [0 :5 ]), file = temp_filtered )
33
+ else :
34
+ ct_dict ["p_value_filter" ] += 1
35
35
temp_genes_fname = root + ".CNVs.Genes"
36
36
to_genes_cmd = "{} intersect -a {}{} -b {} -wb > {}{}" .format (bedtools , out_dir , temp_filtered_fname , bed_file , out_dir , temp_genes_fname )
37
37
subprocess .call (to_genes_cmd , shell = True )
0 commit comments