@@ -19,16 +19,16 @@ def chunks(l, n):
1919 for i in range (0 , len (l ), n ):
2020 yield l [i :i + n ]
2121
22- def write_best_prob (name_gl , res , probs , numOfResult , fout ):
22+ def write_best_prob (name_gl , res , probs , numOfResult , fout , sign = "," ):
2323 sumProbsDict = defaultdict (list )
2424 #loop over the result and sum the prob by populations/haplotype
2525 for k in range (len (res )):
26- key = res [k ][0 ] + "," + res [k ][1 ]
26+ key = res [k ][0 ] + sign + res [k ][1 ]
2727 if key in sumProbsDict :
2828 sumProb = probs [k ] + sumProbsDict [key ]
2929 sumProbsDict [key ] = sumProb
3030 else :
31- key2 = res [k ][1 ] + "," + res [k ][0 ]
31+ key2 = res [k ][1 ] + sign + res [k ][0 ]
3232 if key2 in sumProbsDict :
3333 sumProb = probs [k ] + sumProbsDict [key2 ]
3434 sumProbsDict [key2 ] = sumProb
@@ -1727,7 +1727,7 @@ def impute_file(self, config, planb=None, em_mr = False, em = False):##em
17271727 write_best_hap_race_pairs (subject_id , haps , pops , probs , number_of_results , fout_hap_haplo )
17281728 write_best_prob (subject_id , pops , probs , 1 , fout_pop_haplo )
17291729 else :
1730- write_best_prob (subject_id , haps , probs , number_of_results , fout_hap_haplo )
1730+ write_best_prob (subject_id , haps , probs , number_of_results , fout_hap_haplo , "+" )
17311731 write_best_prob (subject_id , pops , probs , number_of_pop_results , fout_pop_haplo )
17321732 if MUUG_output :
17331733 haps = res_muugs ['Haps' ]
0 commit comments