Aa codes
Jump to navigation
Jump to search
Just a quick little script to allow you to convert from 1-to-3 letter codes and 3-to-1 letter codes in PyMOL. Copy the code below and drop it into your .pymolrc file. Then, each time you load PyMOL, "one_letter" and "three_letter" will be defined.
The Code
# one_letter["SER"] will now return "S"
one_letter ={'VAL':'V', 'ILE':'I', 'LEU':'L', 'GLU':'E', 'GLN':'Q', \
'ASP':'D', 'ASN':'N', 'HIS':'H', 'TRP':'W', 'PHE':'F', 'TYR':'Y', \
'ARG':'R', 'LYS':'K', 'SER':'S', 'THR':'T', 'MET':'M', 'ALA':'A', \
'GLY':'G', 'PRO':'P', 'CYS':'C'}
# three_letter["S"] will now return "SER"
three_letter = dict( [[v,k] for k,v in one_letter.items()])
Example Usage
# we used to have to do the following to get the amino acid name
from pymol import stored
stored.aa = ""
cmd.iterate("myselection", "stored.aa=resn")
# now we can just call
three_letter[string.split(cmd.get_fastastr("myselection"),'\n')[1]]