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):
python rotamer_pdb.py -i ../../atom/test/input/1z5s_A.pdb \ -l /path/to/ALL.bbdep.rotamers.lib -o transformed_1z5s_A.pdb
20 from __future__
import print_function
28 def transform(input_pdb, input_lib, output_pdb):
32 mh = IMP.atom.get_by_type(orig_h, IMP.atom.RESIDUE_TYPE)
36 rl.read_library_file(input_lib)
43 rr = rc.get_rotamer(rd, 0.01)
44 rotamers.append((rd, rr))
48 for rd, rr
in rotamers:
49 for h
in IMP.atom.get_by_type(rd, IMP.atom.ATOM_TYPE):
51 at_t = at.get_atom_type()
52 if rr.get_atom_exists(at_t):
54 idx = min(rr.get_number_of_cases(at_t) - 1, 1)
55 v = rr.get_coordinates(idx, at_t)
57 xyz.set_coordinates(v)
69 if __name__ ==
'__main__':
74 P.add_argument(
'--input_pdb',
'-i', action=
'store',
75 help=
'input PDB file (required)')
76 P.add_argument(
'--input_lib',
'-l', action=
'store',
77 help=
'input rotamer library file (required)')
78 P.add_argument(
'--output_pdb',
'-o', action=
'store',
79 help=
'output PDB file (required)')
80 P.add_argument(
'--verbose',
'-v', action=
'store_true',
81 help=
'show more messages')
84 not (args.input_pdb
or args.input_lib
or args.output_pdb):
87 if not args.input_pdb:
88 print(
'--input_pdb is required')
90 if not args.output_pdb:
91 print(
'--output_pdb is required')
93 if not args.input_lib:
94 print(
'--input_lib is required')
100 transform(args.input_pdb, args.input_lib, args.output_pdb)