25
|
1 #!/bin/bash
|
|
2 TOOLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
3
|
39
|
4 echo "Started FALCO calling"
|
25
|
5
|
|
6 ## ----------
|
58
|
7 ## Variables setup ($1 contains the bash config file path)
|
25
|
8 ## ----------
|
|
9 source $1
|
|
10
|
|
11 ## ----------
|
53
|
12 ## make sure all is ok
|
|
13 ## ----------
|
|
14 if [ ! -f $REF_FILE".fai" ]
|
|
15 then
|
|
16 echo "No FAI index (fai) found for reference fasta [$REF_FILE]"
|
|
17 exit "No FAI index (fai) found for reference fasta [$REF_FILE]"
|
|
18 fi
|
|
19
|
|
20 ## ----------
|
|
21 ## set params
|
25
|
22 ## ----------
|
58
|
23 if [[ $filter_file != 'None' && $filter_file != '' ]] # Galaxy default is "None" for some reason
|
25
|
24 then
|
39
|
25 FILTER_PARAM=" --filter "$filter_file
|
25
|
26 else
|
39
|
27 FILTER_PARAM=""
|
25
|
28 fi
|
|
29
|
58
|
30 if [[ $manifest_file != 'None' && $manifest_file != 'None' ]] # Galaxy default is "None" for some reason
|
39
|
31 then
|
|
32 MANIFEST_PARAM=" --manifest "$manifest_file
|
|
33 else
|
|
34 MANIFEST_PARAM=""
|
|
35 fi
|
25
|
36
|
58
|
37 ## name of file in galaxy not always set so will use a user-set job_name instead
|
|
38 #bam_base=`echo $bam_name | sed 's#.bam$##' - `
|
|
39 bam_base=$job_name
|
|
40
|
25
|
41 ## ----------
|
|
42 ## Status / debug
|
|
43 ## ----------
|
39
|
44 DEBUG=1
|
|
45 if [ $DEBUG ]
|
|
46 then
|
|
47 DBS="[INFO] "
|
53
|
48 echo $DBS"FILTER: "$filter_file
|
|
49 echo $DBS"MANIFEST: "$manifest_file
|
|
50 echo $DBS"REF FILE: "$REF_FILE
|
|
51 echo $DBS"DB KEY: "$DB_KEY
|
|
52 echo $DBS"REF SRC: "$REF_SOURCE
|
|
53 echo $DBS"BAM FILE: "$bam_file
|
|
54 echo $DBS"BAM NAME: "$bam_name
|
|
55 echo $DBS"BAM BASE: "$bam_base
|
|
56 echo $DBS"OUT PATH: "$out_path
|
39
|
57 fi
|
25
|
58
|
|
59 ## ----------
|
|
60 ## create output files dir
|
|
61 ## ----------
|
38
|
62 mkdir $out_path
|
25
|
63
|
|
64 ## ----------
|
|
65 ## running analysis
|
|
66 ## ----------
|
58
|
67 echo "[INFO] Starting variant calling"
|
59
|
68 ## NOTE: if $FILTER_PARAM is set it includes the param name (--filter)
|
|
69 ## NOTE: if $MANIFEST_PARAM is set it includes the param name (--manifest)
|
39
|
70 CALL_STRING="$TOOLDIR/falco/bin/falco --bam $bam_file --output $bam_base --ref $REF_FILE $FILTER_PARAM $MANIFEST_PARAM"
|
|
71 echo "[INFO] "$CALL_STRING
|
|
72 perl $CALL_STRING
|
58
|
73 echo "[INFO] done with variant calling"
|
25
|
74
|
|
75
|
|
76 ## ----------
|
|
77 ## create index html for main galaxy output
|
|
78 ## ----------
|
38
|
79 echo "<!DOCTYPE html>" >> $html_out
|
|
80 echo "<html>" >> $html_out
|
|
81 echo "<head>" >> $html_out
|
|
82 echo "<style>" >> $html_out
|
|
83 echo " body{ padding: 0px 20px; }" >> $html_out
|
|
84 echo " h1{ color: red; }" >> $html_out
|
|
85 echo " table{ border: 1px solid black; padding: 5px }" >> $html_out
|
|
86 echo "</style>" >> $html_out
|
|
87 echo "</head>" >> $html_out
|
|
88 echo "<body>" >> $html_out
|
|
89 echo " <h1>FALCO</h1>" >> $html_out
|
39
|
90 echo " <p>This page is way to get output files that are not implemented in galaxy history, it is not intended to be a user-friendly way of displaying anything ;)</p>" >> $html_out
|
|
91 #echo " <a href=\"index.html\">HTML</a>" >> $html_out
|
38
|
92 echo " <table><tbody>" >> $html_out
|
39
|
93 for file in *.vcf *.txt *stderr *stdout
|
|
94 #for file in *
|
38
|
95 do
|
|
96 lineCount=`wc -l $file | cut -f 1 -d " "`
|
|
97 echo " <tr><td><a href=\"$file\">$file</a> has $lineCount lines</td></tr>" >> $html_out
|
39
|
98 echo " <tr><td> --> " `head -1 $file` "</td></tr>" >> $html_out
|
38
|
99 done
|
|
100 echo " </tbody></table>" >> $html_out
|
|
101 echo "</body>" >> $html_out
|
|
102 echo "</html>" >> $html_out
|
25
|
103
|
|
104 ## ----------
|
|
105 ## creating galaxy history outputs
|
|
106 ## ----------
|
|
107 #cp 'index.html' $html_out # this is the overview of samples html
|
|
108 #cp $bam_base'.html' $out_path/'out.html' # this is the sample html
|
39
|
109 cp $bam_base'.falco.vcf' $vcf_out
|
59
|
110 cp $bam_base'.qc.ann.qual.txt' $qc_ann_qual_out
|
|
111 cp $bam_base'.qc2.ann.txt' $qc2_ann_txt_out
|
|
112 cp $bam_base'.qc.targets.txt' $qc_targets_txt_out
|
25
|
113
|
|
114 ## ----------
|
|
115 ## copy files to keep to output path
|
|
116 ## ----------
|
|
117 #cp -r ./$bam_base/*png $out_path/$bam_base/
|
|
118 #cp -r ./* $out_path
|
39
|
119 cp *.vcf $out_path; cp *.txt $out_path; cp *_std* $out_path
|
25
|
120
|
|
121 ## ----------
|
|
122 echo "END falco sh"
|
58
|
123 exit 0
|