Last active
April 28, 2023 02:35
-
-
Save slowkow/b9c84e0077c16e1821f4 to your computer and use it in GitHub Desktop.
Check if an SRA file contains paired-end data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
Related: