Skip to content

Instantly share code, notes, and snippets.

@mfcovington
Last active December 19, 2016 21:28
Show Gist options
  • Save mfcovington/547090be5b54782909bb2ec40d0b1c5d to your computer and use it in GitHub Desktop.
Save mfcovington/547090be5b54782909bb2ec40d0b1c5d to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# Count reads and validate FASTQ files
FASTQ_DIR="$1"
if [ -z ${FASTQ_DIR+x} ]; then
echo "Usage: $0 /path/to/fastq/files/"
exit 1
fi
echo -e "FILE\tLINES\tREADS" >> $FASTQ_DIR/counts
for FQ in $FASTQ_DIR/*.fastq.gz; do
LINES=`gunzip -c $FQ | wc -l`
READS=$((LINES / 4))
RECORD="$FQ\t$LINES\t$READS"
# Warn if file is not a multiple of 4 lines
if (( $LINES % 4 != 0 )); then
RECORD="$RECORD\tERROR: Truncated File Detected"
fi
echo -e $RECORD >> $FASTQ_DIR/counts
done
cd /bio/amaryllis/girihlet/fda/final-to-send/fq
echo -e "FILE\tLINES\tREADS" > ../counts
for FQ in *.fq.gz *.fastq.gz; do
LINES=`gunzip -c $FQ | wc -l`
READS=$((LINES / 4))
RECORD="$FQ\t$LINES\t$READS"
# Warn if file is not a multiple of 4 lines
if (( $LINES % 4 != 0 )); then
RECORD="$RECORD\tERROR: Truncated File Detected"
fi
echo -e $RECORD >> ../counts
done &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment