Mercurial > repos > alermine > nebula
diff [APliBio]Nebula tools suite/Nebula/FindPeaks/findPeaks_wrapper.sh @ 0:2ec3ba0e9e70 draft
Uploaded
author | alermine |
---|---|
date | Thu, 25 Oct 2012 08:18:25 -0400 |
parents | |
children | 5d392b477172 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/[APliBio]Nebula tools suite/Nebula/FindPeaks/findPeaks_wrapper.sh Thu Oct 25 08:18:25 2012 -0400 @@ -0,0 +1,136 @@ +#:t:::::::::::::::::g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#:t::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#:::::::::::::z;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#::::::::::::i@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@$@@@@ +#:::::::::::3@@@@@@@@@@@@@@@@@@@@@@@@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#::::::::::3@@@@@@@@@@@@@@@@@@@@@BEEESSE5EEEEBBM@@@@@@@@@@@@@@@@@@@@@@@@@@ +#::::::::::3@@@@@@@@@@@@@@@@@@@@BEEEEEE35EE55E2355E5SBMB@@@@@@@@@@@@@@@@@$ +#::::::::::@@@@@@@@@@@@@@@@@@@EEEE55533t3tttt::::::!!!!7755E755SBBMMM@@@MM +#::::::::::3@@@@@@@@@@@@@@@@@@EEEE2t3ttttt:::::::::::::::::::::::!7?5225EE +#::::::::::3@@@@@@@@@@@@@@@@@@EEEEE31t::::::::::::::::::::::::::::::::3E5@ +#::::::::::3@@@@@@@@@@@@@@@@@@EEEEEEtt:::::::::::::::::::::::::::::::::353 +#::::::::::3@@@@@@@@@@@@@@@@@@EEEEEE1ttz::::::::::::::::::::::::::::::::35 +#:::::::::::@@@@@@@@@@@@@@@@@@EEEEEEEtz1::::::::::::::::::::::::::::::::t: +#:::::::::!3@@@@@@@@@@@@@@@@@@@EEEEEttt::::::::::::::::::::::::::::::::;zz +#::::::::::@@@@@@@@@@@@@@@@@@@@EEEEEttt:::::z;z:::::::::::::::::::::::::13 +#::::::::::3B@@@@@@@@@@@@@@@@@@EEEEEEE3tt:czzztti;:::::::::::::::::::::::3 +#::::ttt::::3@@@@@@@@@@@@@@@@EEEEE5EE25Ezt1EEEz5Etzzz;;;;::::::::::::::::: +#:::::::::::I9@@@@@@@@@@@@@@@@@@@@@@@@@@EEEEEE@@@@@@@@@@@@@@Ez;::::::::::: +#:::::::::::::E@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Ez:::::: +#::::::::::::::E@@@@@@@@@@@@@@@@@@@@@@@@@@@@@BE5EBB@@@@@@@@@@@@@@@EEE::::: +#:::::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@E1::35@@@@@@@@@@ME3MMME2:::::: +#:::::::::::::::?@@@@@@@@@@@@@@@@@@M@@@@@@@EE:::::3SB@@BBESEEt:::::::::::: +#::::::::::::::::J$@@@@@@@B@@@@@@@@@@@@@@@@EE:::::::!35E33t::::::::::::::: +#:::::::::::::::::3@E@@@EE5EESE5EESE@@@@@@@Et::::::::::::tz::::::::::::::: +#:::::::::::::::::J@E$@EEE5133555SE@@@@@@@@Et::::::::::::::::::::::::::::: +#::::::::::::::::::E@E@EEEEtt3523EEE@@@@@@@E:::::::::::::::::::::::::::::: +#:t::::::::::::::::JEE3@@@EEEEEEEEEE@@@@@@@E:::::::::t;::::::::::::::::::: +#:t:::::::::::::::::!5ES@EEEEEEEEES@@@@@@@@@E;:::;;;:3Ez:::::::::::::::::: +#:t::::::::::::::::::::JE@@EEEEEEE@@@@@@@@@@@@@@@@ME!:::;::::::::::::::::: +#:tz::::::::::::::::::::JE@@@EEEE@@@@@@@@@@@@@@EE!:::::::t:::::::::::::::: +#:t::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@ESBE:::::::::::::::::::::::::: +#:::::::::::::::::::::::::Q@@@@@@@@@@@@@@@@EE3EE;:::::zzzz:::::::::::::::: +#:::::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@@@@@NN@@@@@@Ez::::::::::::::: +#:zt:::::::::::::::::::::::3@@@@EE@@@@@@@@@@EEEEt::;z113E5t::::::::::::::: +#::tt:::::::::::::::::::::::3@@@E@@@@@@@@@@@@@@@@BEt::::::::::::::::t::::: +#:tt:t:::::::::::::::::::::::?S@@@@@@@@@@@BBEEE51!::::::::::::::zzzEt::::: +#::::::::::::::::::::::::::::::3Q@@@@@@@BEEEEEt:::::::::::::;zz@@@EE:::::: +#::::::::::::::::::::::::::::::::75B@@@@@EEEtt;:::::::::;zz@@@@BEEEtz::::: +#::::::::::::::::::::::::::::::::::::?9@@@@@@@@@@@E2Ezg@@@@@B@@@EEEE1t:::: +#:::::::::::::::::::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@@E@EEEEEEEzzz:: +#::::::::::::::::::::::::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@EEEEEEE5ttttt +#:::::::::::::::::::::::::::::::;g@@@@@@@@@@@@@@@@@@@@@@@@@@EEEEEEEEEEEtzt +#::::::::::::::::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@E@@EEEEEEEEEEEE@@@ +#::::::::::::::::::::::::::g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEE3EEEE@@@@@@@ +#:::::::::::::::::::::;;g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEt33@@@@@@@@@@ +#:::::::::::::::::;g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@E@@@@@@EEEtg@@@@@@@@@@@@ +#::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEE@@@@@@@@@@@@@@@@@@@@@@@@ +#:::::::::::::@@@@@@@@@@@@@@@@@$@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +# +# Copyleft ↄ⃝ 2012 Institut Curie +# Author(s): Valentina Boeva, Alban Lermine (Institut Curie) 2012 +# Contact: valentina.boeva@curie.fr, alban.lermine@curie.fr +# This software is distributed under the terms of the GNU General +# Public License, either Version 2, June 1991 or Version 3, June 2007. + +#!/bin/bash + + +while getopts "r:p:w:a:m:h:l:i:k:s:y:e:x:" optionName; do +case "$optionName" in + +r) OLOG="$OPTARG";; +p) OPEAKS="$OPTARG";; +w) OWIG="$OPTARG";; +a) ALIGNER="$OPTARG";; +m) MED="$OPTARG";; +h) HIGH="$OPTARG";; +l) LOW="$OPTARG";; +i) INPUT="$OPTARG";; +k) MIN="$OPTARG";; +s) SUBPEAKS="$OPTARG";; +y) WIGSTEP="$OPTARG";; +e) PREPEND="$OPTARG";; +x) SHARED_PATH="$OPTARG";; + +esac +done + +FINDPEAKS_BIN_DIR=$SHARED_PATH/shared/jars/FindPeaks + +PREPS=" -prepend chr" + +if [[ $PREPEND == "No" ]] + then + PREPS="" +fi + + +OUTDIR=`dirname $OPEAKS` +NAME=`basename $OPEAKS .dat` + + +if [[ $ALIGNER == "sam" || $ALIGNER == "maq" || $ALIGNER == "sam-filter" || $ALIGNER == "sam-ignore-deletion" || $ALIGNER == "mapview" ]] + then + + FORMAT=$ALIGNER + FILE=$INPUT + + file $INPUT| grep -c gzip >$INPUT.tmp.tmp.txt + + IFBAM=( $( cat $INPUT.tmp.tmp.txt)) + + if [ -r $INPUT.tmp.tmp.txt ]; then + rm $INPUT.tmp.tmp.txt + fi + + if [[ $ALIGNER == "sam" && $IFBAM == 0 ]]; then + samtools view -S -h $INPUT -b | $SAMTOOLS_BIN_DIR/samtools sort -m 4000000000 -o - $INPUT.sorted | /bioinfo/local/samtools/samtools view -h - >$INPUT.tmp.sam 2>> $OLOG + fi + + if [[ $ALIGNER == "sam" && $IFBAM == 1 ]]; then + samtools sort -m 14000000000 -o $INPUT $INPUT.sorted | samtools view -h - >$INPUT.tmp.sam 2>> $OLOG + FILE=$INPUT.tmp.sam + fi + + + java -Xmx20G -jar $FINDPEAKS_BIN_DIR/FindPeaks.jar -aligner $FORMAT -duplicatefilter -no_peaks_header$PREPS -dist_type 1 $MED $HIGH $LOW -input $FILE -minimum $MIN -name $NAME -output $OUTDIR -subpeaks $SUBPEAKS -wig_step_size $WIGSTEP 2>> $OLOG >> $OLOG + + + if [ -r $INPUT.tmp.sam ]; then + rm $INPUT.tmp.sam + fi + + if [ -r $INPUT.sorted ]; then + rm $INPUT.sorted + fi + + mv $OUTDIR/$NAME\_triangle_subpeaks.peaks $OPEAKS + mv $OUTDIR/$NAME\_triangle_subpeaks.wig.gz $OWIG + + + else + echo "Use SAM format.." +fi