Mercurial > repos > yhoogstrate > featurecounts
annotate featurecounts2bed.sh @ 3:e04fbcc4e91a draft default tip
planemo upload for repository https://github.com/ErasmusMC-Bioinformatics/featurecounts_galaxy_wrapper commit 597fa3df643b54ea93a17448c722f657e3d68b60
author | yhoogstrate |
---|---|
date | Wed, 07 Oct 2015 11:38:41 -0400 |
parents | b5c93611d2c5 |
children |
rev | line source |
---|---|
0
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
1 #!/bin/bash |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
2 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
3 # featurecounts2bed - converts featureCounts output to BED format |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
4 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
5 # Copyright 2013-2014, Youri Hoogstrate |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
6 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
8 # it under the terms of the GNU General Public License as published by |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
10 # (at your option) any later version. |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
11 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
15 # GNU General Public License at <http://www.gnu.org/licenses/> for |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
16 # more details. |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
17 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
18 # This tool has been written by Youri Hoogstrate from the Erasmus |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
19 # Medical Center (Rotterdam, Netherlands) on behalf of the Translational |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
20 # Research IT (TraIT) project: |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
21 # http://www.ctmm.nl/en/programmas/infrastructuren/traitprojecttranslationeleresearch |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
22 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
23 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
24 exon_level="true" |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
25 filename="" |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
26 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
27 # Parse parameters |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
28 while getopts e:f: option |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
29 do |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
30 case "${option}" |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
31 in |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
32 e) exon_level=${OPTARG};; |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
33 f) filename=$OPTARG;; |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
34 esac |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
35 done |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
36 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
37 # Convert the file |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
38 if [ $filename == "" ]; then |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
39 echo "Usage:" |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
40 echo " -e [true, false] true = entry for every exon; false = line for genes first exon" |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
41 echo " -f FILENAME from featureCounts" |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
42 else |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
43 while read line; do |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
44 first=${line:0:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
45 if [ $first != "#" ]; then |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
46 columns=($line) |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
47 uid=${columns[@]:0:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
48 if [ $uid != "Geneid" ]; then |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
49 chr=${columns[@]:1:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
50 start=${columns[@]:2:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
51 stop=${columns[@]:3:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
52 direction=${columns[@]:4:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
53 length=${columns[@]:5:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
54 count=${columns[@]:6:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
55 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
56 chr_splitted=($(echo $chr | tr ";" "\n")) |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
57 start_splitted=($(echo $start | tr ";" "\n")) |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
58 stop_splitted=($(echo $stop | tr ";" "\n")) |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
59 strand_splitted=($(echo $direction | tr ";" "\n")) |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
60 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
61 if [ $exon_level == "true" ]; then |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
62 n=${#chr_splitted[@]} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
63 else |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
64 n=1 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
65 fi |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
66 |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
67 for (( i=0; i<$n; i++ )) |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
68 do |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
69 echo ${chr_splitted[@]:$i:1}" "${start_splitted[@]:$i:1}" "${stop_splitted[@]:$i:1}" "$uid" ("$((${stop_splitted[@]:$i:1}-${start_splitted[@]:$i:1}))"/"$length"nt) "$count" "${strand_splitted[@]:$i:1} |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
70 done |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
71 fi |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
72 fi |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
73 done < $filename |
ab0323782bb5
planemo upload for repository https://bitbucket.org/EMCbioinf/galaxy-tool-shed-tools/raw/master/featurecounts commit cc900436bad9c6cca1f73d438c1f158d3bfc4318-dirty
yhoogstrate
parents:
diff
changeset
|
74 fi |