ap_orient_pdb

ap_orient_pdb reads a PDB file and orients the atoms along the axes so the longest protein dimension is along X and the second longest along Y. Then a second transformation is created to rotate a structure fragment around Z axis by 45 degrees

USAGE:
ap_orient_pdb [2kwi.pdb 419 446]

where 2kwi.pdb is the name of an input file and 419 446 is the first and last of the reoriented residues, respectively

Keywords:

Categories:

  • core/calc/numeric/PCA.hh

Input files:

Program source:

 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
#include <iostream>
#include <random>

#include <core/real.hh>
#include <core/index.hh>
#include <core/data/io/Pdb.hh>
#include <core/data/structural/structure_selectors.hh>
#include <core/calc/structural/transformations/Rototranslation.hh>
#include <core/calc/numeric/Pca3.hh>
#include <utils/exit.hh>
#include <core/calc/structural/angles.hh>

std::string program_info = R"(

ap_orient_pdb reads a PDB file and orients the atoms along the axes so the longest protein dimension is along X
and the second longest along Y. Then a second transformation is created to rotate a structure fragment around Z axis by 45 degrees

USAGE:
    ap_orient_pdb [2kwi.pdb 419 446]

where 2kwi.pdb is the name of an input file and 419 446 is the first and last of the reoriented residues, respectively

)";

/** @brief Shows how to rotate a piece of protein structure
 *
 * CATEGORIES: core/calc/numeric/PCA.hh
 * KEYWORDS: PDB input; structural fragment; structure selectors; PCA; transformations
 * IMG: helices.png
 * IMG_ALT: Alpha helix rotated a few times by a fixed angle
 */
int main(const int argc, const char *argv[]) {

  using namespace core::data::basic; // --- for Vec3 and Array2D

  if (argc < 2) utils::exit_OK_with_message(program_info); // --- complain about missing program parameter

  core::data::io::Pdb reader(argv[1]); // --- read the input PDB file
  core::data::structural::Structure_SP structure_sp = reader.create_structure(0); // --- create a structure corresponding to the first model

  std::vector<core::data::structural::PdbAtom_SP> points3d;

  // --- if a chain-ID and residue range were also given, create a selector to extract the relevant part of the input
  if (argc > 4) {
    std::string selection_string = utils::string_format("%c:%d-%d", argv[2][0], atoi(argv[3]), atoi(argv[4]));
    core::data::structural::SelectChainResidues selector(selection_string);
    // --- if selector selects (returns true), copy the atoms
    for (auto atom_it = structure_sp->first_atom(); atom_it != structure_sp->last_atom(); ++atom_it)
      if (selector((*atom_it)->owner())) points3d.push_back(*atom_it);
  } else { // --- If there is no selection, copy all the atoms from the given structure
    for (auto atom_it = structure_sp->first_atom(); atom_it != structure_sp->last_atom(); ++atom_it)
      points3d.push_back(*atom_it);
  }
  core::calc::numeric::Pca3 pca3(points3d);
  auto rt = pca3.create_transformation();
  std::cout << "MODEL        1\n";
  for (auto atom : points3d) {
    rt.apply(*atom);
    std::cout << (atom)->to_pdb_line() << "\n";
  }
  std::cout << "ENDMDL\n";
  auto rt2 = core::calc::structural::transformations::Rototranslation::around_axis(
    Vec3(0,0,1),core::calc::structural::to_radians(45.0),Vec3(0,0,0));
  for(int i=2;i<5;i++) {
    std::cout << "MODEL        " << i << "\n";
    for (auto atom : points3d) {
      rt2.apply(*atom);
      std::cout << atom->to_pdb_line() << "\n";
    }
    std::cout << "ENDMDL\n";
  }

}

../_images/helices.png