ex_local_BBQ_coordinates

ex_local_BBQ_coordinates reads a PDB file and prints local coordinates for sidechain atoms

USAGE:
ex_local_BBQ_coordinates 5edw.pdb

Keywords:

Categories:

  • core::calc::structural::transformations::local_BBQ_coordinates

Input files:

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

#include <core/data/io/Pdb.hh>
#include <core/calc/structural/transformations/Rototranslation.hh>
#include <core/calc/structural/transformations/transformation_utils.hh>
#include <utils/exit.hh>

std::string program_info = R"(

ex_local_BBQ_coordinates reads a PDB file and prints local coordinates for sidechain atoms
USAGE:
    ex_local_BBQ_coordinates 5edw.pdb

)";

/** @brief Reads a PDB file and prints local coordinates for side chain atoms
 *
 * CATEGORIES: core::calc::structural::transformations::local_BBQ_coordinates
 * KEYWORDS:   PDB input; Local coordinates
 */
int main(const int argc, const char* argv[]) {

  if(argc < 2) utils::exit_OK_with_message(program_info); // --- complain about missing program parameter
  using namespace core::data::structural;
  using namespace core::calc::structural::transformations;

  core::data::io::Pdb reader(argv[1]);
  Structure_SP strctr = reader.create_structure(0);

  Rototranslation_SP rt = nullptr;
  for(auto a_chain : *strctr) {
    for (core::index2 i_residue = 1; i_residue < a_chain->count_residues() - 1; ++i_residue) {
      const Residue & the_residue = *(*a_chain)[i_residue];
      const Residue & prev_residue = *(*a_chain)[i_residue - 1];
      const Residue & next_residue = *(*a_chain)[i_residue + 1];
      try {
        rt = local_BBQ_coordinates(*prev_residue.find_atom_safe(" CA "),
          *the_residue.find_atom_safe(" CA "), *next_residue.find_atom_safe(" CA "));
      } catch (utils::exceptions::AtomNotFound ex) {
        i_residue+=2;
        continue;
      }
      Vec3 tmp_atom;
      for (auto i_atom : the_residue) {
        tmp_atom = *i_atom;
        rt->apply(*i_atom);
        std::cout << i_atom->to_pdb_line() << "\n";
        // --- Here we test if the inverse transformation really moves an atom to its original location
        rt->apply_inverse(*i_atom);
        if(tmp_atom.distance_to(*i_atom)>0.001)
          throw std::runtime_error("Incorrect position after transformation!");
      }
    }
  }
}
../_images/file_icon.png