Debian Codegraph @

disambiguate-nucleotides

raw symbols SCIP
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 # Usage: echo RCCGGY | disambiguate-nucleotides
7
8 ExpandNext() {
9
10 local prev
11 local curr
12 local next
13 local arry
14
15 prev="$1"
16 next="$2"
17
18 if [ -n "$next" ]
19 then
20 curr="${next:0:1}"
21 next="${next:1}"
22
23 case "$curr" in
24 R ) arry="A G" ;;
25 Y ) arry="C T" ;;
26 S ) arry="G C" ;;
27 W ) arry="A T" ;;
28 K ) arry="G T" ;;
29 M ) arry="A C" ;;
30 B ) arry="C G T" ;;
31 D ) arry="A G T" ;;
32 H ) arry="A C T" ;;
33 V ) arry="A C G" ;;
34 N ) arry="A C G T" ;;
35 * ) arry="$curr" ;;
36 esac
37 for lttr in $(echo $arry)
38 do
39 ExpandNext "${prev}${lttr}" "${next}"
40 done
41 else
42 echo "$prev"
43 fi
44 }
45
46 tr a-z A-Z |
47 while read pat
48 do
49 ExpandNext "" "$pat"
50 done |
51 sort -f | uniq -i