# ex_local_coordinates_three_atoms¶

ex_local_coordinates_three_atoms reads a PDB file and prints local coordinates for sidechain atoms.

For every residue, a local coordinate system (LCS) is constructed based on N, C-alpha and C atoms. The program prints positions of all atoms of a residue in its LCS

USAGE:
ex_local_coordinates_three_atoms 5edw.pdb


## Categories:¶

• core::calc::structural::transformations::local_coordinates_three_atoms

## 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 #include #include #include #include #include std::string program_info = R"( ex_local_coordinates_three_atoms reads a PDB file and prints local coordinates for sidechain atoms. For every residue, a local coordinate system (LCS) is constructed based on N, C-alpha and C atoms. The program prints positions of all atoms of a residue in its LCS USAGE: ex_local_coordinates_three_atoms 5edw.pdb )"; /** @brief Reads a PDB file and prints local coordinates for sidechain atoms * * CATEGORIES: core::calc::structural::transformations::local_coordinates_three_atoms * KEYWORDS: PDB input; local coordinates; rototranslation */ 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; core::data::io::Pdb reader(argv[1]); core::data::structural::Structure_SP strctr = reader.create_structure(0); for (auto it_resid = strctr->first_residue(); it_resid != strctr->last_residue(); ++it_resid) { PdbAtom_SP n = (*it_resid)->find_atom(" N "); PdbAtom_SP ca = (*it_resid)->find_atom(" CA "); PdbAtom_SP c = (*it_resid)->find_atom(" C "); if ((n == nullptr)||(ca == nullptr)||(c == nullptr)) { std::cout << "Missing backbone atom\n"; continue; } core::calc::structural::transformations::Rototranslation_SP rt = core::calc::structural::transformations::local_coordinates_three_atoms(*n,*ca,*c); Vec3 tmp_atom; for (auto i_atom : **it_resid) { 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!"); } } }