@@ -14,7 +14,7 @@ def index_vcf(vcf_prefix, block_length):
1414 subprocess .run (["python" , indexer , vcf_prefix , str (block_length )])
1515
1616
17- def run_singer_in_parallel (vcf_prefix , output_prefix , mutation_rate , ratio , block_length , num_iters , thinning_interval , Ne , polar , num_cores ):
17+ def run_singer_in_parallel (vcf_prefix , output_prefix , mutation_rate , ratio , block_length , num_iters , thinning_interval , Ne , polar , num_cores , recomb_map , mut_map ):
1818 """Run singer in parallel using the specified parameters."""
1919
2020 # Read the breakpoints from the index file
@@ -30,8 +30,18 @@ def run_singer_in_parallel(vcf_prefix, output_prefix, mutation_rate, ratio, bloc
3030 start = breakpoints [i ]
3131
3232 # Base command
33- cmd = f"{ singer_master_executable } -Ne { Ne } -m { mutation_rate } -ratio { ratio } -vcf { vcf_prefix } -output { output_prefix } _{ i } _{ i + 1 } -start { start } -end { start + block_length } -n { num_iters } -thin { thinning_interval } -polar { polar } "
34-
33+ cmd = f"{ singer_master_executable } -vcf { vcf_prefix } -output { output_prefix } _{ i } _{ i + 1 } -start { start } -end { start + block_length } -n { num_iters } -thin { thinning_interval } -polar { polar } "
34+ if Ne is not None :
35+ cmd += f" -Ne { Ne } "
36+ if recomb_map :
37+ cmd += f" -recomb_map \" { recomb_map } \" "
38+ else :
39+ cmd += f" -ratio { ratio } "
40+ if mut_map is not None :
41+ cmd += f" -mut_map { mut_map } "
42+ else :
43+ cmd += f" -m { mutation_rate } "
44+
3545 cmd_list .append (cmd )
3646
3747 # Execute the commands in parallel
@@ -47,28 +57,32 @@ def convert_long_ARG(vcf_prefix, output_prefix, num_iters, freq):
4757
4858def main ():
4959 parser = argparse .ArgumentParser (description = "Parallelize singer runs by cutting the chromosome" )
50- parser .add_argument ('-Ne' , type = float , required = True , help = 'Effective population size. Default: 1e4.' )
51- parser .add_argument ("-m" , type = float , required = True , help = "Mutation rate." )
60+ parser .add_argument ('-Ne' , type = float , required = False , help = 'Effective population size. Default: 1e4.' )
61+ parser .add_argument ("-m" , type = float , required = False , help = "Mutation rate." )
62+ parser .add_argument ("-mut_map" , type = str , help = "Filename for the mutation rate map." )
5263 parser .add_argument ("-ratio" , type = float , default = 1 , help = "Recombination to mutation ratio. Default: 1." )
64+ parser .add_argument ("-recomb_map" , default = None , required = False , help = "Filename for the recombination rate map." )
5365 parser .add_argument ("-L" , type = int , default = int (1e6 ), help = "Block length. Default: 1e6." )
5466 parser .add_argument ("-vcf" , type = str , required = True , help = "VCF file prefix (without .vcf or .vcf.gz extension)." )
5567 parser .add_argument ("-output" , type = str , required = True , help = "Output file prefix." )
5668 parser .add_argument ("-n" , type = int , required = True , help = "Number of MCMC samples." )
5769 parser .add_argument ("-thin" , type = int , required = True , help = "Thinning interval length." )
5870 parser .add_argument ("-polar" , type = float , default = 0.5 , required = False , help = "Site flip probability. Default: 0.5." )
5971 parser .add_argument ("-freq" , type = float , default = 1 , required = False , help = "Convert to tskit every {freq} samples. Default: 1." )
60- parser .add_argument ("-num_cores" , type = int , default = 20 , required = False , help = "Number of cores. Default: 20." )
61-
72+ parser .add_argument ("-num_cores" , type = int , default = 20 , required = False , help = "Number of cores. Default: 20." )
73+
6274 if len (sys .argv ) == 1 :
6375 parser .print_help (sys .stderr )
6476 sys .exit (1 )
6577
6678 args = parser .parse_args ()
6779
6880 print ("Parameters:" )
69- print (f"Effective population size: { args .Ne } " )
81+ print (f"Effective population size: { args .Ne if args . Ne is not None else 'estimated' } " )
7082 print (f"Mutation rate: { args .m } " )
83+ print (f"Mutation map: { args .mut_map } " )
7184 print (f"Recombination to mutation ratio: { args .ratio } " )
85+ print (f"Recombination map: { args .recomb_map } " )
7286 print (f"Block length: { args .L } " )
7387 print (f"VCF file prefix: { args .vcf } " )
7488 print (f"Output file prefix: { args .output } " )
@@ -79,7 +93,7 @@ def main():
7993 print (f"Number of cores: { args .num_cores } " )
8094
8195 index_vcf (args .vcf , args .L )
82- run_singer_in_parallel (args .vcf , args .output , args .m , args .ratio , args .L , args .n , args .thin , args .Ne , args .polar , args .num_cores )
96+ run_singer_in_parallel (args .vcf , args .output , args .m , args .ratio , args .L , args .n , args .thin , args .Ne , args .polar , args .num_cores , args . recomb_map , args . mut_map )
8397 convert_long_ARG (args .vcf , args .output , args .n , args .freq )
8498
8599if __name__ == "__main__" :
0 commit comments