Created
May 6, 2014 22:58
-
-
Save nimezhu/2b19d8c384b9afaed6b6 to your computer and use it in GitHub Desktop.
check Fastq ( Phred+33 or Phred+64 ) ( shell script )
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
#!/bin/sh | |
inputfile=$1 | |
# you can add friendly code to check the extension and use zcat if it's *.fastq.gz or *.fq.gz... | |
[[ "$inputfile" =~ ".*\.(fq\.gz$|fastq\.gz$)" ]] && zcat $inputfile | head -n400 | awk '{if(NR%4==0) printf("%s",$0);}' | od -A n -t u1 | awk 'BEGIN{min=100;max=0;}{for(i=1;i<=NF;i++) {if($i>max) max=$i; if($i<min) min=$i;}}END{if(max<=74 && min<59) print "Phred+33"; else if(max>73 && min>=64) print "Phred+64"; else if(min>=59 && min<64 && max>73) print "Solexa+64"; else print "Unknown score encoding!";}' | |
[[ "$inputfile" =~ ".*\.(fq$|fastq$)" ]] && head -n400 $inputfile | awk '{if(NR%4==0) printf("%s",$0);}' | od -A n -t u1 | awk 'BEGIN{min=100;max=0;}{for(i=1;i<=NF;i++) {if($i>max) max=$i; if($i<min) min=$i;}}END{if(max<=74 && min<59) print "Phred+33"; else if(max>73 && min>=64) print "Phred+64"; else if(min>=59 && min<64 && max>73) print "Solexa+64"; else print "Unknown score encoding!";}' |
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 sh | |
if [ $# -ge 1 ] | |
then | |
dir=$1 | |
else | |
dir="./" | |
fi | |
for i0 in $dir/*.fastq | |
do | |
# dir=${i0%/*.fastq} | |
i=${i0##*/} | |
if [ "$i" == "*.fastq" ] | |
then | |
echo "no fastq in this directory" | |
break | |
fi | |
j2=${i%_1.fastq} | |
mate2="${j2}_2.fastq" | |
j1=${i%_2.fastq} | |
mate1="${j1}_1.fastq" | |
if [ ! -f "$dir/$mate1" ] | |
then | |
if [ -f "$dir/$mate2" ] | |
then | |
echo "paired end $i $mate2" | |
else | |
echo "single end $i" | |
fi | |
fi | |
done |
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 sh | |
if [ $# -ge 1 ] | |
then | |
dir=$1 | |
else | |
dir="./" | |
fi | |
for i0 in $dir/*.fq | |
do | |
# dir=${i0%/*.fq} | |
i=${i0##*/} | |
if [ "$i" == "*.fq" ] | |
then | |
echo "no fq in this directory" | |
break | |
fi | |
j2=${i%_1.fq} | |
mate2="${j2}_2.fq" | |
j1=${i%_2.fq} | |
mate1="${j1}_1.fq" | |
if [ ! -f "$dir/$mate1" ] | |
then | |
if [ -f "$dir/$mate2" ] | |
then | |
echo "paired end $i $mate2" | |
else | |
echo "single end $i" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment