Skip to content

Instantly share code, notes, and snippets.

@slowkow
Last active April 28, 2023 02:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save slowkow/b9c84e0077c16e1821f4 to your computer and use it in GitHub Desktop.
Save slowkow/b9c84e0077c16e1821f4 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
@slowkow
Copy link
Author

slowkow commented Jun 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment