@@ -35,6 +35,15 @@ def __init__ ( self , model , decoder_model = None, mafftmat = None , submat = N
3535 self .raxmlng_path = raxml_path
3636 self .modelname = model .split ('/' )[- 1 ].split ('.' )[0 ]
3737
38+ if 'bs' in kwargs :
39+ self .bs = kwargs ['bs' ]
40+ else :
41+ self .bs = False
42+ if 'redo' in kwargs :
43+ self .redo = kwargs ['redo' ]
44+ else :
45+ self .redo = False
46+
3847 if charmaps is None :
3948 self .rev_replace_dict_ord = { ord (v ):ord (k ) for k ,v in self .replace_dict .items () }
4049 self .raxml_path = raxml_path
@@ -48,6 +57,7 @@ def __init__ ( self , model , decoder_model = None, mafftmat = None , submat = N
4857 self .nchars = len (self .alphabet )
4958 self .map = { c :i for i ,c in enumerate (self .alphabet )}
5059 self .revmap = { i :c for i ,c in enumerate (self .alphabet )}
60+
5161 else :
5262 print ('loading charmaps from' , charmaps )
5363
@@ -357,16 +367,20 @@ def read_textaln(self, aln_hexfile , outfile = None):
357367 f .write ('>' + i + '\n ' + alndf .loc [i ].remap_symbols + '\n ' )
358368 return outfile
359369
360- def run_raxml_ng (self , fasta_file , matrix_file , nsymbols , output_prefix , iterations = 10 , cores = 8 , bs = False ):
370+ def run_raxml_ng (self , fasta_file , matrix_file , nsymbols , output_prefix , iterations = 10 , cores = 8 ):
361371 raxmlng_path = self .raxml_path
362372 if raxmlng_path == None :
363373 raxmlng_path = 'raxml-ng'
364- raxml_cmd = raxmlng_path + ' --model MULTI' + str (self .nchars )+ '_GTR{' + matrix_file + '} --redo --all --bs-trees ' + str (iterations )+ ' --seed 12345 --threads auto{' + str (self .ncores ) + '} --workers auto --msa ' + fasta_file + ' --prefix ' + output_prefix + ' --force perf_threads'
365- #raxml_cmd =raxmlng_path + ' --model MULTI'+str(nsymbols)+'_GTR+I+G --redo --all --bs-trees '+str(iterations)+' --seed 12345 --threads 8 --msa '+fasta_file+' --prefix '+output_prefix
374+ raxml_cmd = raxmlng_path + ' --model MULTI' + str (self .nchars )+ '_GTR{' + matrix_file + '} --seed 12345 --threads auto{' + str (self .ncores ) + '} --workers auto --msa ' + fasta_file + ' --prefix ' + output_prefix
375+ if self .bs == True :
376+ raxml_cmd += ' --force perf_threads --bs-trees ' + str (iterations )+ ' --bs-metric fbp'
377+ if self .redo == True :
378+ raxml_cmd += ' --redo'
366379 print (raxml_cmd )
367380 subprocess .run (raxml_cmd , shell = True )
368381 return output_prefix + '.raxml.bestTree'
369382
383+
370384 #ancestral reconstruction
371385 #raxml-ng --ancestral --msa ali.fa --tree best.tre --model HKY --prefix ASR
372386
@@ -623,6 +637,9 @@ def main():
623637 parser .add_argument ("--raxmlpath" , default = 'raxml-ng' , help = "Path to RAxML-NG executable" )
624638 parser .add_argument ("--verbose" , action = "store_true" , help = "Enable verbose output" )
625639 parser .add_argument ("--device" , default = None , help = "Device to run the model on (default: None, uses CPU or GPU if available)" )
640+ parser .add_argument ( "--bs" , action = "store_true" , help = "Enable bootstrapping in RAxML-NG" )
641+ parser .add_argument ( "--redo" , action = "store_true" , help = "Enable --redo flag in RAxML-NG to overwrite existing results" )
642+
626643 # Ancestral reconstruction options
627644 parser .add_argument ("--ancestral" , action = "store_true" , help = "Perform ancestral reconstruction" )
628645
@@ -685,7 +702,7 @@ def main():
685702
686703 # Create an instance of treebuilder
687704 tb = treebuilder (model = encoder_path , mafftmat = args .mafftmat , decoder_model = decoder_path , submat = args .submat , raxml_path = args .raxmlpath ,
688- aapropcsv = args .aapropcsv , maffttext2hex = args .maffttext2hex , maffthex2text = args .maffthex2text , ncores = args .ncores , charmaps = args .charmaps , device = args .device )
705+ aapropcsv = args .aapropcsv , maffttext2hex = args .maffttext2hex , maffthex2text = args .maffthex2text , ncores = args .ncores , charmaps = args .charmaps , device = args .device , bs = args . bs , redo = args . redo , verbose = args . verbose )
689706
690707 # Generate tree from structures using the provided options
691708 tb .structs2tree (structs = args .structures , outdir = args .outdir , ancestral = args .ancestral , raxml_iterations = args .raxml_iterations , raxml_path = args .raxmlpath , output_prefix = args .output_prefix
0 commit comments