-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseq_files.py
executable file
·43 lines (36 loc) · 1.5 KB
/
seq_files.py
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
from pymol import cmd
from pymol import stored
from pymol.exporting import _resn_to_aa as one_letter
# *****************************************************************
# Saving every residue to separate file.
# Working example Thomas Holder.
# -----------------------------------------------------------------
# *****************************************************************
# CALLING SEQUENCE:
# PyMOL> set retain_order, 0
# PyMOL> load <object.pdb>
# PyMOL> run seq.py
# PyMOL> seq <state>
# PREPARATION:
# - No residues with resn 'UNK', substrate resn 'LIG'
# -----------------------------------------------------------------
# *****************************************************************
def seq(state, selection="name ca or resn hoh or resn lig"):
print "Generating seqs."
cmd.select("prot", selection)
while cmd.pop("_tmp", "prot"):
cmd.iterate("_tmp", "stored.x=(resn,resv)")
#print stored.x[0], stored.x[1]
# Special case 1: Waters.
if stored.x[0] == 'HOH':
filename = 'seq-x%s-%s.pdb' % (stored.x[1], state)
# Special case 2: Substrate.
elif stored.x[0] == 'LIG':
filename = 'seq-x%s-%s.pdb' % (stored.x[1], state)
# Other: protein back-bone.
else:
filename = 'seq-%s%d-%s.pdb' % (one_letter[stored.x[0]].lower(), stored.x[1], state)
cmd.save(filename, "byres _tmp")
cmd.delete('_tmp prot')
cmd.extend('seq', seq)
# -----------------------------------------------------------------