#!/usr/bin/env bash
# Bulk download script for GSE34995
# Generated from Yeo Lab Publications Database
# Total files: 68

OUTDIR="GSE34995"
mkdir -p "$OUTDIR"
cd "$OUTDIR"

# --- GEO supplementary files ---
wget -nc "ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE34nnn/GSE34995/suppl/GSE34995_RAW.tar" -O "GSE34995_RAW.tar"

# --- SRA run files ---
# Tip: use 'fasterq-dump' from SRA Toolkit for FASTQ conversion
#      with optional renaming to original submitted FASTQ names.
# Set to 1 to rename SRR outputs (e.g. SRR_1.fastq.gz -> sample_R1.fastq.gz)
RENAME_SRA_TO_ORIGINAL=1

_compress_if_exists() {
  local stem="$1"
  if [ -f "${stem}.fastq" ]; then
    gzip -f "${stem}.fastq"
    echo "${stem}.fastq.gz"
    return 0
  fi
  if [ -f "${stem}.fq" ]; then
    gzip -f "${stem}.fq"
    echo "${stem}.fq.gz"
    return 0
  fi
  return 1
}

# Option A: Download via SRA Toolkit (recommended)
fasterq-dump --split-files "SRR398210"
gz1="$(_compress_if_exists 'SRR398210_1' || true)"
gz2="$(_compress_if_exists 'SRR398210_2' || true)"
gzs="$(_compress_if_exists 'SRR398210' || true)"

fasterq-dump --split-files "SRR398211"
gz1="$(_compress_if_exists 'SRR398211_1' || true)"
gz2="$(_compress_if_exists 'SRR398211_2' || true)"
gzs="$(_compress_if_exists 'SRR398211' || true)"

fasterq-dump --split-files "SRR398212"
gz1="$(_compress_if_exists 'SRR398212_1' || true)"
gz2="$(_compress_if_exists 'SRR398212_2' || true)"
gzs="$(_compress_if_exists 'SRR398212' || true)"

fasterq-dump --split-files "SRR398213"
gz1="$(_compress_if_exists 'SRR398213_1' || true)"
gz2="$(_compress_if_exists 'SRR398213_2' || true)"
gzs="$(_compress_if_exists 'SRR398213' || true)"

fasterq-dump --split-files "SRR398214"
gz1="$(_compress_if_exists 'SRR398214_1' || true)"
gz2="$(_compress_if_exists 'SRR398214_2' || true)"
gzs="$(_compress_if_exists 'SRR398214' || true)"

fasterq-dump --split-files "SRR398215"
gz1="$(_compress_if_exists 'SRR398215_1' || true)"
gz2="$(_compress_if_exists 'SRR398215_2' || true)"
gzs="$(_compress_if_exists 'SRR398215' || true)"

fasterq-dump --split-files "SRR398216"
gz1="$(_compress_if_exists 'SRR398216_1' || true)"
gz2="$(_compress_if_exists 'SRR398216_2' || true)"
gzs="$(_compress_if_exists 'SRR398216' || true)"

fasterq-dump --split-files "SRR398217"
gz1="$(_compress_if_exists 'SRR398217_1' || true)"
gz2="$(_compress_if_exists 'SRR398217_2' || true)"
gzs="$(_compress_if_exists 'SRR398217' || true)"

fasterq-dump --split-files "SRR398218"
gz1="$(_compress_if_exists 'SRR398218_1' || true)"
gz2="$(_compress_if_exists 'SRR398218_2' || true)"
gzs="$(_compress_if_exists 'SRR398218' || true)"

fasterq-dump --split-files "SRR398219"
gz1="$(_compress_if_exists 'SRR398219_1' || true)"
gz2="$(_compress_if_exists 'SRR398219_2' || true)"
gzs="$(_compress_if_exists 'SRR398219' || true)"

