-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathpdb_superimpose.py
152 lines (115 loc) · 4.37 KB
/
pdb_superimpose.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
################################################################################
#
# MRC FGU Computational Genomics Group
#
# $Id$
#
# Copyright (C) 2009 Andreas Heger
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#################################################################################
'''
pdb_superimpose.py -
======================================================
:Author: Andreas Heger
:Release: $Id$
:Date: |today|
:Tags: Python
Purpose
-------
.. todo::
describe purpose of the script.
Usage
-----
Example::
python pdb_superimpose.py --help
Type::
python pdb_superimpose.py --help
for command line help.
Documentation
-------------
Code
----
'''
USAGE="""superimposes two pdb structures
python pdb2superimpose.py [OPTIONS] filename1 filename2 alignment
Options:
-i, --iterations # do iterative superimposition, number specifies
maximum number of iterations
-c, --cutoff proximity cutoff for iterative superimposition
"""
import sys, string, os, getopt
import Experiment, PdbTools, numpy
param_loglevel = 1
param_format = "plain"
param_cutoff = 3.0
param_max_iterations = 0
param_write_pdb = None
param_write_rotated = None
if __name__ == '__main__':
try:
optlist, args = getopt.getopt(sys.argv[1:],
"V:i:c:p:r:",
["Verbose=", "cutoff", "iterations", "write_pdb",
"write_rotated"])
except getopt.error, msg:
print USAGE
sys.exit(2)
for o,a in optlist:
if o in ("-f", "--format"):
param_format = a
elif o in ("-i", "--iterations"):
param_max_iterations = string.atoi(a)
elif o in ("-c", "--cutff"):
param_cutoff = string.atof( cutoff )
elif o in ("-p", "--write_pdb"):
param_write_pdb = a
elif o in ("-p", "--write_rotated"):
param_write_rotated = a
if len(args) < 3:
print USAGE
print "not enough arguments specified"
sys.exit(1)
param_filename_pdb1 = args[0]
param_filename_pdb2 = args[1]
param_filename_alignment = args[2]
print Experiment.GetHeader()
print Experiment.GetParams()
try:
rmsd, natoms, translation, rotation, iterations = PdbTools.IterativeSuperImposition( param_filename_pdb1,
param_filename_pdb2,
param_filename_alignment,
max_iterations = param_max_iterations,
cutoff = param_cutoff)
except ValueError, msg:
print "# ERROR: %s" % msg
print "rmsd\tna"
print "natoms\tna"
print "iterations\tna"
sys.exit(1)
print "rmsd\t%5.2f" % rmsd
print "natoms\t%i" % natoms
print "iterations\t%i" % iterations
print translation
print rotation
if param_write_pdb:
PdbTools.MergePdbFiles( (param_filename_pdb1, param_filename_pdb2),
rotations=( ( translation, rotation ), None),
target = param_write_pdb )
if param_write_rotated:
PdbTools.RotatePdbFile( param_filename_pdb1,
param_write_rotated,
translation,
rotation)