Advertisement
Guest User

fasta collector 2

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