-
Notifications
You must be signed in to change notification settings - Fork 0
/
crg.prepare_bcbio_run.sh
executable file
·60 lines (43 loc) · 1.38 KB
/
crg.prepare_bcbio_run.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
#!/bin/bash
# prepares family for bcbio run when input files are family_sample.bam or family_sample_1/2.fq.gz
echo "Parameters:"
#when this script is called from Python, Bash fails to split arguments on space
#using read is compatible when run from both command-line and Python
#$@ has all arguments passed to script
read -r family analysis <<< $(echo $@ | awk '{print $1, $2;}')
#family=$1
echo "family="$family
# analysis:
# -default
# -noalign
# -align_decoy
# -cnvkit
# -sv: no align, bam has to be cleaned after aligning to decoy, call SV, use a bed file for SV regions
# -small_variants
# -validate
#analysis=$2
echo "analysis="$analysis
cd $family
cp ~/cre/bcbio.sample_sheet_header.csv $family.csv
cd input
#there should be no other files except input fq.gz or bams in the input dir, bed files are ignored
ls | egrep -v ".bed$" | sed s/.bam// | sed s/.bai// | sed s/"_1.fq.gz"// | sed s/"_2.fq.gz"// | sort | uniq > ../samples.txt
cd ..
#no family is needed for single sample
while read sample
do
echo $sample","$sample","$family",,," >> $family.csv
done < samples.txt
#default template
template=~/crg/config/crg.bcbio.default.yaml
if [ -n "$analysis" ]
then
template=~/crg/config/crg.bcbio.$analysis.yaml
fi
echo "Using config template: " $template
bcbio_nextgen.py -w template $template $family.csv input/*
mv $family/config .
mv $family/work .
rm $family.csv
rmdir $family
cd ..