Skip to content

Instantly share code, notes, and snippets.

@stagnation
Created November 24, 2016 12:52
Show Gist options
  • Save stagnation/19b3d4015311a974fe5acdb47b36377c to your computer and use it in GitHub Desktop.
Save stagnation/19b3d4015311a974fe5acdb47b36377c to your computer and use it in GitHub Desktop.
AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "usage: $0 <input file>"
exit
fi
protein_table="
UUU f:CUU l:AUU i:GUU v:
UUC f:CUC l:AUC i:GUC v:
UUA l:CUA l:AUA i:GUA v:
UUG l:CUG l:AUG m:GUG v:
UCU s:CCU p:ACU t:GCU a:
UCC s:CCC p:ACC t:GCC a:
UCA s:CCA p:ACA t:GCA a:
UCG s:CCG p:ACG t:GCG a:
UAU y:CAU h:AAU n:GAU d:
UAC y:CAC h:AAC n:GAC d:
UAA Stop:CAA q:AAA k:GAA e:
UAG Stop:CAG q:AAG k:GAG e:
UGU c:CGU r:AGU s:GGU g:
UGC c:CGC r:AGC s:GGC g:
UGA Stop:CGA r:AGA r:GGA g:
UGG w:CGG r:AGG r:GGG g:
"
start="s#^#sed '\n#"
removex="s+x++g"
end="s#\$# $removex\n'#"
translationterm="s#\(\w\+\) \(\w\+\)#s+\1+x\2x+g;#"
sedcommand=$(echo $protein_table |
sed "$start; s#:#\n#g; $end" |
sed "$translationterm"
)
splitintotriplets="s+\w\{3\}+&x+g ;"
cat $1
cat $1 | sed "$splitintotriplets" | eval $sedcommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment