-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSRR_to_names.sh
More file actions
executable file
·63 lines (54 loc) · 1.83 KB
/
Copy pathSRR_to_names.sh
File metadata and controls
executable file
·63 lines (54 loc) · 1.83 KB
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
#!/bin/bash
## tab-delimited list of GSM-name correspondences (no spaces!)
SMP=$1
KK=`cat $SMP`
N=`wc -l $SMP | awk '{print $1}'`
TYPE="undef"
a=( $KK )
for i in `seq 0 2 $((2*N-2))`
do
j=$((i+1))
##echo "$i $j"
SRR=`esearch -db sra -query "${a[$i]}" | efetch -format runinfo | grep SRR | awk -F "," '{print $1}'`
b=( $SRR )
if [[ -e ${b[0]}_1.fastq.gz ]]
then
TYPE="paired"
elif [[ -e ${b[0]}.fastq.gz ]]
then
TYPE="single"
else
TYPE="undef"
fi
echo "Processing file: records: ${a[$i]} ${a[$j]}, testing file: ${b[0]}, experiment type: $TYPE, SRR list: $SRR"
if [[ $TYPE == "single" ]]
then
SRR_FQ=`echo $SRR | perl -ne 's/SRR(\d+)/SRR$1.fastq.gz/g; print'`
if [[ "$SRR_FQ" = "${SRR_FQ%[[:space:]]*}" ]]
then
echo "will be MOVING single file $SRR_FQ into ${a[$j]}.fastq.gz"
mv $SRR_FQ ${a[$j]}.fastq.gz
else
echo "will be CONCATENATING files $SRR_FQ into ${a[$j]}.fastq.gz"
zcat $SRR_FQ | gzip > ${a[$j]}.fastq.gz
fi
elif [[ $TYPE == "paired" ]]
then
SRR_FQ1=`echo $SRR | perl -ne 's/SRR(\d+)/SRR$1_1.fastq.gz/g; print'`
SRR_FQ2=`echo $SRR | perl -ne 's/SRR(\d+)/SRR$1_2.fastq.gz/g; print'`
if [[ "$SRR_FQ1" = "${SRR_FQ1%[[:space:]]*}" ]]
then
echo "will be MOVING single file $SRR_FQ1 to ${a[$j]}.R1.fastq.gz"
echo "will be MOVING single file $SRR_FQ2 to ${a[$j]}.R2.fastq.gz"
mv $SRR_FQ1 ${a[$j]}.R1.fastq.gz
mv $SRR_FQ2 ${a[$j]}.R2.fastq.gz
else
echo "will be CONCATENATING files $SRR_FQ1 to ${a[$j]}.R1.fastq"
echo "will be CONCATENATING files $SRR_FQ2 to ${a[$j]}.R2.fastq"
zcat $SRR_FQ1 | gzip > ${a[$j]}.R1.fastq.gz
zcat $SRR_FQ2 | gzip > ${a[$j]}.R2.fastq.gz
fi
else
echo "ERROR: something went terribly wrong! Your experiment is neither paired nor single!"
fi
done