@@ -92,18 +92,20 @@ def writeOutParamaters(peelingInfo):
9292 :return: None. Writes to files specified in the InputOutput.args.
9393 """
9494 args = InputOutput .args
95-
9695 if args .est_geno_error_prob :
9796 np .savetxt (
98- args .out_file + ".geno_error_prob.txt" , peelingInfo .genoError , fmt = "%f"
97+ args .out_file + ".geno_error_prob.txt" ,
98+ peelingInfo .genoError ,
9999 )
100100 if args .est_seq_error_prob :
101101 np .savetxt (
102- args .out_file + ".seq_error_prob.txt" , peelingInfo .seqError , fmt = "%f"
102+ args .out_file + ".seq_error_prob.txt" ,
103+ peelingInfo .seqError ,
103104 )
104105 if args .rec_prob :
105106 np .savetxt (
106- args .out_file + ".rec_prob.txt" , np .empty ((1 , 1 )), fmt = "%f"
107+ args .out_file + ".rec_prob.txt" ,
108+ np .empty ((1 , 1 )),
107109 ) # not implemented atm, just as a placeholder
108110 # np.savetxt(args.out_file + ".trans", peelingInfo.transmissionRate, fmt = "%f")
109111
@@ -134,7 +136,6 @@ def sort_key(mf_key):
134136 args .out_file + ".alt_allele_prob.txt" ,
135137 combined_AAP ,
136138 delimiter = "\t " ,
137- fmt = "%.2f" ,
138139 header = "\t " .join (sorted_MF ),
139140 comments = "" ,
140141 )
@@ -149,7 +150,8 @@ def writePhenoPenetrance(pedigree):
149150 """
150151 args = InputOutput .args
151152 np .savetxt (
152- args .out_file + ".pheno_penetrance.txt" , pedigree .phenoPenetrance , fmt = "%.2f"
153+ args .out_file + ".pheno_penetrance.txt" ,
154+ pedigree .phenoPenetrance ,
153155 )
154156
155157
@@ -249,13 +251,17 @@ def writePhasedGenoProbs(pedigree, genoProbFunc, outputFile):
249251 :type outputFile: str
250252 :return: None. Writes to the specified output file.
251253 """
254+ args = InputOutput .args
252255 with open (outputFile , "w+" ) as f :
253256 for idx , ind in pedigree .writeOrder ():
254257 matrix = genoProbFunc (ind .idn , ind .sex )
255258 f .write ("\n " )
256259 for i in range (matrix .shape [0 ]):
257260 f .write (
258- ind .idx + " " + " " .join (map ("{:.4f}" .format , matrix [i , :])) + "\n "
261+ ind .idx
262+ + " "
263+ + " " .join (map (f"{{:.{ args .out_digits } f}}" .format , matrix [i , :]))
264+ + "\n "
259265 )
260266
261267
@@ -270,6 +276,7 @@ def writeGenoProbs(pedigree, genoProbFunc, outputFile):
270276 :type outputFile: str
271277 :return: None. Writes to the specified output file.
272278 """
279+ args = InputOutput .args
273280 with open (outputFile , "w+" ) as f :
274281 for idx , ind in pedigree .writeOrder ():
275282 matrix = genoProbFunc (ind .idn , ind .sex )
@@ -279,15 +286,20 @@ def writeGenoProbs(pedigree, genoProbFunc, outputFile):
279286 ind .idx
280287 + " "
281288 + " " .join (
282- map ("{:.4f}" .format , matrix [i , :] + matrix [i + 1 , :])
289+ map (
290+ f"{{:.{ args .out_digits } f}}" .format ,
291+ matrix [i , :] + matrix [i + 1 , :],
292+ )
283293 )
284294 + "\n "
285295 )
286296 elif i != 2 : # Print probabilities for aa and AA
287297 f .write (
288298 ind .idx
289299 + " "
290- + " " .join (map ("{:.4f}" .format , matrix [i , :]))
300+ + " " .join (
301+ map (f"{{:.{ args .out_digits } f}}" .format , matrix [i , :])
302+ )
291303 + "\n "
292304 )
293305
@@ -308,7 +320,10 @@ def writePhenoProbs(pedigree, phenoProbFunc):
308320 f .write ("\n " )
309321 for i in range (matrix .shape [0 ]):
310322 f .write (
311- ind .idx + " " + " " .join (map ("{:.4f}" .format , matrix [i , :])) + "\n "
323+ ind .idx
324+ + " "
325+ + " " .join (map (f"{{:.{ args .out_digits } f}}" .format , matrix [i , :]))
326+ + "\n "
312327 )
313328
314329
@@ -325,14 +340,20 @@ def writeDosages(pedigree, genoProbFunc, isXChr, outputFile):
325340 :type outputFile: str
326341 :return: None. Writes to the specified output file.
327342 """
343+ args = InputOutput .args
328344 with open (outputFile , "w+" ) as f :
329345 for idx , ind in pedigree .writeOrder ():
330346 if isXChr and ind .sex == 0 :
331347 tmp = np .array ([0 , 0 , 0 , 1 ])
332348 else :
333349 tmp = np .array ([0 , 1 , 1 , 2 ])
334350 matrix = np .dot (tmp , genoProbFunc (ind .idn , ind .sex ))
335- f .write (ind .idx + " " + " " .join (map ("{:.4f}" .format , matrix )) + "\n " )
351+ f .write (
352+ ind .idx
353+ + " "
354+ + " " .join (map (f"{{:.{ args .out_digits } f}}" .format , matrix ))
355+ + "\n "
356+ )
336357
337358
338359def writeCalledGenotypes (pedigree , genoProbFunc , isXChr , outputFile , thresh ):
0 commit comments