Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help
Special pages
SBGrid Resources
SBGrid Consortium
SBGrid Data Bank
Software Webinars
PyMOL Webinar
PyMOL Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Aa codes
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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 = == Simple == <source lang="python" enclose="pre"> # 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()]) three_letter ={'V':'VAL', 'I':'ILE', 'L':'LEU', 'E':'GLU', 'Q':'GLN', \ 'D':'ASP', 'N':'ASN', 'H':'HIS', 'W':'TRP', 'F':'PHE', 'Y':'TYR', \ 'R':'ARG', 'K':'LYS', 'S':'SER', 'T':'THR', 'M':'MET', 'A':'ALA', \ 'G':'GLY', 'P':'PRO', 'C':'CYS'} </source> == Simple and Clever == Here's another way to accomplish this <source lang="python"> # The real convenience in there is that you can easily construct any # kind of hash by just adding a matching list, and zipping. aa1 = list("ACDEFGHIKLMNPQRSTVWY") aa3 = "ALA CYS ASP GLU PHE GLY HIS ILE LYS LEU MET ASN PRO GLN ARG SER THR VAL TRP TYR".split() aa123 = dict(zip(aa1,aa3)) aa321 = dict(zip(aa3,aa1)) # Then to extract a sequence, I tend to go for a construction like: sequence = [ aa321[i.resn] for i in cmd.get_model(selection + " and n. ca").atom ] </source> == Using BioPython == If you have BioPython you can use the following, which includes also many three-letter codes of modified amino acids: <source lang="python"> from Bio.PDB import to_one_letter_code as one_letter </source> <source lang="python"> from Bio.Data.SCOPData import protein_letters_3to1 as one_letter </source> == Using PyMOL == <source lang="python"> from pymol.exporting import _resn_to_aa as one_letter </source> = Example Usage = <source lang="python"> # 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]] </source> [[Category:UI_Scripts]]
Summary:
Please note that all contributions to PyMOL Wiki are considered to be released under the GNU Free Documentation License 1.2 (see
PyMOL Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Aa codes
Add topic