IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
rotamer/rotamer_pdb2.py

rotamer_pdb.py is a script demonstrating the usage of RotamerCalculator and RotamerLibrary. It reads a PDB file and a rotamer library file, and tries to rotate the atoms based on the most probable chi angles from the rotamer library. Then it saves the rotated atoms to a specified output PDB file.

Usage:

python rotamer_pdb.py -i <input>.pdb -l <rotamer_library>.lib -o <output>.pdb

Example (the result will be saved into transformed_1z5s_A.pdb):

../../../tools/imppy.sh python rotamer_pdb.py -i ../../atom/test/input/1z5s_A.pdb \ -l /path/to/ALL.bbdep.rotamers.lib -o transformed_1z5s_A.pdb

1 ## \example rotamer/rotamer_pdb2.py
2 # rotamer_pdb.py is a script demonstrating the usage of
3 # RotamerCalculator and RotamerLibrary. It reads a PDB file and a
4 # rotamer library file, and tries to rotate the atoms based on the
5 # most probable chi angles from the rotamer library. Then it saves
6 # the rotated atoms to a specified output PDB file.
7 #
8 # Usage:
9 #
10 # `python rotamer_pdb.py -i <input>.pdb -l <rotamer_library>.lib -o <output>.pdb`
11 #
12 # Example (the result will be saved into transformed_1z5s_A.pdb):
13 #
14 # `../../../tools/imppy.sh python rotamer_pdb.py -i ../../atom/test/input/1z5s_A.pdb \
15 # -l /path/to/ALL.bbdep.rotamers.lib -o transformed_1z5s_A.pdb`
16 #
17 
18 #!/usr/bin/env python
19 
20 from __future__ import print_function
21 import IMP
22 import IMP.core
23 import IMP.atom
24 import IMP.algebra
25 import IMP.rotamer
26 
27 
28 def transform(input_pdb, input_lib, output_pdb):
29  # read rotamer library
31  rl.read_library_file(input_lib)
33 
34  # read the original PDB
35  m = IMP.Model()
36  orig_h = IMP.atom.read_pdb(input_pdb, m)
37  mh = IMP.atom.get_by_type(orig_h, IMP.atom.RESIDUE_TYPE)
38 
39  # transform...
41  rc.transform(orig_h, hps, 0.9, 1e-6, 6)
42 
43  # save the rotated atoms to output PDB
44  IMP.atom.write_pdb(orig_h, output_pdb)
45 
46 
47 def quick_test():
50  rc.set_was_used(True)
51 
52 
53 if __name__ == '__main__':
54 
55  import sys
56 
57  P = IMP.ArgumentParser()
58  P.add_argument('--input_pdb', '-i', action='store',
59  help='input PDB file (required)')
60  P.add_argument('--input_lib', '-l', action='store',
61  help='input rotamer library file (required)')
62  P.add_argument('--output_pdb', '-o', action='store',
63  help='output PDB file (required)')
64  P.add_argument('--verbose', '-v', action='store_true',
65  help='show more messages')
66  args = P.parse_args()
67  if IMP.get_bool_flag('run_quick_test') or \
68  not (args.input_pdb or args.input_lib or args.output_pdb):
69  quick_test()
70  sys.exit(0)
71  if not args.input_pdb:
72  print('--input_pdb is required')
73  sys.exit(1)
74  if not args.output_pdb:
75  print('--output_pdb is required')
76  sys.exit(1)
77  if not args.input_lib:
78  print('--input_lib is required')
79  sys.exit(1)
80  if args.verbose:
81  IMP.set_log_level(IMP.VERBOSE)
82  else:
83  IMP.set_log_level(IMP.SILENT)
84  transform(args.input_pdb, args.input_lib, args.output_pdb)