Created
February 15, 2013 14:27
-
-
Save dalloliogm/4960696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Wrapper to launch a single cosi iteration | |
# | |
# COSI ( http://www.broadinstitute.org/~sfs/cosi/ ) is a software to simulate Human Genetic Variation | |
# (see http://genome.cshlp.org/content/15/11/1576.full for the reference). | |
# It can be used to simulate SNP data of 3 human populations, EUR, AFR and ASN. | |
# | |
# This script is a wrapper to launch multiple COSI simulations in parallel, using the GNU/parallel tool | |
# | |
# | |
# | |
# INSTALLMENT AND REQUIRED FILES | |
# | |
# 1. Download the cosi tool from http://www.broadinstitute.org/~sfs/cosi/ | |
# 2. create a new folder, e.g. mkdir cosi_run | |
# 3. copy this script in the new folder | |
# 4. copy the following files from the cosi .tar distribution to the new folder: | |
# cosi/coalescent | |
# cosi/recosim | |
# examples/bestfit/autosomes_deCODE.distr | |
# examples/bestfit/model.test | |
# examples/bestfit/params | |
# examples/bestfit/recParams | |
# (alternatively, use your own params files) | |
# | |
# 5. Launch the simulations, using GNU/parallel: | |
# | |
# $: seq 1 100 | parallel "./launch_single_cosi_iteration.sh {} outputfolder" | |
# | |
# See below for more options. | |
# | |
# | |
# | |
# | |
# USING THIS SCRIPT TO LAUNCH COSI SIMULATIONS | |
# | |
# | |
# There are two recommended ways to run this script: from bash using parallel, or from | |
# a sun grid engine environment using qsub. To use one or another, you need to uncomment the lines | |
# defining REPLICA_ID and OUTPUTDIR. | |
# | |
# - Launching from bash using parallel: | |
# | |
# Make sure you are using GNU/parallel and not the standard parallel from moreutils. | |
# The syntax should be only slightly different between the two: | |
# | |
# Gnu/Parallel: | |
# | |
# $: seq 1 100 | parallel "./launch_single_cosi_iteration.sh {} outputfolder" | |
# | |
# Parallel from moreutils: | |
# | |
# $: seq 1 100 | parallel -i sh ./launch_single_cosi_iteration.sh {} outputfolder | |
# | |
# | |
# | |
# | |
# - Launching in a Sun Grid Engine environment: | |
# | |
# Customize the qsub options below (any line beginning with #$ will be interpreted as a qsub parameter). | |
# | |
# Then, launch the script from qsub: | |
# | |
# $: qsub launch_single_cosi_iteration.sh | |
# | |
# QSUB options | |
# | |
#$ -cwd | |
#$ -l h_vmem=600M | |
#$ -j y | |
#$ -N cosi5000 | |
#$ -o logs | |
#$ -V | |
# Use the -t option to define how many simulations you want. | |
# E.g. -t 1-1000 will launch 1000 simulations | |
#$ -t 3-1000 | |
# | |
# | |
# NOTES TO THE CODE IN THIS SCRIPT: | |
# | |
# * Each iteration is run in a single directory, defined by $ITERATION_ID | |
# * All the files necessary are copied in the directory | |
# * The recombination model is calculated by recosim for each iteration. | |
# | |
# $1 -> iteration number (usually I execute 100 iteration for each set of parameters) | |
# $2 -> base output folder | |
# | |
##### CONFIGURATION | |
### Parallel - uncomment the next two lines if you are using parallel: | |
REPLICA_ID=$1 | |
OUTPUTDIR=$2 | |
### SGE environment - uncomment the next two lines if you are using SGE: | |
#REPLICA_ID=$SGE_TASK_ID | |
#OUTPUTDIR=../../data/simulations_5000 | |
# Copy all cosi binaries to a temporary subfolder of the output directory | |
mkdir -p ${OUTPUTDIR}/tmp/${REPLICA_ID} | |
mkdir -p ${OUTPUTDIR}/param_logs | |
mkdir -p ${OUTPUTDIR}/results | |
cp autosomes_deCODE.distr params recParams recosim coalescent ${OUTPUTDIR}/tmp/${REPLICA_ID} | |
#cp autosomes_deCODE.distr recosim coalescent ${OUTPUTDIR}/${REPLICA_ID} | |
cp recParams ${OUTPUTDIR}/tmp/${REPLICA_ID}/bestfit_neutral_replica_${REPLICA_ID} | |
cd ${OUTPUTDIR}/tmp/${REPLICA_ID} | |
# generate the recombination model (model.test), and run cosi | |
./recosim bestfit_neutral_replica_${REPLICA_ID} 1000000 | |
./coalescent -p ./params -o ../../results/bestfit_neutral_replica_${REPLICA_ID} | |
gzip -f ../../results/bestfit_neutral_replica_${REPLICA_ID}.* | |
# Clean the temporary subfolder, and move all results to output dir | |
rm coalescent recosim | |
mv model.test ../../param_logs/bestfit_neutral_replica_rec_${REPLICA_ID} | |
gzip -f ../../param_logs/bestfit_neutral_replica_rec_${REPLICA_ID} | |
#rm model.test | |
#gzip ../../param_logs/bestfit_neutral_replica_decode_${REPLICA_ID} | |
#mv autosomes_deCODE.distr ../../param_logs/bestfit_neutral_replica_decode_${REPLICA_ID} | |
rm autosomes_deCODE.distr | |
#gzip ../../param_logs/bestfit_neutral_replica_decode_${REPLICA_ID} | |
#mv recParams ../../param_logs/bestfit_neutral_rec_replica_${REPLICA_ID} | |
#gzip ../../param_logs/bestfit_neutral_rec_replica_${REPLICA_ID} | |
rm recParams | |
rm params | |
rm bestfit_neutral_replica_${REPLICA_ID} | |
cd .. | |
rmdir ${REPLICA_ID} | |
#cd .. | |
#rmdir ${OUTPUTDIR} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment