Exploring DNA Motifs with Custom Bash Script

#!/bin/bash

#./search_motif4.sh test1.fasta GRG 5

if [ $# -ne 3 ]; then
  echo "Usage: $0 
” exit 1 fi fasta_file=$1 motif=$2 context=$3 motif_regex=$(echo $motif | sed ‘s/R/[AG]/g’ | sed ‘s/Y/[CT]/g’ | sed ‘s/S/[GC]/g’ | sed ‘s/W/[AT]/g’ | sed ‘s/K/[GT]/g’ | sed ‘s/M/[AC]/g’ | sed ‘s/B/[CGT]/g’ | sed ‘s/D/[AGT]/g’ | sed ‘s/H/[ACT]/g’ | sed ‘s/V/[ACG]/g’) grep -B1 -A1 -i -E -o “.{0,$context}${motif_regex}.{0,$context}” $fasta_file

Leave a Reply

Your email address will not be published. Required fields are marked *