def run_in_tmp(fs, nexus): """ @param fs: fieldstorage-like user options @param nexus: the nexus object that defines the tree and alignment @return: from_paml """ # create the control object config = Paml.PamlConfig() config.set_hky() # create the baseml.ctl control file ctl_string = config.to_ctl_string() with open(Paml.baseml_ctl, 'wt') as fout: print >> fout, ctl_string # create the nexus object that defines the tree and alignment nexus = Nexus.get_sample_nexus_object() # create the baseml.newick tree file with open(Paml.baseml_newick, 'wt') as fout: print >> fout, nexus.tree.get_newick_string() # create the baseml.phylip alignment file s_phylip = Phylip.get_alignment_string_non_interleaved(nexus.alignment) with open(Paml.baseml_phylip, 'wt') as fout: print >> fout, s_phylip # run PAML args = [Config.baseml_exe_path, Paml.baseml_ctl] from_paml, to_paml = popen2.popen4(args) return from_paml
def run_hky(tree, alignment): """ @param tree: a tree object @param alignment: an alignment object @return: messages from the program but not the results """ # create the baseml.ctl control file config = PamlConfig() config.set_hky() config.to_ctl_string() with open(baseml_ctl, 'wt') as fout: print >> fout, config.to_ctl_string() # create the nexus object that defines the tree and alignment nexus = Nexus.get_sample_nexus_object() # create the baseml.newick tree file with open(baseml_newick, 'wt') as fout: print >> fout, nexus.tree.get_newick_string() # create the baseml.phylip alignment file phylip_string = Phylip.get_alignment_string_non_interleaved( nexus.alignment) with open(baseml_phylip, 'wt') as fout: print >> fout, phylip_string # change the current directory to the data directory with Util.remember_cwd(): os.chdir(Config.data_path) # run PAML exe_path = Config.baseml_exe_path ctl_path = baseml_ctl #cmd = '%s %s > /dev/null' % (exe_path, ctl_path) #os.system(cmd) from_paml, to_paml = popen2.popen4([exe_path, ctl_path]) #p = subprocess.Popen([cmd, arg], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) # change back to the old directory return from_paml.read()
def run_in_tmp(fs, nexus): """ @param fs: fieldstorage-like user options @param nexus: the nexus object that defines the tree and alignment @return: from_paml """ # create the control object config = Paml.PamlConfig() config.set_hky() # create the baseml.ctl control file ctl_string = config.to_ctl_string() with open(Paml.baseml_ctl, 'wt') as fout: print >> fout, ctl_string # create the nexus object that defines the tree and alignment nexus = Nexus.get_sample_nexus_object() # create the baseml.newick tree file with open(Paml.baseml_newick, 'wt') as fout: print >> fout, nexus.tree.get_newick_string() # create the baseml.phylip alignment file s_phylip = Phylip.get_alignment_string_non_interleaved(nexus.alignment) with open(Paml.baseml_phylip, 'wt') as fout: print >> fout, s_phylip # run PAML args = [Config.baseml_exe_path, Paml.baseml_ctl] from_paml, to_paml = popen2.popen4(args) return from_paml
def run_hky(tree, alignment): """ @param tree: a tree object @param alignment: an alignment object @return: messages from the program but not the results """ # create the baseml.ctl control file config = PamlConfig() config.set_hky() config.to_ctl_string() with open(baseml_ctl, "wt") as fout: print >> fout, config.to_ctl_string() # create the nexus object that defines the tree and alignment nexus = Nexus.get_sample_nexus_object() # create the baseml.newick tree file with open(baseml_newick, "wt") as fout: print >> fout, nexus.tree.get_newick_string() # create the baseml.phylip alignment file phylip_string = Phylip.get_alignment_string_non_interleaved(nexus.alignment) with open(baseml_phylip, "wt") as fout: print >> fout, phylip_string # change the current directory to the data directory with Util.remember_cwd(): os.chdir(Config.data_path) # run PAML exe_path = Config.baseml_exe_path ctl_path = baseml_ctl # cmd = '%s %s > /dev/null' % (exe_path, ctl_path) # os.system(cmd) from_paml, to_paml = popen2.popen4([exe_path, ctl_path]) # p = subprocess.Popen([cmd, arg], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) # change back to the old directory return from_paml.read()