IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/21
The Integrative Modeling Platform
alphabets.py
1 """@namespace IMP.pmi.alphabets
2  Mapping between FASTA one-letter codes and residue types.
3 """
4 
5 import IMP.atom
6 
7 
9  """Map between FASTA codes and residue types.
10  Typically one would use the `amino_acid`, `rna`, or `dna` objects."""
11  def __init__(self, charmm_to_one, chain_type=IMP.atom.UnknownChainType):
12  self._one_to_charmm = {}
13  for k, v in charmm_to_one.items():
14  self._one_to_charmm[v] = k
15  self.charmm_to_one = charmm_to_one
16  self._chain_type = chain_type
17 
19  """Given a one-letter code, return an IMP.atom.ResidueType"""
20  return IMP.atom.ResidueType(self._one_to_charmm[code])
21 
23  """Given a residue type, return a one-letter code"""
24  # Technically this is the CHARMM type, not PDB (but they are the
25  # same for amino acids)
26  return self.charmm_to_one.get(rt, 'X')
27 
28  def get_chain_type(self):
29  """Get the IMP.atom.ChainType for this alphabet"""
30  return self._chain_type
31 
32 
33 """Mapping between FASTA one-letter codes and residue types for amino acids"""
34 amino_acid = ResidueAlphabet(
35  {'ALA': 'A', 'ARG': 'R', 'ASN': 'N', 'ASP': 'D',
36  'CYS': 'C', 'GLU': 'E', 'GLN': 'Q', 'GLY': 'G',
37  'HIS': 'H', 'ILE': 'I', 'LEU': 'L', 'LYS': 'K',
38  'MET': 'M', 'PHE': 'F', 'PRO': 'P', 'SER': 'S',
39  'THR': 'T', 'TRP': 'W', 'TYR': 'Y', 'VAL': 'V',
40  'UNK': 'X'}, IMP.atom.Protein)
41 
42 
43 """Mapping between FASTA one-letter codes and residue types for DNA"""
44 dna = ResidueAlphabet(
45  {'DADE': 'A', 'DURA': 'U', 'DCYT': 'C', 'DGUA': 'G',
46  'DTHY': 'T', 'UNK': 'X'}, IMP.atom.DNA)
47 
48 
49 """Mapping between FASTA one-letter codes and residue types for RNA"""
50 rna = ResidueAlphabet(
51  {'ADE': 'A', 'URA': 'U', 'CYT': 'C', 'GUA': 'G',
52  'THY': 'T', 'UNK': 'X'}, IMP.atom.RNA)
def get_one_letter_code_from_residue_type
Given a residue type, return a one-letter code.
Definition: alphabets.py:22
Map between FASTA codes and residue types.
Definition: alphabets.py:8
def get_residue_type_from_one_letter_code
Given a one-letter code, return an IMP.atom.ResidueType.
Definition: alphabets.py:18
The type for a residue.
Functionality for loading, creating, manipulating and scoring atomic structures.
def get_chain_type
Get the IMP.atom.ChainType for this alphabet.
Definition: alphabets.py:28