#!/usr/bin/env bash # # Sweeps through the bowtie2 parameters space. # # Based on a script by Fan Song. # # Usage: # # bash bowtie2-parameter-sweep.sh # # or to set an error rate of 10% # # bash bowtie2-parameter-sweep.sh 0.1 # # set -ue # Default value for the script. ERR=${1:-0.02} # Make a directory mkdir -p temp # This will be the reference. REF=temp/GENOME.fa # Get the data echo "# Getting a reference" efetch -db=nuccore -format=fasta -id=AF086833 > $REF # Build an index from the genome. echo "# Building the index" bowtie2-build $REF $REF > temp/log1 2>> temp/log2 # Generate a simulated genome. echo "# Simulating a genome with error rate=$ERR" wgsim -N 10000 -e $ERR $REF R1.fq R2.fq > temp/log1 2>> temp/log2 # Set read names. R1=R1.fq R2=R2.fq # Generate parameter sweep. printf "Concord\tDiscord\tOneTime\tParams\n" for D in {5..15}; do for R in {1..3}; do for N in {0..1}; do for L in {15..25}; do for i1 in {0..1}; do for i2 in `seq 0.5 0.25 2.5`; do bowtie2 -x $REF -1 $R1 -2 $R2 -S output.sam -D $D -R $R -N $N -L $L -i S,${i1},${i2} 2> tmp conc=`grep "aligned concordantly exactly 1 time" tmp | awk '{print $1}'` disc=`grep "aligned discordantly 1 time" tmp | awk '{print $1}'` onet=`grep "aligned exactly 1 time" tmp | awk '{print $1}'` printf "%d\t%d\t%d\t(%d,%d,%d,%d,%d,%.2f)\n" $conc $disc $onet $D $R $N $L $i1 $i2 done done done done done done