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.

Revisions

  1. @slowkow slowkow revised this gist Apr 24, 2015. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions sra-paired.sh
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,13 @@ sra_paired() {
    [[ $x == 2 ]]
    }

    if sra_paired $1; then
    echo "$1 contains paired-end sequencing data"
    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"
    echo "$1 does not contain paired-end sequencing data"
    fi
  2. @slowkow slowkow created this gist Apr 24, 2015.
    26 changes: 26 additions & 0 deletions sra-paired.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/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 sra_paired $1; then
    echo "$1 contains paired-end sequencing data"
    else
    echo "$1 does not contain paired-end sequencing data"
    fi