Advertisement
Guest User

fasta collector

a guest
Feb 13th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.78 KB | None | 0 0
  1. #! /bin/bash
  2. # Check if the format is correct
  3. if [[ $1 != *.fasta ]]; then
  4.     echo "The input file $1 it's not in fasta format!"
  5.     echo ""    
  6.     echo "Usage: ./nomescript.sh NO_HIT.fasta"
  7.   exit 1
  8. fi
  9.  
  10. read -p "Enter k-mer last value: " KMER
  11. read -p "Enter read lenght: " READLENGHT
  12.  
  13. # calculate the coefficient used to convert coverage. Final is Y
  14.  
  15. K=$(($READLENGHT - $KMER + 1))
  16. Y=$(echo "scale=4; $K / $READLENGHT" | bc)
  17.  
  18. while read odd; do
  19.     echo -n"cov_" ; echo "scale=2;$Y*${odd##*_}" | bc -q
  20.     read even
  21.     ACOUNT=$( grep -c "A")
  22.     GCOUNT=$( grep -c "G")
  23.     CCOUNT=$( grep -c "C")
  24.     TCOUNT=$( grep -c "T")
  25.     TOTALBASES=$(($ACOUNT+$CCOUNT+$GCOUNT+$TCOUNT))
  26.     GC_CONTENT=$(($GCOUNT+$CCOUNT))
  27.     echo "DNA seq:"
  28.     echo "scale=2;$GC_CONTENT / $TOTALBASES*100" | bc
  29. done < "$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement