def main(args): paralog = [args.paralog1, args.paralog2] num_boot = args.bootnum Force = None clock = False alignment_file = './BootStrapSamples/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_Boot' + str(num_boot) + '.fasta' save_name = './BootStrapSave/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_Boot' + str(num_boot) + '_save.txt' newicktree = './YeastTree.newick' test = ReCodonGeneconv( newicktree, alignment_file, paralog, Model = 'MG94', Force = None, clock = False, save_name = save_name) test.get_mle(False, True, 0, 'BFGS') test.get_individual_summary(summary_path = './BootStrapSummary/' + '_'.join(paralog) + '/', file_name = './BootStrapSummary/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_Boot' + str(num_boot) + '_summary.txt')
def main(args): paralog = [args.paralog1, args.paralog2] Force = None if args.case == 'Two': alignment_file = './SwapParalogAlignment/' + '_'.join(paralog) + '/two_ingroup/' + '_'.join(paralog) + '_' + args.spe + '_two_ingroup_input.fasta' save_name = './save/' + '_'.join(paralog) + '_' + args.spe + '_two_ingroup' + args.model+ '_nonclock_save.txt' summary_file = './Summary/'+ '_'.join(paralog) + '_' + args.spe + '_two_ingroup' + args.model+ '_nonclock_summary.txt' elif args.case == 'Six': alignment_file = './SwapParalogAlignment/' + '_'.join(paralog) + '/six_ingroup/' + '_'.join(paralog) + '_' + args.spe + '_six_ingroup_input.fasta' save_name = './save/' + '_'.join(paralog) + '_' + args.spe + '_six_ingroup' + args.model+ '_nonclock_save.txt' summary_file = './Summary/'+ '_'.join(paralog) + '_' + args.spe + '_six_ingroup' + args.model+ '_nonclock_summary.txt' newicktree = './YeastTree.newick' if args.force: if args.model == 'MG94': Force = {5:0.0} elif args.model == 'HKY': Force = {4:0.0} save_name = save_name.replace('./save/', './save/Force_') summary_file = summary_file.replace('./Summary/', './Summary/Force_') else: Force = None sitewise_summary_file = summary_file.replace('_summary.txt', '_sitewise_summary.txt') test = ReCodonGeneconv( newicktree, alignment_file, paralog, Model = args.model, Force = Force, clock = args.clock, save_name = save_name) test.get_mle(True, True, 0, 'BFGS') test.get_individual_summary(summary_path = './Summary/', file_name = summary_file) test.get_SitewisePosteriorSummary(summary_path = './Summary/', file_name = sitewise_summary_file)
def run_mle(test): mle_paralog = [str(test.paralog.paralog1), str(test.paralog.paralog2)] mle_model = test.model.model mle_force = test.model.force mle_clock = test.model.clock mle_newicktree = test.tree.tree_file if mle_force: if mle_model == 'MG94': Force = {5: 0.0} elif mle_model == 'HKY': Force = {4: 0.0} else: Force = None mle_alignment_file = test.alignment.alignment_file mle_save_name = test.save.save_file mle_summary_folder = test.summary.summary_folder summary_name_appendix = '_summary.txt' if mle_clock: summary_name_appendix = '_clock' + summary_name_appendix else: summary_name_appendix = '_nonclock' + summary_name_appendix if mle_force: summary_name_appendix = '_force' + summary_name_appendix else: summary_name_appendix = '_noforce' + summary_name_appendix mle_summary_file = mle_summary_folder + '/' + mle_model + '_' + '_'.join( mle_paralog) + summary_name_appendix mle_sitewise_summary_file = mle_summary_folder + '/' + mle_model + '_' + '_'.join( mle_paralog) + summary_name_appendix.replace('_summary.txt', '_sitewise_summary.txt') mle_test = ReCodonGeneconv(mle_newicktree, mle_alignment_file, mle_paralog, Model=mle_model, Force=Force, clock=mle_clock, save_name=mle_save_name) mle_test.get_mle(True, True, 0, 'BFGS') mle_test.get_individual_summary(summary_path=mle_summary_folder, file_name=mle_summary_file) mle_test.get_SitewisePosteriorSummary(summary_path=mle_summary_folder, file_name=mle_sitewise_summary_file) return mle_test
def main(args): paralog = [args.paralog1, args.paralog2] sim_num = args.simnum Force = None clock = False alignment_file = './Simulation/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_MG94_nonclock_Sim_' + str(sim_num) + '.fasta' save_name = './SimulationSave/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_MG94_nonclock_Sim_' + str(sim_num) + '_save.txt' newicktree = './YeastTree.newick' test = ReCodonGeneconv( newicktree, alignment_file, paralog, Model = 'MG94', Force = None, clock = False, save_name = save_name) test.get_mle(True, True, 0, 'BFGS') test.get_individual_summary(summary_path = './SimulationSummary/' + '_'.join(paralog) + '/', file_name = './SimulationSummary/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_MG94_nonclock_Sim_' + str(num_boot) + '_summary.txt')
def main(args): paralog = [args.paralog1, args.paralog2] Force = None alignment_file = '../MafftAlignment/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_input.fasta' newicktree = './YeastTree.newick' if args.force: if args.model == 'MG94': Force = {5:0.0} elif args.model == 'HKY': Force = {4:0.0} else: Force = None test = ReCodonGeneconv( newicktree, alignment_file, paralog, Model = args.model, Force = Force, clock = args.clock) test.get_mle(True, True, 0, 'BFGS') test.get_individual_summary(summary_path = './Summary/') test.get_SitewisePosteriorSummary(summary_path = './Summary/')
def main(args): paralog = [args.paralog1, args.paralog2] Force = None alignment_file = '../MafftAlignment/' + '_'.join(paralog) + '/' + '_'.join( paralog) + '_input.fasta' newicktree = './YeastTree.newick' if args.force: if args.model == 'MG94': Force = {5: 0.0} elif args.model == 'HKY': Force = {4: 0.0} else: Force = None test = ReCodonGeneconv(newicktree, alignment_file, paralog, Model=args.model, Force=Force, clock=args.clock) test.get_mle(True, True, 0, 'BFGS') test.get_individual_summary(summary_path='./Summary/') test.get_SitewisePosteriorSummary(summary_path='./Summary/')
def run(self): mle_paralog = [str(self.paralog.paralog1), str(self.paralog.paralog2)] mle_model = self.model.model mle_force = self.model.force mle_clock = self.model.clock mle_newicktree = self.tree.tree_file if mle_force: if mle_model == 'MG94': Force = {5: 0.0} elif mle_model == 'HKY': Force = {4: 0.0} else: Force = None mle_alignment_file = self.alignment.alignment_file mle_save_name = self.save.save_file mle_summary_folder = self.summary.summary_folder summary_name_appendix = '_summary.txt' if mle_clock: summary_name_appendix = '_clock' + summary_name_appendix else: summary_name_appendix = '_nonclock' + summary_name_appendix if mle_force: summary_name_appendix = '_force' + summary_name_appendix else: summary_name_appendix = '_noforce' + summary_name_appendix mle_summary_file = mle_summary_folder + '/' + '_'.join( mle_paralog) + '_' + mle_model + summary_name_appendix mle_sitewise_summary_file = mle_summary_folder + '/' + '_'.join( mle_paralog) + '_' + mle_model + summary_name_appendix.replace( '_summary.txt', '_sitewise_summary.txt') self.test = ReCodonGeneconv(mle_newicktree, mle_alignment_file, mle_paralog, Model=mle_model, Force=Force, clock=mle_clock, save_name=mle_save_name)
def main(args): paralog = [args.paralog1, args.paralog2] num_boot = args.bootnum Force = None clock = False alignment_file = './BootStrapSamples/' + '_'.join( paralog) + '/' + '_'.join(paralog) + '_Boot' + str(num_boot) + '.fasta' save_name = './BootStrapSave/' + '_'.join(paralog) + '/' + '_'.join( paralog) + '_Boot' + str(num_boot) + '_save.txt' newicktree = './YeastTree.newick' test = ReCodonGeneconv(newicktree, alignment_file, paralog, Model='MG94', Force=None, clock=False, save_name=save_name) test.get_mle(False, True, 0, 'BFGS') test.get_individual_summary( summary_path='./BootStrapSummary/' + '_'.join(paralog) + '/', file_name='./BootStrapSummary/' + '_'.join(paralog) + '/' + '_'.join(paralog) + '_Boot' + str(num_boot) + '_summary.txt')
if __name__ == '__main__': paralog = ['EDN', 'ECP'] Force = None alignment_file = './EDN_ECP_Cleaned.fasta' newicktree = './EDN_ECP_tree.newick' Force = None model = 'HKY' # choose from 'HKY' and 'MG94' save_folder = './save/' check_folder(save_folder) save_name = save_folder + model + '_EDN_ECP_nonclock_save_change.txt' summary_folder = './summary/' check_folder(summary_folder) test = ReCodonGeneconv(newicktree, alignment_file, paralog, Model=model, Force=Force, clock=None, save_path='./save/', save_name=save_name, tau=1, omega=0.9, kappa=0.1, inibl=0.2) test.get_mle() test.get_ExpectedNumGeneconv() test.get_individual_summary(summary_path='./save/')
from Pdiff import read_txt from IGCexpansion.CodonGeneconv import ReCodonGeneconv if __name__ == '__main__': pairs = [] all_pairs = './Filtered_pairs.txt' summary_path = '/Users/xji3/MixedFromCluster/NewPackageNewRun/' with open(all_pairs, 'r') as f: for line in f.readlines(): pairs.append(line.replace('\n', '').split('_')) for paralog in pairs: model = 'MG94' alignment_file = '../MafftAlignment/' + '_'.join( paralog) + '/' + '_'.join(paralog) + '_input.fasta' newicktree = './YeastTree.newick' clock = False Force = None test = ReCodonGeneconv(newicktree, alignment_file, paralog, Model=model, Force=Force, clock=clock) x = read_txt(summary_path, paralog, model, Force, clock, False, False) test.update_by_x(x) test.save_x()
# this function creats it by assuming the outer folder exists (potential bug...) if not os.path.isdir(folder_name): os.mkdir(folder_name) if __name__ == '__main__': paralog = ['EDN', 'ECP'] Force = None alignment_file = './EDN_ECP_Cleaned.fasta' newicktree = './EDN_ECP_tree.newick' Force = None model = 'MG94' # choose from 'HKY' and 'MG94' save_folder = './save/' check_folder(save_folder) save_name = save_folder + model + '_EDN_ECP_nonclock_save.txt' summary_folder = './summary/' check_folder(summary_folder) test = ReCodonGeneconv(newicktree, alignment_file, paralog, Model=model, Force=Force, clock=None, save_path='../test/save/', save_name=save_name) test.get_mle() test.get_ExpectedNumGeneconv() test.get_summary(True)
from IGCexpansion.CodonGeneconv import ReCodonGeneconv if __name__ == '__main__': paralog = ['YLR406C', 'YDL075W'] Force = None alignment_file = './YLR406C_YDL075W_input.fasta' newicktree = './YeastTree.newick' # if args.force: # if args.model == 'MG94': # Force = {5:0.0} # elif args.model == 'HKY': # Force = {4:0.0} # else: # Force = None Force = None test = ReCodonGeneconv(newicktree, alignment_file, paralog, Model='HKY', Force=Force, clock=None) test.get_mle(True, True, 0, 'BFGS') #test.get_individual_summary(summary_path = './Summary/') #test.get_SitewisePosteriorSummary(summary_path = './Summary/')
def main(args): model = args.model paralog = [args.paralog1, args.paralog2] alignment_file = '../MafftAlignment/' + '_'.join(paralog) + '/' + '_'.join( paralog) + '_input.fasta' switched_alignment_file = './TestTau/' + '_'.join( paralog) + '/' + '_'.join(paralog) + '_switched.fasta' if args.switch: newicktree = './TestTau/YeastTestTree.newick' path = './TestTau/' summary_path = './TestTau/' else: newicktree = '../PairsAlignemt/YeastTree.newick' path = './NewPackageNewRun/' summary_path = './NewPackageNewRun/' omega_guess = 0.1 print('Now calculate MLE for pair', paralog) if args.force: if model == 'MG94': Force = {5: 0.0} elif model == 'HKY': Force = {4: 0.0} else: Force = None if args.gBGC: if args.dir: test = gBGCDirGeneconv(newicktree, alignment_file, paralog, Model=model, Force=Force, clock=args.clock) else: test = gBGCCodonGeneconv(newicktree, alignment_file, paralog, Model=model, Force=Force, clock=args.clock) else: if args.dir: test = DirGeneconv(newicktree, alignment_file, paralog, Model=model, Force=Force, clock=args.clock) else: test = ReCodonGeneconv(newicktree, alignment_file, paralog, Model=model, Force=Force, clock=args.clock) if model == 'MG94': method = 'BFGS' else: method = 'BFGS' result = test.get_mle(display=False, em_iterations=0, method=method) test.get_ExpectedNumGeneconv() test.get_ExpectedHetDwellTime() if model == 'MG94': test.get_individual_summary(summary_path=summary_path) if args.switch: if args.gBGC: if args.dir: test2 = gBGCDirGeneconv(newicktree, switched_alignment_file, paralog, Model=model, Force=Force, clock=args.clock) else: test2 = gBGCCodonGeneconv(newicktree, switched_alignment_file, paralog, Model=model, Force=Force, clock=args.clock) else: if args.dir: test2 = DirGeneconv(newicktree, switched_alignment_file, paralog, Model=model, Force=Force, clock=args.clock) else: test2 = ReCodonGeneconv(newicktree, switched_alignment_file, paralog, Model=model, Force=Force, clock=args.clock) result = test2.get_mle(display=False, em_iterations=0, method=method) test2.get_ExpectedNumGeneconv() test2.get_ExpectedHetDwellTime() test2.get_individual_summary(summary_path=summary_path + 'switched_')