-
Notifications
You must be signed in to change notification settings - Fork 0
/
bowtie2-loop-script
42 lines (33 loc) · 1.54 KB
/
bowtie2-loop-script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# A simple loop to serially map all samples against the bowtie2 indices.
# how many threads should each mapping task use?
NUM_THREADS=24
for sample in `ls /home/marcolabuser/Zach/LSU_Metagenomics/*_forward_paired_control.fq.gz`
do
dir="/home/marcolabuser/Zach/LSU_Metagenomics"
base=$(basename $sample "_forward_paired_control.fq.gz")
#use echo command to make sure the right files are being used
echo "bowtie2 \
--threads $NUM_THREADS \
-x /home/marcolabuser/Zach/LSU_Metagenomics/bowtie_index/contigs/contigs \
-1 ${dir}/${base}_forward_paired_control.fq.gz -2 ${dir}/${base}_reverse_paired_control.fq.gz \
--no-unal \
-S ${dir}/bowtie_index/${base}.sam \
--sensitive \
2>${dir}/bowtie_index/${base}_alignment.log"
#perform bowtie2 alignment in sensitive mode, write STDERR to logfile
bowtie2 \
--threads $NUM_THREADS \
-x /home/marcolabuser/Zach/LSU_Metagenomics/bowtie_index/contigs/contigs \
-1 ${dir}/${base}_forward_paired_control.fq.gz \
-2 ${dir}/${base}_reverse_paired_control.fq.gz \
--no-unal \
-S ${dir}/bowtie_index/${base}.sam \
--sensitive \
2>${dir}/bowtie_index/${base}_alignment.log
#generate and format BAM file from SAM file
samtools view -F 4 -bS ${dir}/bowtie_index/${base}.sam > ${dir}/bowtie_index/${base}-RAW.bam
anvi-init-bam ${dir}/bowtie_index/${base}-RAW.bam -o ${dir}/bowtie_index/${base}.bam
#delete unnecessary files
rm ${dir}/bowtie_index/${base}.sam ${dir}/bowtie_index/${base}-RAW.bam
done