Commits

Giovanni Marco Dall'Olio committed 2592163

ADD: a script to create a batch file to launch positive simulations

  • Participants
  • Parent commits b7de7af

Comments (0)

Files changed (3)

File bin/model.test

-1	3.77941e-10
-29761	1.58486e-05
-29762	3.77941e-10
-42204	5.89969e-07
-42205	3.77941e-10
-42205	7.50514e-06
-42206	3.77941e-10
-44372	4.19899e-06
-44373	3.77941e-10
-49041	6.43195e-06
-49042	3.77941e-10
-57499	2.16034e-06
-57500	3.77941e-10
-65270	1.00436e-06
-65271	3.77941e-10
-106696	5.68301e-08
-106697	3.77941e-10
-108542	1.12141e-05
-108543	3.77941e-10
-108744	4.46872e-06
-108745	3.77941e-10
-150903	4.81381e-06
-150904	3.77941e-10
-156000	1.65204e-07
-156001	3.77941e-10
-156282	1.78179e-08
-156283	3.77941e-10
-162523	1.02660e-07
-162524	3.77941e-10
-172547	5.62925e-07
-172548	3.77941e-10
-184488	9.46549e-09
-184489	3.77941e-10
-184664	1.14035e-05
-184665	3.77941e-10
-211348	1.95265e-09
-211349	3.77941e-10
-224532	4.35420e-07
-224533	3.77941e-10
-250191	6.06932e-07
-250192	3.77941e-10
-250406	5.37313e-10
-250407	3.77941e-10
-254971	2.53684e-05
-254972	3.77941e-10
-255457	1.03111e-09
-255458	3.77941e-10
-257371	1.60828e-06
-257372	3.77941e-10
-259553	9.11885e-07
-259554	3.77941e-10
-259662	7.58679e-06
-259663	3.77941e-10
-270770	5.61837e-09
-270771	3.77941e-10
-271227	1.90773e-05
-271228	3.77941e-10
-271244	1.63797e-06
-271245	3.77941e-10
-271259	9.97257e-06
-271260	3.77941e-10
-289114	3.88320e-07
-289115	3.77941e-10
-289291	1.11963e-05
-289292	3.77941e-10
-289954	7.48615e-07
-289955	3.77941e-10
-290700	8.51531e-07
-290701	3.77941e-10
-298197	5.30204e-06
-298198	3.77941e-10
-319368	1.57674e-06
-319369	3.77941e-10
-323007	8.60956e-08
-323008	3.77941e-10
-323593	4.53830e-08
-323594	3.77941e-10
-327344	1.70941e-07
-327345	3.77941e-10
-333365	1.22971e-09
-333366	3.77941e-10
-333594	3.77941e-10
-333595	3.77941e-10
-333601	6.23437e-07
-333602	3.77941e-10
-335415	2.77678e-07
-335416	3.77941e-10
-339258	3.81915e-06
-339259	3.77941e-10
-341545	2.29996e-06
-341546	3.77941e-10
-341753	2.79587e-06
-341754	3.77941e-10
-349015	9.54847e-09
-349016	3.77941e-10
-349357	1.03575e-06
-349358	3.77941e-10
-362881	8.42847e-07
-362882	3.77941e-10
-404986	1.18154e-06
-404987	3.77941e-10
-405705	7.52449e-07
-405706	3.77941e-10
-405725	5.28603e-10
-405726	3.77941e-10
-412331	3.81084e-10
-412332	3.77941e-10
-429809	6.59553e-09
-429810	3.77941e-10
-430013	1.49192e-05
-430014	3.77941e-10
-437937	4.15220e-10
-437938	3.77941e-10
-447623	4.24340e-07
-447624	3.77941e-10
-447624	2.45066e-06
-447625	3.77941e-10
-462072	1.48698e-08
-462073	3.77941e-10
-470406	4.89214e-08
-470407	3.77941e-10
-470592	3.79427e-10
-470593	3.77941e-10
-471515	9.90847e-06
-471516	3.77941e-10
-478452	4.80144e-06
-478453	3.77941e-10
-499306	5.43030e-09
-499307	3.77941e-10
-519000	4.83018e-07
-519001	3.77941e-10
-521412	2.93323e-06
-521413	3.77941e-10
-522111	5.34041e-06
-522112	3.77941e-10
-523454	1.70283e-06
-523455	3.77941e-10
-529710	9.71163e-07
-529711	3.77941e-10
-529927	1.53416e-06
-529928	3.77941e-10
-532925	1.33904e-06
-532926	3.77941e-10
-581817	1.38178e-07
-581818	3.77941e-10
-581818	7.92382e-06
-581819	3.77941e-10
-590651	1.83720e-06
-590652	3.77941e-10
-606399	7.35884e-08
-606400	3.77941e-10
-610930	1.09446e-05
-610931	3.77941e-10
-617675	2.02582e-09
-617676	3.77941e-10
-621423	3.11311e-07
-621424	3.77941e-10
-624902	1.83868e-06
-624903	3.77941e-10
-627146	7.43833e-07
-627147	3.77941e-10
-630733	2.98900e-08
-630734	3.77941e-10
-638854	6.74400e-08
-638855	3.77941e-10
-639083	4.32968e-06
-639084	3.77941e-10
-658997	5.61351e-08
-658998	3.77941e-10
-659034	2.53464e-07
-659035	3.77941e-10
-659475	1.24170e-07
-659476	3.77941e-10
-659557	1.60565e-06
-659558	3.77941e-10
-673783	3.82368e-08
-673784	3.77941e-10
-674271	5.06022e-07
-674272	3.77941e-10
-690529	6.44553e-07
-690530	3.77941e-10
-692230	9.28690e-07
-692231	3.77941e-10
-701066	4.93853e-10
-701067	3.77941e-10
-701068	8.58739e-07
-701069	3.77941e-10
-701300	2.54325e-06
-701301	3.77941e-10
-701341	1.66425e-05
-701342	3.77941e-10
-712871	2.93964e-06
-712872	3.77941e-10
-714069	2.58602e-08
-714070	3.77941e-10
-714565	4.93259e-07
-714566	3.77941e-10
-722511	9.32584e-06
-722512	3.77941e-10
-733431	1.67456e-05
-733432	3.77941e-10
-736286	5.35142e-06
-736287	3.77941e-10
-801528	5.36447e-08
-801529	3.77941e-10
-801745	2.62432e-05
-801746	3.77941e-10
-804676	1.26204e-06
-804677	3.77941e-10
-805236	1.31477e-06
-805237	3.77941e-10
-808299	6.38127e-07
-808300	3.77941e-10
-842281	1.81167e-07
-842282	3.77941e-10
-842282	1.52172e-08
-842283	3.77941e-10
-842367	9.03718e-07
-842368	3.77941e-10
-842901	3.60543e-06
-842902	3.77941e-10
-843056	7.26718e-07
-843057	3.77941e-10
-874146	3.50732e-07
-874147	3.77941e-10
-887299	4.21014e-07
-887300	3.77941e-10
-947934	3.24056e-08
-947935	3.77941e-10
-948273	4.42803e-10
-948274	3.77941e-10
-955789	1.21364e-08
-955790	3.77941e-10
-955826	4.32215e-06
-955827	3.77941e-10
-957323	1.28761e-06
-957324	3.77941e-10
+1	5.76542e-10
+2448	7.95595e-10
+2449	5.76542e-10
+3702	6.15731e-09
+3703	5.76542e-10
+14387	7.31960e-10
+14388	5.76542e-10
+29296	1.39432e-09
+29297	5.76542e-10
+29366	6.28296e-10
+29367	5.76542e-10
+58562	5.82095e-10
+58563	5.76542e-10
+62046	6.44049e-10
+62047	5.76542e-10
+88759	1.29644e-09
+88760	5.76542e-10
+89319	2.53081e-09
+89320	5.76542e-10
+92019	5.83413e-10
+92020	5.76542e-10
+99569	2.02361e-09
+99570	5.76542e-10
+100276	9.05275e-09
+100277	5.76542e-10
+100277	3.31552e-09
+100278	5.76542e-10
+104084	1.44593e-09
+104085	5.76542e-10
+104426	6.66696e-10
+104427	5.76542e-10
+105587	8.28148e-10
+105588	5.76542e-10
+138893	2.19465e-09
+138894	5.76542e-10
+139853	1.43127e-09
+139854	5.76542e-10
+151912	2.43016e-09
+151913	5.76542e-10
+161568	2.14336e-09
+161569	5.76542e-10
+161626	6.13406e-10
+161627	5.76542e-10
+161630	5.23891e-09
+161631	5.76542e-10
+196010	1.18954e-09
+196011	5.76542e-10
+202627	3.09858e-09
+202628	5.76542e-10
+242018	6.22944e-10
+242019	5.76542e-10
+250892	9.36463e-10
+250893	5.76542e-10
+261067	1.23632e-09
+261068	5.76542e-10
+270389	1.00396e-09
+270390	5.76542e-10
+270627	1.55468e-09
+270628	5.76542e-10
+270630	2.19958e-09
+270631	5.76542e-10
+271034	5.95418e-10
+271035	5.76542e-10
+271085	1.72665e-09
+271086	5.76542e-10
+282074	3.07337e-09
+282075	5.76542e-10
+282076	8.31615e-10
+282077	5.76542e-10
+301915	5.76543e-10
+301916	5.76542e-10
+306546	2.22914e-09
+306547	5.76542e-10
+306674	3.32663e-09
+306675	5.76542e-10
+307905	8.63283e-10
+307906	5.76542e-10
+312327	6.62863e-10
+312328	5.76542e-10
+312348	7.34354e-10
+312349	5.76542e-10
+312827	6.03516e-10
+312828	5.76542e-10
+315448	1.37249e-09
+315449	5.76542e-10
+315449	5.90647e-10
+315450	5.76542e-10
+317691	5.80495e-10
+317692	5.76542e-10
+317827	9.07572e-10
+317828	5.76542e-10
+320977	1.06565e-09
+320978	5.76542e-10
+360947	1.23765e-09
+360948	5.76542e-10
+383687	5.79120e-10
+383688	5.76542e-10
+400744	5.76543e-10
+400745	5.76542e-10
+406232	3.34405e-09
+406233	5.76542e-10
+409286	5.76958e-10
+409287	5.76542e-10
+418140	9.83097e-10
+418141	5.76542e-10
+424773	5.76557e-10
+424774	5.76542e-10
+496286	2.24667e-09
+496287	5.76542e-10
+500049	1.10834e-09
+500050	5.76542e-10
+510841	3.35967e-09
+510842	5.76542e-10
+510842	6.31546e-10
+510843	5.76542e-10
+512775	9.01526e-10
+512776	5.76542e-10
+523773	7.42348e-09
+523774	5.76542e-10
+528725	5.87996e-10
+528726	5.76542e-10
+528750	5.78152e-10
+528751	5.76542e-10
+528965	5.76552e-10
+528966	5.76542e-10
+565463	6.87686e-10
+565464	5.76542e-10
+565521	5.76976e-10
+565522	5.76542e-10
+565695	1.01073e-09
+565696	5.76542e-10
+568413	1.71879e-09
+568414	5.76542e-10
+569335	4.52598e-09
+569336	5.76542e-10
+577820	6.92407e-09
+577821	5.76542e-10
+581276	5.80817e-10
+581277	5.76542e-10
+583630	5.76674e-10
+583631	5.76542e-10
+583719	7.19084e-10
+583720	5.76542e-10
+592241	5.80364e-10
+592242	5.76542e-10
+610585	5.71780e-09
+610586	5.76542e-10
+634825	1.94264e-09
+634826	5.76542e-10
+636807	3.34944e-09
+636808	5.76542e-10
+636914	5.78992e-10
+636915	5.76542e-10
+636941	7.22016e-10
+636942	5.76542e-10
+641764	5.76573e-10
+641765	5.76542e-10
+642610	5.91168e-10
+642611	5.76542e-10
+642625	6.37552e-09
+642626	5.76542e-10
+646800	4.87295e-09
+646801	5.76542e-10
+646932	8.04685e-10
+646933	5.76542e-10
+690394	7.03442e-10
+690395	5.76542e-10
+706380	6.29235e-10
+706381	5.76542e-10
+707072	6.49183e-10
+707073	5.76542e-10
+707166	5.79039e-10
+707167	5.76542e-10
+709082	6.89579e-10
+709083	5.76542e-10
+709093	1.20532e-09
+709094	5.76542e-10
+713954	1.09982e-09
+713955	5.76542e-10
+722346	2.65308e-09
+722347	5.76542e-10
+727996	1.16790e-09
+727997	5.76542e-10
+727997	1.84185e-09
+727998	5.76542e-10
+732765	7.69141e-10
+732766	5.76542e-10
+744270	3.08566e-09
+744271	5.76542e-10
+744273	1.07492e-09
+744274	5.76542e-10
+745213	5.83360e-10
+745214	5.76542e-10
+747011	5.76615e-10
+747012	5.76542e-10
+755835	1.38685e-09
+755836	5.76542e-10
+767156	5.78072e-10
+767157	5.76542e-10
+785366	8.13902e-10
+785367	5.76542e-10
+786098	6.91417e-09
+786099	5.76542e-10
+792492	6.01580e-10
+792493	5.76542e-10
+793323	9.64640e-10
+793324	5.76542e-10
+803334	9.13485e-09
+803335	5.76542e-10
+806587	5.76543e-10
+806588	5.76542e-10
+821435	3.20157e-09
+821436	5.76542e-10
+856110	6.54188e-10
+856111	5.76542e-10
+857742	5.76556e-10
+857743	5.76542e-10
+864463	5.02227e-09
+864464	5.76542e-10
+864651	1.36647e-09
+864652	5.76542e-10
+866153	1.01544e-09
+866154	5.76542e-10
+867749	5.80517e-10
+867750	5.76542e-10
+879408	8.93642e-10
+879409	5.76542e-10
+879475	5.95279e-10
+879476	5.76542e-10
+879477	6.19286e-10
+879478	5.76542e-10
+909232	6.08113e-10
+909233	5.76542e-10
+912491	6.66696e-10
+912492	5.76542e-10
+912543	6.06150e-10
+912544	5.76542e-10
+928528	1.09608e-09
+928529	5.76542e-10
+928559	5.76554e-10
+928560	5.76542e-10
+934271	5.67149e-09
+934272	5.76542e-10
+934277	2.04552e-09
+934278	5.76542e-10
+941709	7.11019e-10
+941710	5.76542e-10
+951075	5.77253e-10
+951076	5.76542e-10
+955118	7.16754e-10
+955119	5.76542e-10
+955121	6.34212e-10
+955122	5.76542e-10
+958291	8.88664e-10
+958292	5.76542e-10
+974255	6.84466e-10
+974256	5.76542e-10
+996239	5.98953e-10
+996240	5.76542e-10
+996240	7.10683e-10
+996241	5.76542e-10
 # per bp per generation
 mutation_rate 1.5e-8
 
