Skip to content

Instantly share code, notes, and snippets.

@aimirza
Last active July 30, 2018 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aimirza/03ebf5b1d573b3d39a65045ce58e7aef to your computer and use it in GitHub Desktop.
Save aimirza/03ebf5b1d573b3d39a65045ce58e7aef to your computer and use it in GitHub Desktop.
Bash script to screen the primer of interest in your file, including it's reverse sequence, its compliment, and it's reverse compliment.
#!/bin/bash
#HOW TO USE: sh primer_screen.sh <primer> <path to file with sequences>
#Simple bash script to quickly screen the primer of interest in your file.
#The script will screen for your primer, it's reverse sequence, its compliment, and it's reverse compliment.
#If a perimer is found, the terminal will print text in red with the primer sequence and the
#number of times the primer is present in the file.
primer1=$1
fastq=$2
RED='\033[0;31m'
NC='\033[0m' # No Color
primer2=$(echo "$1" | rev)
primer3=$(echo "$1" | rev | tr ATGCatgcNn TACGtacgNn)
primer4=$(echo "$1" | tr ATGCatgcNn TACGtacgNn)
for primer in $primer1 $primer2 $primer3 $primer4
do
num=$(grep -c "${primer}" ${fastq})
if [ $num -ne "0" ]; then
printf "${RED}The primer ${primer} is found in ${num} sequences in the file ${fastq}\n${NC}"
else
printf "The primer ${primer} is found in ${num} sequences in the file ${fastq}\n"
fi
done
printf "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment