59
|
1 #!/bin/bash
|
|
2 TOOLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
3
|
|
4 echo "Started FALCO calling"
|
|
5
|
|
6 ## ----------
|
|
7 ## Variables setup ($1 contains the bash config file path)
|
|
8 ## ----------
|
|
9 source $1
|
|
10
|
|
11 ## ----------
|
|
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
|
|
22 ## ----------
|
|
23 if [[ $filter_file != 'None' && $filter_file != '' ]] # Galaxy default is "None" for some reason
|
|
24 then
|
|
25 FILTER_PARAM=" --filter "$filter_file
|
|
26 else
|
|
27 FILTER_PARAM=""
|
|
28 fi
|
|
29
|
|
30 if [[ $manifest_file != 'None' && $manifest_file != 'None' ]] # Galaxy default is "None" for some reason
|
|
31 then
|
|
32 MANIFEST_PARAM=" --manifest "$manifest_file
|
|
33 else
|
|
34 MANIFEST_PARAM=""
|
|
35 fi
|
|
36
|
|
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 vcf_base=$job_name
|
|
40
|
|
41 ## ----------
|
|
42 ## Status / debug
|
|
43 ## ----------
|
|
44 DEBUG=1
|
|
45 if [ $DEBUG ]
|
|
46 then
|
|
47 DBS="[INFO] "
|
|
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
|
|
57 fi
|
|
58
|
|
59 ## ----------
|
|
60 ## create output files dir
|
|
61 ## ----------
|
|
62 mkdir $out_path
|
|
63
|
|
64 ## ----------
|
|
65 ## running analysis
|
|
66 ## ----------
|
|
67 echo "[INFO] Starting FALCO reporting"
|
|
68 CMD_STRING="$TOOLDIR/falco/bin/falco-filter-report --vcf $vcf_file --output $vcf_base --qc_ann_qual_txt $qc_ann_qual_file --qc2_ann_txt $qc2_ann_txt_file --qc_targets_txt $qc_targets_txt_file"
|
|
69 echo "[INFO] "$CMD_STRING
|
|
70 perl $CMD_STRING
|
|
71 echo "[INFO] done with FALCO reporting"
|
|
72
|
|
73
|
|
74 ## ----------
|
|
75 ## create index html for main galaxy output
|
|
76 ## ----------
|
|
77 echo "<!DOCTYPE html>" >> $html_out
|
|
78 echo "<html>" >> $html_out
|
|
79 echo "<head>" >> $html_out
|
|
80 echo "<style>" >> $html_out
|
|
81 echo " body{ padding: 0px 20px; }" >> $html_out
|
|
82 echo " h1{ color: red; }" >> $html_out
|
|
83 echo " table{ border: 1px solid black; padding: 5px }" >> $html_out
|
|
84 echo "</style>" >> $html_out
|
|
85 echo "</head>" >> $html_out
|
|
86 echo "<body>" >> $html_out
|
|
87 echo " <h1>FALCO</h1>" >> $html_out
|
|
88 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
|
|
89 #echo " <a href=\"index.html\">HTML</a>" >> $html_out
|
|
90 echo " <table><tbody>" >> $html_out
|
|
91 for file in *.vcf *.txt *stderr *stdout
|
|
92 #for file in *
|
|
93 do
|
|
94 lineCount=`wc -l $file | cut -f 1 -d " "`
|
|
95 echo " <tr><td><a href=\"$file\">$file</a> has $lineCount lines</td></tr>" >> $html_out
|
|
96 echo " <tr><td> --> " `head -1 $file` "</td></tr>" >> $html_out
|
|
97 done
|
|
98 echo " </tbody></table>" >> $html_out
|
|
99 echo "</body>" >> $html_out
|
|
100 echo "</html>" >> $html_out
|
|
101
|
|
102 ## ----------
|
|
103 ## creating galaxy history outputs
|
|
104 ## ----------
|
|
105 cp 'index.html' $html_out # this is the overview of samples html
|
|
106 #cp $bam_base'.html' $out_path/'out.html' # this is the sample html
|
|
107
|
|
108 ## ----------
|
|
109 ## copy files to keep to output path
|
|
110 ## ----------
|
|
111 #cp -r ./$bam_base/*png $out_path/$bam_base/
|
|
112 #cp -r ./* $out_path
|
|
113 cp *.vcf $out_path; cp *.txt $out_path; cp *_std* $out_path
|
|
114
|
|
115 ## ----------
|
|
116 echo "END falco sh"
|
|
117 exit 0
|