File: build_peptide.py

package info (click to toggle)
pymol 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,288 kB
  • sloc: cpp: 476,472; python: 76,538; ansic: 29,510; javascript: 6,792; sh: 47; makefile: 24
file content (47 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (11)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

aa_dict = {
   'A' : 'ala',
   'C' : 'cys',
   'D' : 'asp',
   'E' : 'glu',
   'F' : 'phe',

   'G' : 'gly',
   'H' : 'his',
   'I' : 'ile',
   'K' : 'lys',
   'L' : 'leu',

   'M' : 'met',
   'N' : 'asn',
   'P' : 'pro',
   'Q' : 'gln',
   'R' : 'arg',

   'S' : 'ser',
   'T' : 'thr',
   'V' : 'val',
   'W' : 'trp',
   'Y' : 'tyr',
}

from pymol import editor
from pymol import cmd

def build(object_name, sequence, first_residue = "1"):
   if len(sequence):
      code = sequence[0]
      cmd.fragment(aa_dict[code],object_name)
      cmd.alter(object_name,'resi="%s"'%first_residue)
      cmd.edit(object_name+" and name C")
      for code in sequence[1:]:
         editor.attach_amino_acid("pk1",aa_dict[code])
      cmd.edit()
      
build("poly_ala","ACDEFGHIKLMNPQRSTVWY")

cmd.zoom()