Skip to content

Instantly share code, notes, and snippets.

@alienzj
Forked from slowkow/sra-paired.sh
Created April 28, 2023 02:35
Show Gist options
  • Save alienzj/8bb3521da2a8d2863b066718e2c3a995 to your computer and use it in GitHub Desktop.
Save alienzj/8bb3521da2a8d2863b066718e2c3a995 to your computer and use it in GitHub Desktop.
Check if an SRA file contains paired-end data.
#!/usr/bin/env bash
# sra-paired.sh
# Kamil Slowikowski
# April 23, 2014
#
# Check if an SRA file contains paired-end sequencing data.
#
# See documentation for the SRA Toolkit:
# http://www.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?view=toolkit_doc&f=fastq-dump
sra_paired() {
local SRA="$1"
local x=$(
fastq-dump -I -X 1 -Z --split-spot "$SRA" 2>/dev/null \
| awk '{if(NR % 2 == 1) print substr($1,length($1),1)}' \
| uniq \
| wc -l
)
[[ $x == 2 ]]
}
if [[ "$1" == "" ]]; then
echo "usage: sra-paired.sh file.sra"
exit 1
fi
if sra_paired "$1"; then
echo "$1 contains paired-end sequencing data"
else
echo "$1 does not contain paired-end sequencing data"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment