-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbcl2eyre.sh
63 lines (39 loc) · 1.84 KB
/
bcl2eyre.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
input=${1?Error:no SampleSheet.csv given}
dir=$( dirname $input)
### Load module
source /phe/tools/miniconda3/etc/profile.d/conda.sh
conda activate eyre
### Running bcl2fastq
BCL=$(sbatch --job-name bcl2fastq --mem 100G --ntasks 16 --time 960:00:00 -D /phe/tools/eyre/log/ --wrap "bcl2fastq --sample-sheet $input --runfolder-dir $dir --no-lane-splitting --ignore-missing-bcls --ignore-missing-filter --ignore-missing-positions --output-dir $dir/BaseCalls")
### Create folder
folder=$(awk -F ',' 'FNR == 4 {print $2}' $input)
mkdir -p /scratch/eyre/$folder
cd /scratch/eyre/$folder
### Creating config file
awk -F ',' 'BEGIN{ print "samples:"}; FNR > 21 {if($0 !~/NEG/ && $0 !~/Metagenomic/) print "- " $2|"sort -u"}' $input > config.yaml
awk -F ',' 'BEGIN{ print "negative:"}; ( $0 ~/NEG/ ){print "- " $2 }' $input >> config.yaml
### Create input folder
mkdir -p /scratch/eyre/$folder/input
cd /scratch/eyre/$folder/input
### Pausing following jobs until bcl2fastq started properly
secs=$((30))
while [ $secs -gt 0 ]; do
echo -ne "Waiting $secs\033[0K\r"
sleep 1
: $((secs--))
done
### Create symlinks
for i in `ls $dir/BaseCalls/$folder/*.fastq.gz | cut -f 8 -d "/" | cut -f 1 -d "_" | sort -u`
do
ln -fs $dir/BaseCalls/$folder/"$i"_*R1_001.fastq.gz /scratch/eyre/$folder/input/"$i"_R1.fastq.gz
ln -fs $dir/BaseCalls/$folder/"$i"_*R2_001.fastq.gz /scratch/eyre/$folder/input/"$i"_R2.fastq.gz
done
### Load eyre module
source /phe/tools/miniconda3/etc/profile.d/conda.sh
conda activate eyre
## Identify job_id of bcl2fastq on slurm
array=(${BCL// / })
JOBID=${array[3]}
### Running eyre on slurm
sbatch --dependency=afterok:${JOBID} --job-name eyre --mem 100G --ntasks 16 --time 960:00:00 -D /scratch/eyre/$folder/ --wrap "snakemake -j 16 --configfile /scratch/eyre/$folder/config.yaml --snakefile /phe/tools/eyre/scripts/Snakefile"