ex_set_dihedral

Sets a particular values for Phi, Psi and Omega angles at a certain residue in a protein.

USAGE:
2gb1.pdb 18 -80.4 90.4 180.0

where 2gb1.pdb is the protein structure to be modified, 18 is the residue ID and the three following real values are Phi, Psi and omega dihedrals. The results is printed in PDB forma

Keywords:

Categories:

  • core/calc/structural/transformations/Rototranslation

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <cmath>

#include <core/data/io/Pdb.hh>
#include <core/data/structural/Structure.hh>
#include <core/data/structural/structure_selectors.hh>

#include <core/calc/structural/protein_angles.hh>
#include <core/calc/structural/transformations/Rototranslation.hh>
#include <utils/exit.hh>

using namespace core::data::structural;
using namespace core::data::io;
using namespace core::data::basic;

std::string program_info = R"(

Sets a particular values for Phi, Psi and Omega angles at a certain residue in a protein.
USAGE:
    2gb1.pdb 18 -80.4 90.4 180.0

where 2gb1.pdb is the protein structure to be modified, 18 is the residue ID and the three
following real values are Phi, Psi and omega dihedrals. The results is printed in PDB format
)";

/** @brief Sets a particular values for Phi, Psi and Omega angles at a certain residue in a protein.
 * *
 * CATEGORIES: core/calc/structural/transformations/Rototranslation
 * KEYWORDS:   PDB input; rototranslation; dihedral angles
 */
int main(const int argc, const char *argv[]) {

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

  // --- The first parameter of the program is the PDB file name
  core::data::io::Pdb reader(argv[1], is_not_alternative, false); // --- Read in a PDB file
  core::data::structural::Structure_SP strctr = reader.create_structure(0);
  // --- create a Structure object from the first model and extract the first chain (indexed as 'A') from it
  core::data::structural::Chain & chain = *(strctr->get_chain('A'));
  core::index2 res_idx = utils::from_string<core::index2>(argv[2]);
  core::calc::structural::transformations::Rototranslation rt;

  // --- Phi rotation; the new value of the Phi angle (in degrees) is the fourth parameter of this program
  if (argc > 3 && strlen(argv[3]) > 1) {
    core::real phi = core::calc::structural::evaluate_phi(*chain[res_idx-1],*chain[res_idx]);
    std::cerr << "Phi angle before change: " << phi * 180.0 / M_PI << " degrees\n";
    phi = utils::from_string<core::real>(argv[3]) * M_PI / 180.0 - phi;
    PdbAtom & N = *chain[res_idx]->find_atom_safe(" N  ");
    PdbAtom & CA = *chain[res_idx]->find_atom_safe(" CA ");
    core::calc::structural::transformations::Rototranslation::around_axis(N, CA, phi, CA, rt);
    for (core::index2 ires = 0 ; ires < res_idx; ++ires) {
      for (PdbAtom_SP ai : *chain[ires]) rt.apply(*ai);
    }
    if(chain[res_idx]->find_atom(" H  ")!=nullptr)
      rt.apply(*chain[res_idx]->find_atom(" H  "));
  }

  // --- Psi rotation; the new value of the Psi angle (in degrees) is the fifth parameter of this program
  if (argc > 4 && strlen(argv[4]) > 1) {
    core::real psi = core::calc::structural::evaluate_psi(*chain[res_idx],*chain[res_idx+1]);
    std::cerr << "Psi angle before change: " << psi * 180.0 / M_PI << " degrees\n";
    psi = utils::from_string<core::real>(argv[4]) * M_PI / 180.0 - psi;
    PdbAtom & C = *chain[res_idx]->find_atom_safe(" C  ");
    PdbAtom & CA = *chain[res_idx]->find_atom_safe(" CA ");
    core::calc::structural::transformations::Rototranslation::around_axis(CA, C, psi, C, rt);
    rt.apply(*chain[res_idx]->find_atom_safe(" O  "));
    for (core::index2 ires = res_idx + 1; ires < chain.count_residues(); ++ires) {
      for (PdbAtom_SP ai : *chain[ires]) rt.apply(*ai);
    }
  }

  // --- Omega rotation; the new value of the Omega angle (in degrees) is the fifth parameter of this program
  if (argc > 5 && strlen(argv[5]) > 1) {
    core::real omega = core::calc::structural::evaluate_omega(*chain[res_idx],*chain[res_idx+1]);
    std::cerr << "Omega angle before change: " << omega * 180.0 / M_PI << " degrees\n";
    omega = utils::from_string<core::real>(argv[5]) * M_PI / 180.0 - omega;
    PdbAtom & C = *chain[res_idx]->find_atom_safe(" C  ");
    PdbAtom & N = *chain[res_idx+1]->find_atom_safe(" N  ");
    core::calc::structural::transformations::Rototranslation::around_axis(C, N, omega, N, rt);
    for (core::index2 ires = res_idx + 1; ires < chain.count_residues(); ++ires) {
      for (PdbAtom_SP ai : *chain[ires]) rt.apply(*ai);
    }
  }

  std::for_each(chain.first_atom(),chain.last_atom(),[](PdbAtom_SP ai){std::cout << ai->to_pdb_line()<<"\n";});
}
../_images/file_icon.png