IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
rotamer_pdb2.py
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 # `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 import IMP
21 import IMP.core
22 import IMP.atom
23 import IMP.algebra
24 import IMP.rotamer
25 
26 
27 def transform(input_pdb, input_lib, output_pdb):
28  # read rotamer library
30  rl.read_library_file(input_lib)
32 
33  # read the original PDB
34  m = IMP.Model()
35  orig_h = IMP.atom.read_pdb(input_pdb, m)
36  # mh = IMP.atom.get_by_type(orig_h, IMP.atom.RESIDUE_TYPE)
37 
38  # transform...
40  rc.transform(orig_h, hps, 0.9, 1e-6, 6)
41 
42  # save the rotated atoms to output PDB
43  IMP.atom.write_pdb(orig_h, output_pdb)
44 
45 
46 def quick_test():
49  rc.set_was_used(True)
50 
51 
52 if __name__ == '__main__':
53 
54  import sys
55 
56  P = IMP.ArgumentParser()
57  P.add_argument('--input_pdb', '-i', action='store',
58  help='input PDB file (required)')
59  P.add_argument('--input_lib', '-l', action='store',
60  help='input rotamer library file (required)')
61  P.add_argument('--output_pdb', '-o', action='store',
62  help='output PDB file (required)')
63  P.add_argument('--verbose', '-v', action='store_true',
64  help='show more messages')
65  args = P.parse_args()
66  if IMP.get_bool_flag('run_quick_test') or \
67  not (args.input_pdb or args.input_lib or args.output_pdb):
68  quick_test()
69  sys.exit(0)
70  if not args.input_pdb:
71  print('--input_pdb is required')
72  sys.exit(1)
73  if not args.output_pdb:
74  print('--output_pdb is required')
75  sys.exit(1)
76  if not args.input_lib:
77  print('--input_lib is required')
78  sys.exit(1)
79  if args.verbose:
80  IMP.set_log_level(IMP.VERBOSE)
81  else:
82  IMP.set_log_level(IMP.SILENT)
83  transform(args.input_pdb, args.input_lib, args.output_pdb)
A class storing a whole rotamer library read from a file.
bool get_bool_flag(std::string name)
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
Score distance between two particle centers using a harmonic function.
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Transform a hierarchy. This is aware of rigid bodies.
A class performing the rotations of atoms in the residues.
Sampling of sidechain rotamers.
IMP-specific subclass of argparse.ArgumentParser.
Definition: __init__.py:9592
void set_log_level(LogLevel l)
Set the current global log level.
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Functionality for loading, creating, manipulating and scoring atomic structures.