Gemmi C++ API
Loading...
Searching...
No Matches
gemmi
include
gemmi
riding_h.hpp
Go to the documentation of this file.
1
// Copyright 2018-2022 Global Phasing Ltd.
2
//
3
// Place hydrogens according to bond lengths and angles from monomer library.
4
5
#ifndef GEMMI_RIDING_H_HPP_
6
#define GEMMI_RIDING_H_HPP_
7
8
#include <cmath>
// for isnan
9
#include "
topo.hpp
"
// for Topo
10
11
namespace
gemmi
{
12
13
GEMMI_DLL
void
place_hydrogens_on_all_atoms
(
Topo
&
topo
);
14
15
inline
void
adjust_hydrogen_distances
(
Topo
&
topo
,
Restraints::DistanceOf
of
,
16
double
default_scale
=1.) {
17
for
(
const
Topo::Bond
&
t
:
topo
.bonds) {
18
assert
(
t
.atoms[0] !=
nullptr
&&
t
.atoms[1] !=
nullptr
);
19
if
(
t
.atoms[0]->is_hydrogen() ||
t
.atoms[1]->is_hydrogen()) {
20
Position
u =
t
.atoms[1]->pos -
t
.atoms[0]->pos;
21
double
scale =
t
.restr->distance(
of
) / u.length();
22
if
(std::isnan(scale))
23
scale =
default_scale
;
24
if
(
t
.atoms[1]->is_hydrogen())
25
t
.atoms[1]->pos =
t
.atoms[0]->pos + u * scale;
26
else
27
t
.atoms[0]->pos =
t
.atoms[1]->pos - u * scale;
28
}
29
}
30
}
31
32
}
// namespace gemmi
33
#endif
GEMMI_DLL
#define GEMMI_DLL
Definition
fail.hpp:53
gemmi
Definition
addends.hpp:12
gemmi::adjust_hydrogen_distances
void adjust_hydrogen_distances(Topo &topo, Restraints::DistanceOf of, double default_scale=1.)
Definition
riding_h.hpp:15
gemmi::place_hydrogens_on_all_atoms
GEMMI_DLL void place_hydrogens_on_all_atoms(Topo &topo)
gemmi::HklValue
Definition
asudata.hpp:97
gemmi::Position
Coordinates in Angstroms - orthogonal (Cartesian) coordinates.
Definition
unitcell.hpp:32
gemmi::Restraints::DistanceOf
DistanceOf
Definition
chemcomp.hpp:69
gemmi::Topo::Bond
Definition
topo.hpp:31
gemmi::Topo
Definition
topo.hpp:23
topo.hpp
Generated by
1.9.8