Debian Codegraph @

amino-acid-composition

raw
1 #!/bin/bash -norc
2
3 # Public domain notice for all NCBI EDirect scripts is located at:
4 # https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice
5
6 abbrev=( Ala Asx Cys Asp Glu Phe Gly His Ile \
7 Xle Lys Leu Met Asn Pyl Pro Gln Arg \
8 Ser Thr Sec Val Trp Xxx Tyr Glx )
9
10 AminoAcidComp() {
11 local count
12 while read num lttr
13 do
14 idx=$(printf %i "'$lttr'")
15 ofs=$((idx-97))
16 count[$ofs]="$num"
17 done <<< "$1"
18 for i in {0..25}
19 do
20 echo -e "${abbrev[$i]}\t${count[$i]-0}"
21 done |
22 sort
23 }
24
25 while read seq
26 do
27 comp="$(echo "$seq" | tr A-Z a-z | sed 's/[^a-z]//g' | fold -w 1 | sort-uniq-count)"
28 AminoAcidComp "$comp"
29 done