@@ -132,7 +132,7 @@ def get_toy_data():
132132# For each site, the sum of backward value over all haplotypes is calculated
133133# before scaling and shifting.
134134
135- fwd_matrix_text_1 = """
135+ beagle_forward_matrix_text_1 = """
136136m,h,probRec,probNoRec,noErrProb,errProb,refAl,queryAl,shiftFac,scaleFac,sumSite,val
1371370,0,0.000000,1.000000,0.999900,0.000100,1,0,0.000000,1.000000,0.000100,0.000100
1381380,1,0.000000,1.000000,0.999900,0.000100,0,0,0.000000,1.000000,1.000000,0.999900
@@ -152,7 +152,7 @@ def get_toy_data():
1521523,3,1.000000,0.000000,0.999900,0.000100,1,0,0.250000,0.000000,0.250050,0.000025
153153"""
154154
155- bwd_matrix_text_1 = """
155+ beagle_backward_matrix_text_1 = """
156156m,h,probRec,probNoRec,noErrProb,errProb,refAl,queryAl,shiftFac,scaleFac,sumSite,val
1571573,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,1.000000
1581583,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1.000000
@@ -172,7 +172,7 @@ def get_toy_data():
1721720,3,1.000000,0.000000,0.999900,0.000100,1,1,0.000000,0.250000,0.250050,0.250000
173173"""
174174
175- fwd_matrix_text_2 = """
175+ beagle_forward_matrix_text_2 = """
176176m,h,probRec,probNoRec,noErrProb,errProb,refAl,queryAl,shiftFac,scaleFac,sumSite,val
1771770,0,0.000000,1.000000,0.999900,0.000100,1,1,0.000000,1.000000,0.999900,0.999900
1781780,1,0.000000,1.000000,0.999900,0.000100,0,1,0.000000,1.000000,1.000000,0.000100
@@ -192,7 +192,7 @@ def get_toy_data():
1921923,3,1.000000,0.000000,0.999900,0.000100,1,1,0.250000,0.000000,0.749950,0.249975
193193"""
194194
195- bwd_matrix_text_2 = """
195+ beagle_backward_matrix_text_2 = """
196196m,h,probRec,probNoRec,noErrProb,errProb,refAl,queryAl,shiftFac,scaleFac,sumSite,val
1971973,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,1.000000
1981983,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1.000000
@@ -223,39 +223,39 @@ def convert_to_numpy(matrix_text):
223223 return df .val .to_numpy ().reshape ((4 , 4 ))
224224
225225
226- def get_forward_backward_matrices ():
227- fwd_matrix_1 = convert_to_numpy (fwd_matrix_text_1 )
228- bwd_matrix_1 = convert_to_numpy (bwd_matrix_text_1 )
229- fwd_matrix_2 = convert_to_numpy (fwd_matrix_text_2 )
230- bwd_matrix_2 = convert_to_numpy (bwd_matrix_text_2 )
226+ def get_beagle_forward_backward_matrices ():
227+ fwd_matrix_1 = convert_to_numpy (beagle_forward_matrix_text_1 )
228+ bwd_matrix_1 = convert_to_numpy (beagle_backward_matrix_text_1 )
229+ fwd_matrix_2 = convert_to_numpy (beagle_forward_matrix_text_2 )
230+ bwd_matrix_2 = convert_to_numpy (beagle_backward_matrix_text_2 )
231231 return [fwd_matrix_1 , bwd_matrix_1 , fwd_matrix_2 , bwd_matrix_2 ]
232232
233233
234- def get_test_data (matrix_text , par ):
234+ def get_beagle_data (matrix_text , data_type ):
235235 """Extracts data to check forward or backward probability matrix calculations."""
236236 df = pd .read_csv (io .StringIO (matrix_text ))
237- if par == "switch" :
237+ if data_type == "switch" :
238238 # Switch probability, one per site
239239 return df .probRec .to_numpy ().reshape ((4 , 4 ))[:, 0 ]
240- elif par == "mismatch" :
240+ elif data_type == "mismatch" :
241241 # Mismatch probability, one per site
242242 return df .errProb .to_numpy ().reshape ((4 , 4 ))[:, 0 ]
243- elif par == "ref_hap_allele" :
243+ elif data_type == "ref_hap_allele" :
244244 # Allele in haplotype in reference panel
245245 # 0 = ref allele, 1 = alt allele
246246 return df .refAl .to_numpy ().reshape ((4 , 4 ))
247- elif par == "query_hap_allele" :
247+ elif data_type == "query_hap_allele" :
248248 # Allele in haplotype in query
249249 # 0 = ref allele, 1 = alt allele
250250 return df .queryAl .to_numpy ().reshape ((4 , 4 ))[:, 0 ]
251- elif par == "shift" :
251+ elif data_type == "shift" :
252252 # Shift factor, one per site
253253 return df .shiftFac .to_numpy ().reshape ((4 , 4 ))[:, 0 ]
254- elif par == "scale" :
254+ elif data_type == "scale" :
255255 # Scale factor, one per site
256256 return df .scaleFac .to_numpy ().reshape ((4 , 4 ))[:, 0 ]
257- elif par == "sum" :
257+ elif data_type == "sum" :
258258 # Sum of values over haplotypes
259259 return df .sumSite .to_numpy ().reshape ((4 , 4 ))[:, 0 ]
260260 else :
261- raise ValueError (f"Unknown parameter : { par } " )
261+ raise ValueError (f"Unknown data type : { data_type } " )
0 commit comments