fasterq-dump --split-files "SRR398220"
gz1="$(_compress_if_exists 'SRR398220_1' || true)"
gz2="$(_compress_if_exists 'SRR398220_2' || true)"
gzs="$(_compress_if_exists 'SRR398220' || true)"

fasterq-dump --split-files "SRR398221"
gz1="$(_compress_if_exists 'SRR398221_1' || true)"
gz2="$(_compress_if_exists 'SRR398221_2' || true)"
gzs="$(_compress_if_exists 'SRR398221' || true)"

fasterq-dump --split-files "SRR398222"
gz1="$(_compress_if_exists 'SRR398222_1' || true)"
gz2="$(_compress_if_exists 'SRR398222_2' || true)"
gzs="$(_compress_if_exists 'SRR398222' || true)"

fasterq-dump --split-files "SRR398223"
gz1="$(_compress_if_exists 'SRR398223_1' || true)"
gz2="$(_compress_if_exists 'SRR398223_2' || true)"
gzs="$(_compress_if_exists 'SRR398223' || true)"

fasterq-dump --split-files "SRR398224"
gz1="$(_compress_if_exists 'SRR398224_1' || true)"
gz2="$(_compress_if_exists 'SRR398224_2' || true)"
gzs="$(_compress_if_exists 'SRR398224' || true)"

fasterq-dump --split-files "SRR398225"
gz1="$(_compress_if_exists 'SRR398225_1' || true)"
gz2="$(_compress_if_exists 'SRR398225_2' || true)"
gzs="$(_compress_if_exists 'SRR398225' || true)"

fasterq-dump --split-files "SRR398226"
gz1="$(_compress_if_exists 'SRR398226_1' || true)"
gz2="$(_compress_if_exists 'SRR398226_2' || true)"
gzs="$(_compress_if_exists 'SRR398226' || true)"

fasterq-dump --split-files "SRR398227"
gz1="$(_compress_if_exists 'SRR398227_1' || true)"
gz2="$(_compress_if_exists 'SRR398227_2' || true)"
gzs="$(_compress_if_exists 'SRR398227' || true)"

fasterq-dump --split-files "SRR398228"
gz1="$(_compress_if_exists 'SRR398228_1' || true)"
gz2="$(_compress_if_exists 'SRR398228_2' || true)"
gzs="$(_compress_if_exists 'SRR398228' || true)"

fasterq-dump --split-files "SRR398229"
gz1="$(_compress_if_exists 'SRR398229_1' || true)"
gz2="$(_compress_if_exists 'SRR398229_2' || true)"
gzs="$(_compress_if_exists 'SRR398229' || true)"

fasterq-dump --split-files "SRR398230"
gz1="$(_compress_if_exists 'SRR398230_1' || true)"
gz2="$(_compress_if_exists 'SRR398230_2' || true)"
gzs="$(_compress_if_exists 'SRR398230' || true)"

fasterq-dump --split-files "SRR398231"
gz1="$(_compress_if_exists 'SRR398231_1' || true)"
gz2="$(_compress_if_exists 'SRR398231_2' || true)"
gzs="$(_compress_if_exists 'SRR398231' || true)"

fasterq-dump --split-files "SRR398232"
gz1="$(_compress_if_exists 'SRR398232_1' || true)"
gz2="$(_compress_if_exists 'SRR398232_2' || true)"
gzs="$(_compress_if_exists 'SRR398232' || true)"

fasterq-dump --split-files "SRR398233"
gz1="$(_compress_if_exists 'SRR398233_1' || true)"
gz2="$(_compress_if_exists 'SRR398233_2' || true)"
gzs="$(_compress_if_exists 'SRR398233' || true)"

fasterq-dump --split-files "SRR398234"
gz1="$(_compress_if_exists 'SRR398234_1' || true)"
gz2="$(_compress_if_exists 'SRR398234_2' || true)"
gzs="$(_compress_if_exists 'SRR398234' || true)"

