-
Notifications
You must be signed in to change notification settings - Fork 1
/
BB_download_GEO.sh
executable file
·50 lines (43 loc) · 1.11 KB
/
BB_download_GEO.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
#!/bin/bash
# help information
if [ $# -lt 1 ];then
echo0 1 "usage:"
echo0 1 " "$0" SRR/ERR/DRR_ID single/paired prefix.name [SRR/ERR/DRR_ID_IN_DIFF_LANE]"
exit 1
fi
START_ID=$1
STRAND=$2
PREFIX=$3
# download data
GID=$1
wget -nd -q ftp://ftp-trace.ncbi.nih.gov/sra/sra-instant/reads/ByRun/sra/${GID:0:3}/${GID:0:6}/${GID}/${GID}.sra
# fastq-dump data
if [ "${STRAND}" == "single" ];then
fastq-dump.2.8.2 ${GID}.sra
else
fastq-dump.2.8.2 --split-files ${GID}.sra
fi
rm ${GID}.sra
# for each data in different lane
if [ $# -gt 3 ];then
shift
GID=$3
wget -nd -q ftp://ftp-trace.ncbi.nih.gov/sra/sra-instant/reads/ByRun/sra/${GID:0:3}/${GID:0:6}/${GID}/${GID}.sra
if [ "${STRAND}" == "single" ];then
fastq-dump.2.8.2 ${GID}.sra
cat ${GID}.fastq >> ${START_ID}.fastq
else
fastq-dump.2.8.2 --split-files ${GID}.sra
cat ${GID}_1.fastq >> ${START_ID}_1.fastq
cat ${GID}_2.fastq >> ${START_ID}_2.fastq
fi
rm ${GID}.sra
rm ${GID}*.fastq
fi
# rename data
if [ "$2" == "single" ];then
mv ${START_ID}.fastq ${PREFIX}.fastq
else
mv ${START_ID}_1.fastq ${PREFIX}_1.fastq
mv ${START_ID}_2.fastq ${PREFIX}_2.fastq
fi