-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroch-novo-brc-download.sh
executable file
·306 lines (205 loc) · 6.35 KB
/
roch-novo-brc-download.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#!/bin/bash
#SBATCH -J brc_roch_novo_download
#SBATCH -o %x.out
# ------------------------------------------------------------------------------------------------------------------------
# Download Script for BRC Novogene and Rochester:
# Downloads, Archives and Copy to TREx_shared/projects
# Archive Path: /home/RSCshare/RSC/Projects/dataArchive/
# Archive Dir Structure
# .
# ├── logfiles
# ├── raw
# │ └── < sequencing provider distribution date format YYMMDD > e.g. 230209
# └── reports
#
# ------------------------------------------------------------------------------------------------------------------------
WD=`pwd`
usage(){
echo "BRC // Rochester // Novogene Download - @bixBeta"
echo ""
echo "hu:p:b:d:l:"
echo "Usage: bash" $0 "[-h arg] [-u arg] [-p args] [-b arg] [-d arg] [-l arg] "
echo
echo "---------------------------------------------------------------------------------------------------------------------------"
echo ""
echo "[-h] --> Display Help"
echo "[-p] --> Comma sep list of all projects in the ftp download e.g. < 1002D,1004A,1024S > "
echo "[-u] --> Comma sep list of Novogene ftp username and pw e.g. < username,password > "
echo "[-b] --> BRC download < yes or no >"
echo "[-d] --> Data distibution date from BRC, Roch or Novo < YYMMDD >"
echo "[-l] --> Roch link"
echo ""
echo "---------------------------------------------------------------------------------------------------------------------------"
echo ""
}
dirCheck(){
# check if project dir exists
cat $WD/projects.list | while read line
do
DIR="/home/RSCshare/RSC/Projects/dataArchive/600x/${line}*"
if [ -d /home/RSCshare/RSC/Projects/dataArchive/600x/$line* ]; then
echo "-----------------------------------------------------------------------------"
echo "Project Directory Exists, adding reseqs"
echo "-----------------------------------------------------------------------------"
cd $DIR/raw
mkdir -m 777 $DATE
cd $DATE
pwd >> $WD/archive.Path
else
echo "-----------------------------------------------------------------------------"
echo "Project Directory Does not Exist!!! Creating dirs logfiles; raw/$DATE; reports"
echo "-----------------------------------------------------------------------------"
cd /home/RSCshare/RSC/Projects/dataArchive/600x/
mkdir -m 777 -p $line/logfiles $line/raw $line/reports
cd $line/raw
mkdir -m 777 $DATE && cd $DATE
pwd >> $WD/archive.Path
fi
done
}
donwload.novo(){
echo "N O V O G E N E D O W N L O A D"
echo "User = $USER, PW = $PW "
echo ""
wget -r -c ftp://${USER}:${PW}@usftp21.novogene.com:21/
cd usftp21.novogene.com
md5sum 01.RawData/*/*.gz >> myMD5s.txt
sort -k2 -n MD5.txt > sorted.MD5.txt
sort -k2 -n myMD5s.txt > sorted.myMD5s.txt
diff sorted.MD5.txt sorted.myMD5s.txt > diff.command.out
cd 01.RawData
mkdir -m 777 downloaded_fastqs
mv */*.gz downloaded_fastqs
cd downloaded_fastqs
cat $WD/projects.list | while read fq
do
mkdir -m 777 $fq
mv `find . -type f | grep $fq` $fq
done
cat $WD/projects.list | while read fq
do
rsync -av $fq/*gz `grep "$fq" $WD/archive.Path`
rsync -arctuxzv --remove-source-files $fq /workdir/TREx_shared/projects/
done
}
donwload.roch(){
echo "R O C H E S T E R D O W N L O A D"
echo "Roch URL -- ${URL}"
echo ""
wget -r -c ${URL}
mv `find grcweb.circ.rochester.edu/ -type f | grep 'tar.gz'` .
md5sum *tar.gz >> TAR.md5
tar -xzvf *tar.gz
cd deliv*
md5sum *.gz >> myMD5s.txt
sort -k2 -n md5sums.log > sorted.MD5.txt
sort -k2 -n myMD5s.txt > sorted.myMD5s.txt
diff sorted.MD5.txt sorted.myMD5s.txt > diff.command.out
cat $WD/projects.list | while read fq
do
mkdir -m 777 $fq
mv `find . -type f | grep $fq` $fq
done
cat $WD/projects.list | while read fq
do
rsync -av $fq/*gz `grep "$fq" $WD/archive.Path`
rsync -arctuxzv --remove-source-files $fq /workdir/TREx_shared/projects/
done
}
donwload.BRC(){
echo "B R C D O W N L O A D"
`bash download.sh`
cat $WD/projects.list | while read fq
do
mkdir -m 777 $fq
mv `find . -type f | grep $fq` $fq
done
cat $WD/projects.list | while read fq
do
rsync -av $fq/*gz `grep "$fq" $WD/archive.Path`
rsync -arctuxzv --remove-source-files $fq /workdir/TREx_shared/projects/
done
}
# PROJ=$1
# WD=`pwd`
# DATE="YYMMDD"
# dirCheck
# rm $WD/projects.list
# `find ${DIR} -type d | wc -l` -gt 0
# ------------------------------------------------------------------------------------------------------------------------
# CASE ESAC FLOW
while getopts "hu:p:b:d:l:" opt; do
case ${opt} in
h)
echo
echo
echo
usage
echo
echo
exit 1
;;
u )
USERPW=$OPTARG
;;
p )
PROJ=$OPTARG
;;
b)
BRC=$OPTARG
;;
d)
DATE=$OPTARG
;;
l)
URL=$OPTARG
;;
\?)
echo
echo
echo
usage
;;
esac
done
# PARAMETER CHECKS
if [[ ! -z "${PROJ+x}" ]]; then
echo $PROJ | sed -e 's/,/\n/g' >> $WD/projects.list
dirCheck
fi
# split user and pw
if [[ ! -z "${USERPW+x}" ]]; then
echo
echo
USER=`echo $USERPW | cut -d , -f1`
PW=`echo $USERPW | cut -d , -f2 `
# dirCheck
donwload.novo
fi
if [[ ! -z "${URL+x}" ]]; then
echo
echo "Downloading data from Rochester"
echo
# dirCheck
donwload.roch
fi
if [[ ! -z "${BRC+x}" ]]; then
echo
echo "Downloading data from BRC"
echo
# dirCheck
donwload.BRC
fi
if [[ -z $1 ]] || [[ $1 = "help" ]] || [[ $1 = "--help" ]] ; then
#statements
echo
echo
usage
echo
echo
exit 1
else
echo >> download.log
echo `date` >> download.log
echo "Projects included in the download = " $PROJ >> download.log
fi