File: two_models.py

package info (click to toggle)
mmtk 2.7.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,788 kB
  • ctags: 6,600
  • sloc: python: 18,050; ansic: 12,400; makefile: 129; csh: 3
file content (30 lines) | stat: -rw-r--r-- 978 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Set up an all-atom model and a C-alpha model for the same protein,
# with a facility for copying configurations back and forth.
#

from MMTK import *
from MMTK.Proteins import Protein

# Create an all-atom universe and a c-alpha universe
universe_aa = InfiniteUniverse()
universe_ca = InfiniteUniverse()

# Add the protein to both universes
protein_aa = Protein('insulin.pdb')
universe_aa.addObject(protein_aa)
protein_ca = Protein('insulin.pdb', model='calpha')
universe_ca.addObject(protein_ca)

# Set up a dictionary mapping aa atoms to ca atoms
atom_map = {}
for ichain in range(len(protein_aa)):
    chain_aa = protein_aa[ichain]
    chain_ca = protein_ca[ichain]
    for iresidue in range(len(chain_aa)):
        ca_aa = chain_aa[iresidue].peptide.C_alpha
        ca_ca = chain_ca[iresidue].peptide.C_alpha
        atom_map[ca_aa] = ca_ca

# Copy the aa configuration to the ca configuration
for ca_aa, ca_ca in atom_map.items():
    ca_ca.setPosition(ca_aa.position())