-#recomb_file /lustre/scratch103/sanger/igr/simulations/model.test_75
+#recomb_file /lustre/scratch103/sanger/igr/simulations/model.test_12
 gene_conversion_rate 4.5e-9
 
 # population info
 
 pop_event change_size "african pop size" 3 17000 12500
 
-pop_event sweep "selective sweep" 3 0 0.0172 0.5 1
+pop_event sweep "selective sweep" 3 0 0.0415 0.5 0.4
  

File launch_simulations_positive.py

+#!/usr/bin/env python
+"""
+"""
+
+import subprocess
+import re
+import argparse
+import os
+import sys
+import glob
+
+
+
+# General parameters (paths, etc.) (modify them to fit to your system)!!!!!!!!!!!! 
+simulationDataFolder = '/home/gioby/workspace/cnag-simulations/cosi_1.2/examples/bestfit/'
+outputFolder = '/home/gioby/workspace/cnag-simulations/results/'
+
+paramsFile = simulationDataFolder + 'params'
+run_simulations = simulationDataFolder + 'run.pl'
+cosi_to_plink = simulationDataFolder + 'cosi_to_plink.pl'
+
+popDict = {'EUR': 1, 'ASN': 2, 'AFR': 3}
+
+
+
+
+def launch_simulation_folder_of_parameters(params_folder, convert_to_plink=False):
+    """
+    Scan a directory for files containing cosi parameters, and launch cosi on each of them
+
+
+    For each file in params_folder:
+    - copy params file into bin/ folder
+    - call cosi through the run.pl script
+    - convert output to plink
+    - move the outputs to the outputdir folder
+
+    """
+    bin_folder = os.getcwd() + '/bin/'
+#    bin_folder = './bin/'
+    params_folder = os.getcwd() + '/params/'
+    results_folder = os.getcwd() + '/results/'
+#    print bin_folder, params_folder
+    print """#!/bin/bash
+# @ job_name = test
+# @ initialdir = .
+# @ output = output_%j.out
+# @ error = error_%j.out
+# @ total_tasks = 1
+# @ wall_clock_limit = 00:02:00
+
+# limit RAM to 6 GB (in KB)
+ulimit -v 6000000
+"""
+    os.chdir(bin_folder)
+    print 'cd %s' % bin_folder
+#    print glob.glob(params_folder)
+#    print glob.glob('./*')
+
+    for param_file in glob.glob(params_folder + "*"):
+        scenario_id = param_file.rsplit('_', 1)[1]
+#        print ('----'*20)
+#        print scenario_id
+#    param_file_fullpath = params_folder + '/' + param_file
+#        subprocess.call(['cp', param_file, bin_folder + '/params'])
+        print('')
+        print('cp ' + param_file + ' ' + 'params')
+        print('perl run.pl ' + bin_folder + 'params')
+        
+#        subprocess.call(['./run.pl ', bin_folder + 'params'])
+#        subprocess.call(['perl', bin_folder + 'run.pl '])
+#        print param_file
+
+        coreName = 'cosi_60ind_'
+        # convert to PLINK
+        if convert_to_plink:
+#            oldMapFile = coreName + population + '.map'
+#            oldHapFile = coreName + population + '.ped'
+#            newMapFile = outputFolder + 'bestfit_neutral_params_' + population + '_neutral_' + str(scenario_id) + '.map'
+#            newHapFile = outputFolder + 'bestfit_neutral_params_' + population + '_neutral_' + str(scenario_id) + '.ped'
+#
+#            print('perl cosi_to_plink.pl')
+#            print('cp %s %s' %(oldMapFile, newMapFile ))
+#            print('cp %s %s' %(oldHapFile, newHapFile ))
+
+            pass
+        
+        # Copy simulated data to output data folder
+#        print('cp *.map *.ped %s' % results_folder )
+   #
+        # Move out.pos-1/2/3 and out.hap-1/2/3 files
+        print('mkdir %s' % outputFolder + '/param_' + scenario_id)
+
+        print('mv %s %s' % ("out.hap-1", outputFolder + '/param_' + scenario_id + '/selection_params_' + str(scenario_id) + '.hap-1')) 
+        print('mv %s %s' % ("out.hap-2", outputFolder + '/param_' + scenario_id + '/selection_params_' + str(scenario_id) + '.hap-2')) 
+        print('mv %s %s' % ("out.hap-3", outputFolder + '/param_' + scenario_id + '/selection_params_' + str(scenario_id) + '.hap-3')) 
+        print('mv %s %s' % ("out.pos-1", outputFolder + '/param_' + scenario_id + '/selection_params_' + str(scenario_id) + '.pos-1')) 
+        print('mv %s %s' % ("out.pos-2", outputFolder + '/param_' + scenario_id + '/selection_params_' + str(scenario_id) + '.pos-2')) 
+        print('mv %s %s' % ("out.pos-3", outputFolder + '/param_' + scenario_id + '/selection_params_' + str(scenario_id) + '.pos-3')) 
+
+#        print( 'rm ' + 'out*' )
+#        print( 'rm ' + coreName + '*')
+
+
+
+
+
+
+
+
+
+
+
+
+
+if __name__ == '__main__':
+    params_folder = 'params/'
+    launch_simulation_folder_of_parameters(params_folder)
+