| 0 | 1 #!/bin/bash | 
|  | 2 | 
|  | 3 REG="NA" | 
|  | 4 CONTROLFILE="NA" | 
|  | 5 | 
|  | 6 while getopts "f:c:l:o:r:u:v:e:p:" optionName; do | 
|  | 7 case "$optionName" in | 
|  | 8 | 
|  | 9 f) CHIPFILE="$OPTARG";; | 
|  | 10 c) CONTROLFILE="$OPTARG";; | 
|  | 11 l) STEP="$OPTARG";; | 
|  | 12 r) RIGHT="$OPTARG";; | 
|  | 13 o) OUTPUT="$OPTARG";; | 
|  | 14 u) OUTSTAT="$OPTARG";; | 
|  | 15 v) GENOME="$OPTARG";; | 
|  | 16 e) REG="$OPTARG";; | 
|  | 17 p) PDF="$OPTARG";; | 
|  | 18 | 
|  | 19 esac | 
|  | 20 done | 
|  | 21 | 
|  | 22 LOGTMP=$OUTPUT.log.tmp | 
|  | 23 | 
|  | 24 #LOGTMP=/data/tmp/log.tmp | 
|  | 25 | 
|  | 26 #echo $LOGTMP | 
|  | 27 #echo "$@" | 
|  | 28 | 
|  | 29 echo "$@" >> $LOGTMP | 
|  | 30 | 
|  | 31 LOCAL_DIR=`( cd -P $(dirname $0); pwd)` | 
|  | 32 DOCKER_PATH='/usr/bin/maketssdist_histones' | 
|  | 33 | 
|  | 34 | 
|  | 35 OUTPUT_DIR=`dirname $OUTPUT` | 
| 6 | 36 R_PATH='Rscript --slave ' | 
| 0 | 37 | 
|  | 38 databasePath=$(find / -type d -name files | grep database) | 
|  | 39 | 
|  | 40 mkdir -p $databasePath/nebulaAnnotations | 
|  | 41 mkdir -p $databasePath/nebulaAnnotations/noIdenticalTransc | 
|  | 42 nebulaAnnotationPath=$databasePath/nebulaAnnotations | 
|  | 43 [ ! -f $nebulaAnnotationPath/noIdenticalTransc/$GENOME.noIdenticalTransc.txt ] && curl -s -o $nebulaAnnotationPath/noIdenticalTransc/$GENOME.noIdenticalTransc.txt -L https://github.com/jbrayet/nebula_tools_docker/raw/master/tools_data/noIdenticalTransc/$GENOME.noIdenticalTransc.txt | 
|  | 44 | 
|  | 45 noIdenticalTranscPath=$nebulaAnnotationPath/noIdenticalTransc | 
|  | 46 | 
|  | 47 if [ -r $REG ]; then | 
|  | 48   echo "1:  perl $DOCKER_PATH/crossBedWithGenes_hist.pl -g $noIdenticalTranscPath/$GENOME.noIdenticalTransc.txt -f $CHIPFILE -reg $REG -o $OUTPUT.annotated" >> $LOGTMP | 
|  | 49   perl $DOCKER_PATH/crossBedWithGenes_hist.pl -g $noIdenticalTranscPath/$GENOME.noIdenticalTransc.txt -f $CHIPFILE -reg $REG -o $OUTPUT.annotated >> $LOGTMP 2>> $LOGTMP | 
|  | 50  else | 
|  | 51   echo "2:  perl $DOCKER_PATH/crossBedWithGenes_hist.pl -g $noIdenticalTranscPath/$GENOME.noIdenticalTransc.txt -f $CHIPFILE -reg $REG -o $OUTPUT.annotated" >> $LOGTMP | 
|  | 52   perl $DOCKER_PATH/crossBedWithGenes_hist.pl -g $noIdenticalTranscPath/$GENOME.noIdenticalTransc.txt -f $CHIPFILE -o $OUTPUT.annotated >> $LOGTMP 2>> $LOGTMP | 
|  | 53 fi | 
|  | 54 | 
|  | 55 if [ -r $CONTROLFILE ]; then | 
|  | 56   #create a subset of control peaks (highest peaks, the same number as in the sample) | 
|  | 57    echo "   perl $DOCKER_PATH/createControlPeakSubSet.pl -f $CHIPFILE -c $CONTROLFILE -o ${OUTPUT_DIR}/control.tmp" >>$LOGTMP | 
|  | 58    perl $DOCKER_PATH/createControlPeakSubSet.pl -f $CHIPFILE -c $CONTROLFILE -o ${OUTPUT_DIR}/control.tmp >>$LOGTMP 2>>$LOGTMP | 
|  | 59   if [ -r $REG ]; then | 
|  | 60     perl $DOCKER_PATH/crossBedWithGenes_hist.pl -g $noIdenticalTranscPath/$GENOME.noIdenticalTransc.txt -f ${OUTPUT_DIR}/control.tmp -reg $REG -o $OUTPUT.control.annotated >> $LOGTMP 2>> $LOGTMP | 
|  | 61   else | 
|  | 62     perl $DOCKER_PATH/crossBedWithGenes_hist.pl -g $noIdenticalTranscPath/$GENOME.noIdenticalTransc.txt -f ${OUTPUT_DIR}/control.tmp -o $OUTPUT.control.annotated >> $LOGTMP 2>> $LOGTMP | 
|  | 63   fi | 
|  | 64   echo "3: cat $DOCKER_PATH/makeTSSdist_hist.R | R --slave --args $STEP $RIGHT $OUTPUT.annotated $OUTPUT $OUTSTAT $OUTPUT.control.annotated $PDF" >> $LOGTMP | 
|  | 65   cat $DOCKER_PATH/makeTSSdist_hist.R | R --slave --args $STEP $RIGHT $OUTPUT.annotated $OUTPUT $OUTSTAT $OUTPUT.control.annotated $PDF >>$LOGTMP 2>>$LOGTMP | 
|  | 66 else | 
|  | 67   echo "4:  cat $DOCKER_PATH/makeTSSdist_hist.R | R --slave --args $STEP $RIGHT $OUTPUT.annotated $OUTPUT $OUTSTAT $PDF 2>>$LOGTMP" >>$LOGTMP | 
|  | 68   cat $DOCKER_PATH/makeTSSdist_hist.R | R --slave --args $STEP $RIGHT $OUTPUT.annotated $OUTPUT $OUTSTAT $PDF 2>>$LOGTMP >>$LOGTMP | 
|  | 69 fi | 
|  | 70 | 
|  | 71 if [ -r $LOGTMP ]; then | 
|  | 72   rm $LOGTMP | 
|  | 73 fi | 
|  | 74 | 
|  | 75 rm $OUTPUT.annotated* | 
|  | 76 | 
|  | 77 if [ -r $CONTROLFILE ]; then | 
|  | 78   rm $OUTPUT.control.annotated* | 
|  | 79   rm ${OUTPUT_DIR}/control.tmp | 
|  | 80 fi | 
|  | 81 |