annotate processMAF.sh @ 3:d49b9759e294 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit 3abc213e109bb564de7dee75d71d90eb1bf78c7e
author rnateam
date Thu, 15 Nov 2018 01:24:06 -0500
parents 434332033e82
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
1 #!/usr/bin/env bash
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
2 # RNAcode sometimes fails because of bugs. Since the manual suggests
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
3 # to call RNAcode on splitted alignments it is feasible to run
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
4 # RNAcode separately on the parts. This is implemented here. Command
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
5 # line parameters just passed on to RNAcode.
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
6 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
7 # - the script ensures that the region ids are continuous (otherwise
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
8 # the results for each block would start with 0)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
9 # - also eps file names are corrected accordingly
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
10 # if RNAcode fails for one part it just outputs the part (for bug reporting)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
11 # and continues
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
12
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
13 # for splitting the alignment you can use breakMAF.pl from the RNAcode
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
14 # github (it seems to be absent from the 0.3 release) and feed the output
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
15 # with the desired RNAcode parameters into this shell script, e.g.:
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
16 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
17 # breakMAF.pl < chrM.maf | ./processMAF.sh --tabular --eps --eps-dir eps2/
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
18
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
19 # parse the command line options
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
20 # - removes --outfile, --help, --version, and the input file from the arguments
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
21 # - outfile and infile are stored in variables
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
22 declare -a args=()
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
23 while [[ $# -gt 0 ]]
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
24 do
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
25 key="$1"
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
26 case $key in
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
27 -d|--eps-dir)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
28 epsdir=$2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
29 args+=($1 $2)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
30 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
31 shift # past value
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
32 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
33 -e|--eps)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
34 eps=1
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
35 args+=($1)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
36 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
37 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
38 -g|--gtf)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
39 gtf=1
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
40 args+=($1)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
41 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
42 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
43 -t|--tabular)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
44 tabular=1
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
45 args+=($1)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
46 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
47 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
48 -o|--outfile)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
49 outfile=$2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
50 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
51 shift # past value
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
52 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
53 -b|--best-only|-r|--best-region|-s|--stop-early)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
54 args+=($1)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
55 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
56 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
57 -n|--num-samples|-p|--cutoff|-c|--pars|-i|--eps-cutoff)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
58 args+=($1 $2)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
59 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
60 shift # past value
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
61 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
62 -h|--help|-v|--version)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
63 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
64 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
65 *) # unknown option
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
66 file=$1
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
67 shift # past argument
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
68 ;;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
69 esac
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
70 done
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
71
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
72 # fix output (renumber blocks)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
73 # and move eps files (if present) to tmpdir
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
74 function fix_output {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
75 if [[ -z "$last" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
76 last=0
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
77 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
78 while read line
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
79 do
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
80 if [[ -z "$gtf" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
81 i=`echo "$line" | sed 's/^\([[:digit:]]\+\)[[:space:]].*/\1/'`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
82 else
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
83 i=`echo $line | sed 's/.*Gene\([[:digit:]]\+\).*/\1/'`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
84 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
85 j=`echo "$i+$last" | bc`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
86 if [[ -z "$gtf" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
87 echo "$line" | sed "s/^\([[:digit:]]\+\)\([[:space:]].*\)/$j\2/"
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
88 else
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
89 echo "$line" | sed "s/^\(.*\)Gene[0-9]\+\(\".*\)$/\1Gene$j\2/"
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
90 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
91 #echo $line | awk -v n=$j '{printf("%d\t", n); for(i=2; i<=NF; i++){printf("%s", $(i)); if(i==NF){printf("\n")}else{printf("\t")}}}'
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
92 if [[ ! -z "$eps" && -f ${epsdir:-eps}/hss-$i.eps ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
93 mv ${epsdir:-eps}/hss-$i.eps $tmpd/hss-$j.eps
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
94 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
95 done
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
96 if [[ ! -z "$j" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
97 last=`echo "$j+1" | bc`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
98 unset j
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
99 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
100 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
101
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
102 # run RNAcode for $tempfile if >= 3 sequences
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
103 function run_rnacode {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
104 >&2 echo -e "processing " `cat ${tmpif} | grep ^s | head -n 1 | cut -d" " -f1-6`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
105 # >&2 echo "with RNAcode" $@
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
106 nl=`cat ${tmpif} | grep "^s" | wc -l`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
107 if [[ "$nl" -ge "3" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
108 # - filter the outfile for lines containing the ref and redirect everything to stderr
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
109 # https://github.com/wash/rnacode/issues/9
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
110 # - we can not pipe stdout | ... | fix_output since then $last can not be used as global variable
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
111 if [[ ! -z "$gtf" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
112 field=1
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
113 elif [[ ! -z "$tabular" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
114 field=7
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
115 else
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
116 field=6
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
117 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
118 RNAcode $@ | awk -v ref=$ref -v field=$field '{if($(field)==ref){print $0}else{$0 > "/dev/stderr"}}' > ${tmpof}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
119
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
120 if [[ "$?" != "0" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
121 ef=$(mktemp -u -p '.')
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
122 cat ${tmpif} > ${ef}.maf
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
123 >&2 echo "RNAcode failed for the alignmentblock \""`cat ${tmpif} | grep $ref | cut -d" " -f 1-6`"\" (${ef}.maf)"
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
124 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
125 fix_output < $tmpof
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
126 echo -n > ${tmpof}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
127 else
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
128 >&2 echo "less than 3 sequences in the alignment block \""`cat ${tmpif} | grep $ref | cut -d" " -f 1-6`"\""
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
129 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
130 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
131
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
132 ref=""
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
133 last=0
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
134
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
135 if [[ ! -z "$tabular" ]]; then
3
d49b9759e294 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit 3abc213e109bb564de7dee75d71d90eb1bf78c7e
rnateam
parents: 2
diff changeset
136 echo -e "HSS #\tStrand\tFrame\tLength\tFrom\tTo\tName\tStart\tEnd\tScore\tP" >> ${outfile:-/dev/stdout}
2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
137 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
138
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
139 tmpif=$(mktemp -p '.')
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
140 tmpof=$(mktemp -p '.')
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
141 tmpd=$(mktemp -d -p '.')
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
142
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
143 # process lines of the alignment
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
144 # - save lines to tmpif
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
145 # - empty lines: process tmpif (ie. last alignment block) with RNAcode, clear tmpif
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
146 # - on the go the name of the reference species is determined from the 1st line
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
147 # of the alignment this is used then for filtering the RNAcode output
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
148 # in case of gtf output only the chromosome is printed, ie only chr1 instead of dm6.chr1
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
149 while read line
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
150 do
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
151 if [[ "$line" =~ ^# ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
152 echo -n > ${tmpif}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
153 elif [[ "$line" =~ ^$ ]]; then
3
d49b9759e294 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit 3abc213e109bb564de7dee75d71d90eb1bf78c7e
rnateam
parents: 2
diff changeset
154 run_rnacode ${args[@]} ${tmpif} >> ${outfile:-/dev/stdout}
2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
155 echo -n > ${tmpif}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
156 else
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
157 if [[ -z $ref && "$line" =~ ^s ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
158 if [[ -z "$gtf" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
159 ref=`echo $line | cut -d" " -f 2`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
160 else
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
161 ref=`echo $line | sed 's/\./ /g' | cut -d" " -f 3`
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
162 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
163 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
164 echo $line >> ${tmpif}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
165 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
166 done < ${file:-/dev/stdin}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
167 # if there is something left -> process it
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
168 if [[ "`cat ${tmpif} | wc -l`" -gt "0" ]]; then
3
d49b9759e294 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit 3abc213e109bb564de7dee75d71d90eb1bf78c7e
rnateam
parents: 2
diff changeset
169 run_rnacode ${args[@]} ${tmpif} >> ${outfile:-/dev/stdout}
2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
170 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
171
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
172 if [[ ! -z "$eps" ]]; then
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
173 mv ${tmpd}/*eps ${epsdir:-eps}/
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
174 fi
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
175
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
176 rm ${tmpif}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
177 rm ${tmpof}
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
178 rmdir ${tmpd}