forked from naumenko-sa/cre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bcbio.prepare_families.sh
executable file
·62 lines (48 loc) · 1.79 KB
/
bcbio.prepare_families.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
#!/bin/bash
# prepares a run of multiples families to run variant calling, one family may have several samples
# $1 - a file table.txt in the format
# sample_id family_id absolute_path_to_bam_file, i.e.
# 531_IN0067 531 /hpf/largeprojects/ccm_dccforge/dccdipg/dccc4r/c4r_wes/bam_files/531_IN0067.bam
# creates one project per family
#
# run with
# bcbio.prepare_families.sh table.txt &> file.log to track failed bams
# or
# qsub ~/bioscripts/bcbio.prepare_families.sh -v project_list=table.txt
# the scripts supposes it is install in ~/cre/ and bcbio is installed and available in the PATH
# uses
# bcbio.sample_sheet_header.csv
# bcbio.templates.exome.yaml
# to create table.txt from a directory of bam files with names family_sample.yyy.bam
# for f in *.bam;do echo $f | awk -F "." '{print $1"\t"$0}' | awk -F '_' '{print $2"\t"$0}' | awk -v dir=`pwd` '{print $1"\t"$2"\t"dir"/"$4}' >> ~/table.txt;done;
#PBS -l walltime=20:00:00,nodes=1:ppn=1
#PBS -joe .
#PBS -d .
#PBS -l vmem=10g,mem=10g
prepare_family()
{
local family=$1
mkdir -p ${family}/input
mkdir ${family}/work
cp ~/cre/bcbio.sample_sheet_header.csv $family.csv
while read sample fam bam
do
ln -s $bam ${family}/input/${sample}.bam
echo $sample","$sample","$family",,," >> $family.csv
done < $family.txt
bcbio_nextgen.py -w template ~/cre/bcbio.templates.exome.yaml $family.csv ${family}/input/*.bam
rm $family.csv
}
if [ -z $project_list ];
then
project_list=$1
fi
cat $project_list | awk '{print $2}' | sort | uniq > families.txt
cp families.txt projects.txt
for family in `cat families.txt`
do
# not grep because two family names may overlap
cat $project_list | awk -v fam=$family '{if ($2==fam) print $0}' > ${family}.txt
prepare_family $family
rm $family.txt
done