fasterq-dump --split-files "SRR398235"
gz1="$(_compress_if_exists 'SRR398235_1' || true)"
gz2="$(_compress_if_exists 'SRR398235_2' || true)"
gzs="$(_compress_if_exists 'SRR398235' || true)"

fasterq-dump --split-files "SRR398236"
gz1="$(_compress_if_exists 'SRR398236_1' || true)"
gz2="$(_compress_if_exists 'SRR398236_2' || true)"
gzs="$(_compress_if_exists 'SRR398236' || true)"

fasterq-dump --split-files "SRR398237"
gz1="$(_compress_if_exists 'SRR398237_1' || true)"
gz2="$(_compress_if_exists 'SRR398237_2' || true)"
gzs="$(_compress_if_exists 'SRR398237' || true)"

fasterq-dump --split-files "SRR398238"
gz1="$(_compress_if_exists 'SRR398238_1' || true)"
gz2="$(_compress_if_exists 'SRR398238_2' || true)"
gzs="$(_compress_if_exists 'SRR398238' || true)"

fasterq-dump --split-files "SRR398239"
gz1="$(_compress_if_exists 'SRR398239_1' || true)"
gz2="$(_compress_if_exists 'SRR398239_2' || true)"
gzs="$(_compress_if_exists 'SRR398239' || true)"

fasterq-dump --split-files "SRR398240"
gz1="$(_compress_if_exists 'SRR398240_1' || true)"
gz2="$(_compress_if_exists 'SRR398240_2' || true)"
gzs="$(_compress_if_exists 'SRR398240' || true)"


# Option B: Direct download (larger .sra files)
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398210/SRR398210"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398211/SRR398211"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398212/SRR398212"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398213/SRR398213"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398214/SRR398214"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398215/SRR398215"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398216/SRR398216"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398217/SRR398217"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398218/SRR398218"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398219/SRR398219"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398220/SRR398220"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398221/SRR398221"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398222/SRR398222"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398223/SRR398223"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398224/SRR398224"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398225/SRR398225"
curl -L -O -C - "https://sra-pub-src-1.s3.amazonaws.com/SRR398226/hnRNPM_293T_RNAseq_KD1b_sequence.txt.1"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398227/SRR398227"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398228/SRR398228"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398229/SRR398229"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398230/SRR398230"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398231/SRR398231"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398232/SRR398232"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398233/SRR398233"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398234/SRR398234"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398235/SRR398235"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398236/SRR398236"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398237/SRR398237"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398238/SRR398238"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398239/SRR398239"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398240/SRR398240"

# --- Additional data files ---
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398235/SRR398235"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398236/SRR398236"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398237/SRR398237"
curl -L -O -C - "https://sra-downloadb.be-md.ncbi.nlm.nih.gov/sos5/sra-pub-zq-14/SRR000/398/SRR398238.sralite.1"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398238/SRR398238"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398239/SRR398239"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398240/SRR398240"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398210/SRR398210"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398211/SRR398211"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398212/SRR398212"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398213/SRR398213"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398214/SRR398214"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398215/SRR398215"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398216/SRR398216"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398217/SRR398217"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398218/SRR398218"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398219/SRR398219"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398220/SRR398220"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398221/SRR398221"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398222/SRR398222"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398223/SRR398223"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398224/SRR398224"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398225/SRR398225"
curl -L -O -C - "https://sra-pub-src-1.s3.amazonaws.com/SRR398226/hnRNPM_293T_RNAseq_KD1b_sequence.txt.1"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398227/SRR398227"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398228/SRR398228"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398229/SRR398229"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398230/SRR398230"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398231/SRR398231"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398232/SRR398232"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398233/SRR398233"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398234/SRR398234"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398215/SRR398215"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398224/SRR398224"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398230/SRR398230"
curl -L -O -C - "https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR398234/SRR398234"

echo "Download complete. Files saved to $OUTDIR"