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