-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtrim_auto_2_file.sh
47 lines (37 loc) · 1.29 KB
/
trim_auto_2_file.sh
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
43
44
45
46
47
#!/bin/bash
#specify paths to your working directory and your reads directory
wok_dir='/home/dkiambi/Module4/'
read_dir=$wok_dir/reads
cd $wok_dir
#create an overall output directory
out_dir=$wok_dir/trim
#make separate output directories within the overall output directories; -p indicates to create the whole path
mkdir -p $out_dir/run_logs
mkdir -p $out_dir/slurm_scripts
mkdir -p $out_dir/trimming_output
reads=($(ls $read_dir))
#the reads are in pairs in folders, iterate over each pair
for READ in ${reads[@]}
do
READS_PATH=$read_dir/$READ
#specify the input reads and output names
R1=$READ'.r1.fastq.gz'
R2=$READ'.r2.fastq.gz'
R1_trimmed=$READ'.trimmed.fastq.gz'
#generate a unique slurm script for this pair
echo \
"#!/bin/bash -e
#SBATCH -p batch
#SBATCH -n 4
#SBATCH [email protected]
#SBATCH -o ./trim.%N.%j.out
#SBATCH -e ./trim.%N.%j.err
#SBATCH --mail-type=END,FAIL
#automatically loads 0.38
module load trimmomatic
#PE for paired end
trimmomatic PE -threads 4 $READS_PATH/$R1 $READS_PATH/$R2 -baseout $out_dir/trimming_output/$R1_trimmed \
LEADING:3 TRAILING:3 SLIDINGWINDOW:4:2 MINLEN:60 AVGQUAL:20 \
" > $out_dir/slurm_scripts/$READ'_trimmomatic_slurm.sh'
sbatch $out_dir/slurm_scripts/$READ'_trimmomatic_slurm.sh'
done