|
2 | 2 |
|
3 | 3 | SERIES=$1 |
4 | 4 |
|
5 | | -if [[ -f $SERIES.urls.list ]] |
6 | | -then |
7 | | - >&2 echo "WARNING: File '$SERIES.urls.list' exists! This should not happen; overwriting the file.." |
| 5 | +if [[ -f $SERIES.urls.list ]]; then |
| 6 | + echo >&2 "WARNING: File '$SERIES.urls.list' exists! This should not happen; overwriting the file.." |
8 | 7 | rm $SERIES.urls.list |
9 | | -fi |
| 8 | +fi |
10 | 9 |
|
11 | | -for i in `cat $SERIES.run.list` |
12 | | -do |
13 | | - TYPE="SRA" ## we always default to SRA. This could cause problems for very fresh datasets. |
| 10 | +for i in $(cat $SERIES.run.list); do |
| 11 | + TYPE="SRA" ## we always default to SRA. This could cause problems for very fresh datasets. |
14 | 12 | LOC="" |
15 | | - AEGZ="" |
16 | | - if [[ $SERIES == E-MTAB-* ]] |
17 | | - then |
18 | | - AEGZ=`grep -w $i $SERIES.sdrf.txt | tr '\t' '\n' | grep "ftp://.*\.f.*q" | tr '\n' ';' | sed "s/;$//"` |
19 | | - fi |
20 | | - SPECIES=`grep -w $i $SERIES.ena.tsv | cut -f10` |
21 | | - ENAGZ=`grep -w $i $SERIES.ena.tsv | cut -f11 | grep "_1\.fastq.gz" | grep "_2\.fastq.gz"` ## ENA formatting is strict |
22 | | - ORIFQ=`grep -w $i $SERIES.ena.tsv | cut -f12 | grep "f.*q"` ## ppl name files *all kinds of random shiz*, really |
23 | | - ORIBAM=`grep -w $i $SERIES.ena.tsv | cut -f12 | tr ';' '\n' | grep -v "\.bai" | grep "\.bam"` ## don't need the BAM index which is often there |
24 | | - SRA=`grep -w $i $SERIES.ena.tsv | cut -f13` |
25 | | - SRABAM=`curl -s "https://locate.ncbi.nlm.nih.gov/sdl/2/retrieve?acc=$i&accept-alternate-locations=yes" | jq -r ' |
| 13 | + AEGZ="" |
| 14 | + if [[ $SERIES == E-MTAB-* ]]; then |
| 15 | + AEGZ=$(grep -w $i $SERIES.sdrf.txt | tr '\t' '\n' | grep "ftp://.*\.f.*q" | tr '\n' ';' | sed "s/;$//") |
| 16 | + fi |
| 17 | + SPECIES=$(grep -w $i $SERIES.ena.tsv | cut -f10) |
| 18 | + ENAGZ=$(grep -w $i $SERIES.ena.tsv | cut -f11 | grep "_1\.fastq.gz" | grep "_2\.fastq.gz") ## ENA formatting is strict |
| 19 | + ORIFQ=$(grep -w $i $SERIES.ena.tsv | cut -f12 | grep "f.*q" | grep ";") ## ppl name files *all kinds of random shiz*, really |
| 20 | + ORIBAM=$(grep -w $i $SERIES.ena.tsv | cut -f12 | tr ';' '\n' | grep -v "\.bai" | grep "\.bam") ## don't need the BAM index which is often there |
| 21 | + BAMFTP=$(grep -w $i $SERIES.ena.tsv | cut -f14 | tr ';' '\n' | grep -v "\.bai" | grep "\.bam") ## don't need the BAM index which is often there |
| 22 | + SRA=$(grep -w $i $SERIES.ena.tsv | cut -f13) |
| 23 | + SRABAM=$(curl -s "https://locate.ncbi.nlm.nih.gov/sdl/2/retrieve?acc=$i&accept-alternate-locations=yes" | jq -r ' |
26 | 24 | .result[].files[] | |
27 | 25 | select(.name | contains("bam")) | |
28 | 26 | .locations[] | |
29 | 27 | select((.rehydrationRequired // false) == false and (.payRequired // false) == false) | |
30 | 28 | .link |
31 | | - '` |
| 29 | + ') |
32 | 30 |
|
33 | | - if [[ $AEGZ != "" ]] |
34 | | - then |
| 31 | + if [[ $AEGZ != "" ]]; then |
35 | 32 | TYPE="ORIFQ" |
36 | 33 | LOC=$AEGZ |
37 | | - echo $AEGZ | tr ';' '\n' >> $SERIES.urls.list |
38 | | - >&2 echo "Sample $i is available via ArrayExpress as paired-end fastq archive: $LOC" |
39 | | - elif [[ $ENAGZ != "" ]] |
40 | | - then |
| 34 | + echo $AEGZ | tr ';' '\n' >>$SERIES.urls.list |
| 35 | + echo >&2 "Sample $i is available via ArrayExpress as paired-end fastq archive: $LOC" |
| 36 | + elif [[ $ENAGZ != "" ]]; then |
41 | 37 | TYPE="ENAFQ" |
42 | 38 | LOC=$ENAGZ |
43 | | - echo $ENAGZ | tr ';' '\n' >> $SERIES.urls.list |
44 | | - >&2 echo "Sample $i is available via ENA as a paired-end fastq: $LOC" |
45 | | - elif [[ $ORIFQ != "" ]] |
46 | | - then |
| 39 | + echo $ENAGZ | tr ';' '\n' >>$SERIES.urls.list |
| 40 | + echo >&2 "Sample $i is available via ENA as a paired-end fastq: $LOC" |
| 41 | + elif [[ $ORIFQ != "" ]]; then |
47 | 42 | TYPE="ORIFQ" |
48 | 43 | LOC=$ORIFQ |
49 | | - echo $ORIFQ | tr ';' '\n' >> $SERIES.urls.list |
50 | | - >&2 echo "Sample $i is available via ENA as original submitter's fastq: $LOC" |
51 | | - elif [[ $ORIBAM != "" ]] |
52 | | - then |
| 44 | + echo $ORIFQ | tr ';' '\n' >>$SERIES.urls.list |
| 45 | + echo >&2 "Sample $i is available via ENA as original submitter's fastq: $LOC" |
| 46 | + elif [[ $ORIBAM != "" ]]; then |
53 | 47 | TYPE="BAM" |
54 | 48 | LOC=$ORIBAM |
55 | | - echo $ORIBAM >> $SERIES.urls.list |
56 | | - >&2 echo "Sample $i is available via ENA as an original submitter's BAM file: $LOC" |
57 | | - elif [[ $SRABAM != "" ]] |
58 | | - then |
| 49 | + echo $ORIBAM >>$SERIES.urls.list |
| 50 | + echo >&2 "Sample $i is available via ENA as an original submitter's BAM file: $LOC" |
| 51 | + elif [[ $SRABAM != "" ]]; then |
59 | 52 | TYPE="BAM" |
60 | 53 | LOC=$SRABAM |
61 | | - echo $SRABAM >> $SERIES.urls.list |
62 | | - >&2 echo "Sample $i is available via SRA as an original submitter's BAM file: $LOC" |
63 | | - elif [[ $SRA != "" ]] |
64 | | - then |
| 54 | + echo $SRABAM >>$SERIES.urls.list |
| 55 | + echo >&2 "Sample $i is available via SRA as an original submitter's BAM file: $LOC" |
| 56 | + elif [[ $BAMFTP != "" ]]; then |
| 57 | + TYPE="BAM" |
| 58 | + LOC=$BAMFTP |
| 59 | + echo $BAMFTP >>$SERIES.urls.list |
| 60 | + echo >&2 "Sample $i is available via SRA as an original submitter's BAM file: $LOC" |
| 61 | + elif [[ $SRA != "" ]]; then |
65 | 62 | TYPE="SRA" |
66 | 63 | LOC=$SRA |
67 | | - echo $SRA >> $SERIES.urls.list |
68 | | - >&2 echo "Sample $i is available via ENA as an SRA archive: $LOC" |
| 64 | + echo $SRA >>$SERIES.urls.list |
| 65 | + echo >&2 "Sample $i is available via ENA as an SRA archive: $LOC" |
69 | 66 | else |
70 | | - ## means $SRA == "" for some reason - usually this is a failure of ENA, but not always |
71 | | - SRA=`srapath $i` |
| 67 | + ## means $SRA == "" for some reason - usually this is a failure of ENA, but not always |
| 68 | + SRA=$(srapath $i) |
72 | 69 | LOC=$SRA |
73 | | - >&2 echo "WARNING: No ENA ftp URL found for sample $i, using 'srapath' to get the (open) Amazon link to SRA archive.." |
74 | | - echo $SRA >> $SERIES.urls.list |
75 | | - >&2 echo "Sample $i is available via NCBI/Amazon as an SRA archive: $LOC" |
| 70 | + echo >&2 "WARNING: No ENA ftp URL found for sample $i, using 'srapath' to get the (open) Amazon link to SRA archive.." |
| 71 | + echo $SRA >>$SERIES.urls.list |
| 72 | + echo >&2 "Sample $i is available via NCBI/Amazon as an SRA archive: $LOC" |
76 | 73 | fi |
77 | 74 |
|
78 | 75 | echo -e "$i\t$SPECIES\t$LOC\t$TYPE" |
79 | 76 | done |
80 | | - |
0 commit comments