Mercurial > repos > stef > qdnaseq_test
comparison QDNAseq.sh @ 1:034fedc6043f draft
Uploaded
author | stef |
---|---|
date | Fri, 05 Sep 2014 10:15:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:cc5254dac2b6 | 1:034fedc6043f |
---|---|
1 #!/bin/sh | |
2 | |
3 ## This script creates a config file for use with the QDNAseq R wrapper | |
4 ## For use outside Galaxy | |
5 | |
6 QDNASEQ_R_SCRIPT='/ccagc/home/stef/code/QDNASEQ/QDNAseq.R' | |
7 R_LOCATION='/ccagc/lib/R/R-3.1.0/bin/' | |
8 OUTPUT_DIR='QDNASEQ' | |
9 SCRIPT_DIR=$(dirname $0) | |
10 SCRIPT_NAME=$(basename $0) | |
11 | |
12 binSizesString='1000,100,15' | |
13 outputName=`basename $PWD` | |
14 doSegment='TRUE' | |
15 debug='FALSE' | |
16 | |
17 usage() | |
18 { | |
19 cat<<EOF | |
20 This script creates a QDNAseq wrapper config. | |
21 | |
22 Experiment name and/or output dir are optional | |
23 $SCRIPT_NAME [-n myExperiment] [-o outputDir] *.bam | |
24 | |
25 Debug mode for working with build in LGG150 data | |
26 $SCRIPT_NAME -d | |
27 | |
28 OPTIONS: | |
29 -n [s] provide analysis name [$outputName] | |
30 -o [s] output dir [$OUTPUT_DIR] | |
31 -d debug mode (only create config) | |
32 | |
33 EOF | |
34 } | |
35 | |
36 PARAM_COUNT=0 | |
37 if [ $# -eq 0 ] || [ "$1" == "-h" ] | |
38 then | |
39 usage | |
40 exit 1 | |
41 else | |
42 while getopts "n:o:d" opt; do | |
43 case $opt in | |
44 n) | |
45 #echo "$opt was triggered, Parameter: $OPTARG" >&2 | |
46 outputName=$OPTARG | |
47 PARAM_COUNT=`bc <<< $PARAM_COUNT+2` | |
48 ;; | |
49 o) | |
50 OUTPUT_DIR=$OPTARG | |
51 PARAM_COUNT=`bc <<< $PARAM_COUNT+2` | |
52 ;; | |
53 d) | |
54 debug='TRUE' | |
55 PARAM_COUNT=`bc <<< $PARAM_COUNT+1` | |
56 ;; | |
57 \?) | |
58 echo "Invalid option: -$OPTARG" >&2 | |
59 exit 1 | |
60 ;; | |
61 :) | |
62 echo "Option -$OPTARG requires an argument." >&2 | |
63 exit 1 | |
64 ;; | |
65 esac | |
66 done | |
67 fi | |
68 | |
69 ## set param dependent variables | |
70 printf '%s\n' "[INFO] --- QDNAseq wrapper config creator ---" | |
71 CONFIG_FILE=$OUTPUT_DIR'/qdnaseqConfig.R' | |
72 | |
73 ## remove the params from input string leaving only the BAMs | |
74 shift $PARAM_COUNT | |
75 | |
76 ## sanity checks | |
77 if [ -e $CONFIG_FILE ]; then | |
78 echo "[ERR] Config file ($CONFIG_FILE) already exists, exit.."; | |
79 exit 0 | |
80 fi | |
81 if [ -d $OUTPUT_DIR ]; then | |
82 echo "[ERR] Output dir ($OUTPUT_DIR) already exists, exit.."; | |
83 exit 0 | |
84 else | |
85 mkdir $OUTPUT_DIR | |
86 fi | |
87 | |
88 ## variables setup | |
89 CONFIG_TXT="## ========== | |
90 ## QDNAseq pipeline config file | |
91 ## ========== | |
92 | |
93 ## ---------- | |
94 inGalaxy <- FALSE | |
95 binSizesString <- '$binSizesString' | |
96 experimentType <- 'SR50' | |
97 outputName <- '$outputName' | |
98 | |
99 ## ---------- | |
100 outputHtml <- 'galaxyIndex.html' | |
101 outputId <- NA | |
102 newFilePath <- '$OUTPUT_DIR' | |
103 outputPath <- '$OUTPUT_DIR' | |
104 doSegment <- as.logical( $doSegment ) | |
105 debug <- as.logical( $debug ) | |
106 undoSD <- as.double( 1.0 ) | |
107 binAnnotations <- '' | |
108 | |
109 ## ---------- | |
110 filterBlacklistedBins <- as.logical( 'TRUE' ) | |
111 mappabilityCutoff <- as.integer( 0 ) | |
112 undoSplits <- 'sdundo' | |
113 doOutputCopynumbersIgv <- FALSE | |
114 | |
115 ## ---------- | |
116 PLOT_WIDTH <- as.integer( 1440 ) | |
117 PLOT_HEIGHT <- as.integer( 720 ) | |
118 excludeChrsString <- 'X,Y' | |
119 | |
120 ## ---------- | |
121 bamsPaths <- c() | |
122 bamsNames <- c() | |
123 " | |
124 | |
125 ## create config file | |
126 printf '%s\n' "$CONFIG_TXT" > $CONFIG_FILE | |
127 | |
128 ## add bam files to config file | |
129 BAMS=$@ | |
130 for bam_path in $BAMS; do | |
131 | |
132 if [ ! -e $bam_path ]; then | |
133 echo "[ERR] Bam file does not exist ($bam_path), exit.."; | |
134 exit 0 | |
135 fi | |
136 | |
137 bam_name=`basename "$bam_path"` | |
138 printf '%s\n' "bamsPaths <- c( bamsPaths, \"$bam_path\" )" >> $CONFIG_FILE | |
139 printf '%s\n' "bamsNames <- c( bamsNames, \"$bam_name\" )" >> $CONFIG_FILE | |
140 printf '%s\n' "[INFO] BAM: $bam_name" | |
141 done | |
142 | |
143 ## done | |
144 printf '%s\n' "[INFO] OUTPUT DIR: $OUTPUT_DIR" | |
145 printf '%s\n' "[INFO] OUTPUT NAME: $outputName" | |
146 printf '%s\n' "[INFO] CONFIG FILE can be found in $CONFIG_FILE" | |
147 printf '%s\n' "[INFO] Run with: $R_LOCATION/Rscript $QDNASEQ_R_SCRIPT $CONFIG_FILE" | |
148 printf '%s\n' "[INFO] Done" |