Debian Codegraph @

coords/mmdb-crystal.hh

raw symbols SCIP
1 /* coords/mmdb-crystal.h
2 *
3 * Copyright 2006 by The University of York
4 * Author: Paul Emsley
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 3 of the License, or (at
9 * your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copies of the GNU General Public License and
17 * the GNU Lesser General Public License along with this program; if not,
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
19 * Fifth Floor, Boston, MA, 02110-1301, USA.
20 * See http://www.gnu.org/licenses/
21 *
22 */
23
24 // -*-c++-*-
25
26 #ifndef MMDB_CRYSTAL
27 #define MMDB_CRYSTALcxx . . $ `coords/mmdb-crystal.hh:27:9`!
28
29 #include "Cartesian.hh"cxx . . $ `<file>/coords/Cartesian.hh`/
30 #include "coot-utils/atom-selection-container.hh"cxx . . $ `<file>/coot-utils/atom-selection-container.hh`/
31
32 namespace cootcxx . . $ coot/ {
33 class coot_v4cxx . . $ coot/coot_v4# {
34 public:
35 stdcxx . . $ std/::vectorcxx . . $ std/vector#<float> v4cxx . . $ coot/coot_v4#v4.;
36 };
37
38 class coot_mat44cxx . . $ coot/coot_mat44# {
39 public:
40 stdcxx . . $ std/::vectorcxx . . $ std/vector#<coot_v4cxx . . $ coot/coot_v4#> mcxx . . $ coot/coot_mat44#m.;
41 coot_mat44cxx . . $ coot/coot_mat44#coot_mat44(49f6e7a06ebc5aa8).() {
42 mcxx . . $ coot/coot_mat44#m..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(4);
43 for (int i=0; i<4; i++)
44 mcxx . . $ coot/coot_mat44#m.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i].v4cxx . . $ coot/coot_v4#v4..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(4);
45 }
46 bool is_close_to_unit_matrixcxx . . $ coot/coot_mat44#is_close_to_unit_matrix(50ce9a9e25b4a850).() const {
47 float sum_dist = 0.0;
48 for (int i=0; i<4; i++) {
49 for (int j=0; j<4; j++) {
50 if (i==j) {
51 if (i==3)
52 sum_dist += fabsf(mcxx . . $ coot/coot_mat44#m.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i].v4cxx . . $ coot/coot_v4#v4.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).j]);
53 else
54 sum_dist += fabsf(mcxx . . $ coot/coot_mat44#m.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i].v4cxx . . $ coot/coot_v4#v4.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).j]-1);
55 } else{
56 sum_dist += fabsf(mcxx . . $ coot/coot_mat44#m.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i].v4cxx . . $ coot/coot_v4#v4.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).j]);
57 }
58 }
59 }
60 return (sum_dist < 0.001);
61 }
62 };
63
64 class trans_selection_tcxx . . $ coot/trans_selection_t# {
65 public:
66 Cartesiancxx . . $ coot/Cartesian# frontcxx . . $ coot/trans_selection_t#front.;
67 Cartesiancxx . . $ coot/Cartesian# backcxx . . $ coot/trans_selection_t#back.;
68 Cartesiancxx . . $ coot/Cartesian# leftcxx . . $ coot/trans_selection_t#left.;
69 Cartesiancxx . . $ coot/Cartesian# rightcxx . . $ coot/trans_selection_t#right.;
70 Cartesiancxx . . $ coot/Cartesian# topcxx . . $ coot/trans_selection_t#top.;
71 Cartesiancxx . . $ coot/Cartesian# bottomcxx . . $ coot/trans_selection_t#bottom.;
72 bool point_is_in_boxcxx . . $ coot/trans_selection_t#point_is_in_box(4f0a7aeeebabedf4).(const cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# &point) const;
73 };
74 }
75
76 stdcxx . . $ std/::ostreamcxx . . $ std/ostream# & operatorcxx . . $ `operator<<`(f7f970f1ff2ebfee).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &s, const cootcxx . . $ coot/::coot_mat44cxx . . $ coot/coot_mat44# &m);
77
78 //! A class for symmetry operators
79 class symm_trans_tcxx . . $ symm_trans_t# {
80
81 int symm_nocxx . . $ symm_trans_t#symm_no., x_shift_cxx . . $ symm_trans_t#x_shift_., y_shift_cxx . . $ symm_trans_t#y_shift_., z_shift_cxx . . $ symm_trans_t#z_shift_.;
82
83 public:
84 //! symmetry as symm
85 stdcxx . . $ std/::stringcxx . . $ std/string# symm_as_stringcxx . . $ symm_trans_t#symm_as_string.;
86 symm_trans_tcxx . . $ symm_trans_t#symm_trans_t(748afa4755bc9595).(int n, int x, int y, int z) {
87 symm_nocxx . . $ symm_trans_t#symm_no. = n; x_shift_cxx . . $ symm_trans_t#x_shift_. = x; y_shift_cxx . . $ symm_trans_t#y_shift_. = y; z_shift_cxx . . $ symm_trans_t#z_shift_. = z; mmdbcxx . . $ mmdb/::Mat4Initcxx . . $ mmdb/Mat4Init(2d03b4dddd0d84e5).(matcxx . . $ symm_trans_t#mat.); };
88 explicit symm_trans_tcxx . . $ symm_trans_t#symm_trans_t(d4f767463ce0a6b3).(int idx) { symm_nocxx . . $ symm_trans_t#symm_no. = idx; x_shift_cxx . . $ symm_trans_t#x_shift_. = 0; y_shift_cxx . . $ symm_trans_t#y_shift_. = 0; z_shift_cxx . . $ symm_trans_t#z_shift_. = 0; }
89 symm_trans_tcxx . . $ symm_trans_t#symm_trans_t(49f6e7a06ebc5aa8).() {};
90 mmdbcxx . . $ mmdb/::mat44cxx . . $ mmdb/mat44# matcxx . . $ symm_trans_t#mat.;
91
92 friend stdcxx . . $ std/::ostreamcxx . . $ std/ostream# & operatorcxx . . $ `operator<<`(8bbe85a26905b0a).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &s, const symm_trans_tcxx . . $ symm_trans_t# &st);
93
94 //! the operator index (from SYMINFO)
95 int isymcxx . . $ symm_trans_t#isym(455f465bc33b4cdf).() const { return symm_nocxx . . $ symm_trans_t#symm_no.;};
96 //! the x-shift
97 int xcxx . . $ symm_trans_t#x(455f465bc33b4cdf).() const { return x_shift_cxx . . $ symm_trans_t#x_shift_.;};
98 //! the y-shift
99 int ycxx . . $ symm_trans_t#y(455f465bc33b4cdf).() const { return y_shift_cxx . . $ symm_trans_t#y_shift_.;};
100 //! the z-shift
101 int zcxx . . $ symm_trans_t#z(455f465bc33b4cdf).() const { return z_shift_cxx . . $ symm_trans_t#z_shift_.;};
102 void add_shiftcxx . . $ symm_trans_t#add_shift(b1146eedae1e1d0b).(int xs, int ys, int zs) {
103 x_shift_cxx . . $ symm_trans_t#x_shift_. += xs;
104 y_shift_cxx . . $ symm_trans_t#y_shift_. += ys;
105 z_shift_cxx . . $ symm_trans_t#z_shift_. += zs;
106 }
107
108 //! @return true if this symmetry operator is the identity matrix
109 bool is_identitycxx . . $ symm_trans_t#is_identity(c9857a73d68e59ba).();
110
111 //! symmetry as string
112 stdcxx . . $ std/::stringcxx . . $ std/string# strcxx . . $ symm_trans_t#str(66f8cb911a5426e1).(bool expanded_flag) const;
113
114 //! fill mat using mol
115 void as_mat44cxx . . $ symm_trans_t#as_mat44(74b71a2f3768dafd).(mmdbcxx . . $ mmdb/::mat44cxx . . $ mmdb/mat44# *mat, mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol);
116
117 //! fill m
118 void fill_matcxx . . $ symm_trans_t#fill_mat(5b0a958cc70af8d5).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol) {
119 as_mat44cxx . . $ symm_trans_t#as_mat44(74b71a2f3768dafd).(&matcxx . . $ symm_trans_t#mat., mol);
120 }
121
122 };
123
124 //! class for the cell translation for generation/application of symmery-related molecules
125 //!
126 class Cell_Translationcxx . . $ Cell_Translation# {
127
128 public:
129
130 //! unit cell steps
131 int uscxx . . $ Cell_Translation#us., vscxx . . $ Cell_Translation#vs., wscxx . . $ Cell_Translation#ws.;
132
133 //! constructor
134 Cell_Translationcxx . . $ Cell_Translation#Cell_Translation(49f6e7a06ebc5aa8).() {uscxx . . $ Cell_Translation#us.=0; vscxx . . $ Cell_Translation#vs.=0; wscxx . . $ Cell_Translation#ws.=0;}
135 //! constructor
136 Cell_Translationcxx . . $ Cell_Translation#Cell_Translation(b1146eedae1e1d0b).(int a, int b, int c);
137 friend stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& operatorcxx . . $ `operator<<`(aaf9bcb29705ab6a).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &s, Cell_Translationcxx . . $ Cell_Translation# ct);
138 //! inversion
139 Cell_Translationcxx . . $ Cell_Translation# invcxx . . $ Cell_Translation#inv(41436905654a045f).() const { return Cell_Translationcxx . . $ Cell_Translation#(-uscxx . . $ Cell_Translation#us., -vscxx . . $ Cell_Translation#vs., -wscxx . . $ Cell_Translation#ws.); }
140 };
141
142 stdcxx . . $ std/::stringcxx . . $ std/string# to_stringcxx . . $ to_string(d4c0f7a13452a29e).(const stdcxx . . $ std/::paircxx . . $ std/pair#<symm_trans_tcxx . . $ symm_trans_t#, Cell_Translationcxx . . $ Cell_Translation#> &sts);
143
144
145
146 class molecule_extents_tcxx . . $ molecule_extents_t# {
147
148 // coordinates of the most limiting atoms in the faces.
149 //
150 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# frontcxx . . $ molecule_extents_t#front., backcxx . . $ molecule_extents_t#back., leftcxx . . $ molecule_extents_t#left., rightcxx . . $ molecule_extents_t#right., topcxx . . $ molecule_extents_t#top., bottomcxx . . $ molecule_extents_t#bottom., centrecxx . . $ molecule_extents_t#centre.;
151 // front, back, minimum and maximum in z;
152 // left, right, minimum and maximum in x;
153 // bottom, top minimum and maximum in y;
154
155 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# extents_selectioncxx . . $ molecule_extents_t#extents_selection.;
156 float expansion_size_cxx . . $ molecule_extents_t#expansion_size_.;
157 // Grrr.. we cant have a function that returns an mmdb symmetry matrix.
158 // So modify it in place.
159 void shift_matrixcxx . . $ molecule_extents_t#shift_matrix(f12ae1caba62eb2).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol,
160 mmdbcxx . . $ mmdb/::mat44cxx . . $ mmdb/mat44# my_matt,
161 int x_shift, int y_shift, int z_shift,
162 mmdbcxx . . $ mmdb/::mat44cxx . . $ mmdb/mat44# new_matrix) const;
163
164 Cell_Translationcxx . . $ Cell_Translation# atom_sel_cell_transcxx . . $ molecule_extents_t#atom_sel_cell_trans.; // The reverse
165 // transformation to bring
166 // atom sel current position
167 // to close to the origin.
168 // So, it's the
169 // origin->current_position
170 // cell translation. Set by
171 // the constructor.
172
173 public:
174
175 // expansion_size is typically the symmetry radius
176 molecule_extents_tcxx . . $ molecule_extents_t#molecule_extents_t(a46d6ccb8a4046dd).(atom_selection_container_tcxx . . $ atom_selection_container_t#, float expansion_size);
177 ~cxx . . $ molecule_extents_t#`~molecule_extents_t`(49f6e7a06ebc5aa8).molecule_extents_tcxx . . $ molecule_extents_t#();
178 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# get_frontcxx . . $ molecule_extents_t#get_front(fdd76dab8e81a510).() const;
179 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# get_backcxx . . $ molecule_extents_t#get_back(fdd76dab8e81a510).() const;
180 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# get_leftcxx . . $ molecule_extents_t#get_left(fdd76dab8e81a510).() const;
181 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# get_rightcxx . . $ molecule_extents_t#get_right(fdd76dab8e81a510).() const;
182 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# get_topcxx . . $ molecule_extents_t#get_top(fdd76dab8e81a510).() const;
183 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# get_bottomcxx . . $ molecule_extents_t#get_bottom(fdd76dab8e81a510).() const;
184
185 Cell_Translationcxx . . $ Cell_Translation#
186 coord_to_unit_cell_translationscxx . . $ molecule_extents_t#coord_to_unit_cell_translations(b0949cae8bee1b1c).(cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# point,
187 atom_selection_container_tcxx . . $ atom_selection_container_t# AtomSel) const;
188
189 // Return vector size 0 when there is no symmetry
190 // (GetNumberOfSymOps returns 0)
191 //
192 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<symm_trans_tcxx . . $ symm_trans_t#, Cell_Translationcxx . . $ Cell_Translation#> >
193 which_boxescxx . . $ molecule_extents_t#which_boxes(dff80d6d1e44460).(cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# point,
194 atom_selection_container_tcxx . . $ atom_selection_container_t# AtomSel,
195 int shift_search_size = 1) const;
196
197 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<int, symm_trans_tcxx . . $ symm_trans_t#> >
198 which_strict_ncscxx . . $ molecule_extents_t#which_strict_ncs(5273511b94a857c6).(const cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# &centre_pt,
199 atom_selection_container_tcxx . . $ atom_selection_container_t# &AtomSel,
200 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<cootcxx . . $ coot/::coot_mat44cxx . . $ coot/coot_mat44#> &strict_ncs_mats,
201 const Cell_Translationcxx . . $ Cell_Translation# &c_t) const;
202
203 // new style
204
205 // use extents to fill transsel, use cryst from mol (not coords of mol)
206 cootcxx . . $ coot/::trans_selection_tcxx . . $ coot/trans_selection_t# trans_sel_ocxx . . $ molecule_extents_t#trans_sel_o(8d49a541ea708f5c).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, const symm_trans_tcxx . . $ symm_trans_t# &symm_trans) const;
207 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# trans_selcxx . . $ molecule_extents_t#trans_sel(8ffb2f07ab6cfc66).(mmdbcxx . . $ mmdb/::Crystcxx . . $ mmdb/Cryst# *my_cryst, symm_trans_tcxx . . $ symm_trans_t# symm_trans) const;
208 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# trans_selcxx . . $ molecule_extents_t#trans_sel(8d0628e64c1b3c3b).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, const symm_trans_tcxx . . $ symm_trans_t# &symm_trans) const;
209 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# trans_selcxx . . $ molecule_extents_t#trans_sel(89d0c1ed84386e24).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, mmdbcxx . . $ mmdb/::mat44cxx . . $ mmdb/mat44# my_mat,
210 int x_shift, int y_shift, int z_shift) const;
211
212
213 bool point_is_in_boxcxx . . $ molecule_extents_t#point_is_in_box(d0389468fcb5043c).(const cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# &point, mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# TransSel) const;
214
215 friend stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& operatorcxx . . $ `operator<<`(3da8a14749d8bb46).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &s, const molecule_extents_tcxx . . $ molecule_extents_t# &e);
216 };
217
218
219
220 // Let's use symmetry in a properly OO manner, rather than the fortran
221 // way that I dislike. Hide all that here.
222 //
223 class SymmMatrixcxx . . $ SymmMatrix# {
224
225 double matcxx . . $ SymmMatrix#mat.[4][4];
226
227 public:
228
229 SymmMatrixcxx . . $ SymmMatrix#SymmMatrix(49f6e7a06ebc5aa8).(); // creates identity matrix.
230 SymmMatrixcxx . . $ SymmMatrix#SymmMatrix(3b0497aa59ba007d).(double** in_mat); // creates from a mmdb::mat44.
231
232 double** getMatcxx . . $ SymmMatrix#getMat(5692d059b6a4bcd7).() const;
233 // float[4][4] testing() const; // oh. C++ does not allow us to return
234 // a mmdb::mat44 - grumble.
235
236 void add_unit_shiftcxx . . $ SymmMatrix#add_unit_shift(b1146eedae1e1d0b).(int x, int y, int z);
237 friend stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& operatorcxx . . $ `operator<<`(7bb435dd6f24994f).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream#&, SymmMatrixcxx . . $ SymmMatrix#);
238
239 };
240
241
242 // return an atom selection that has had the symm_trans
243 // applied to it.
244 //
245 mmdbcxx . . $ mmdb/::PPAtomcxx . . $ mmdb/PPAtom# translated_atomscxx . . $ translated_atoms(bc972b4e575757a2).(atom_selection_container_tcxx . . $ atom_selection_container_t# AtomSel,
246 symm_trans_tcxx . . $ symm_trans_t# symm_trans);
247
248 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# translate_atomcxx . . $ translate_atom(e293b8589db6035d).(atom_selection_container_tcxx . . $ atom_selection_container_t# AtomSel,
249 int i,
250 symm_trans_tcxx . . $ symm_trans_t# symm_trans);
251
252 cootcxx . . $ coot/::Cartesiancxx . . $ coot/Cartesian# translate_atom_with_pre_shiftcxx . . $ translate_atom_with_pre_shift(e763c068d949965e).(atom_selection_container_tcxx . . $ atom_selection_container_t# AtomSel,
253 int i,
254 const stdcxx . . $ std/::paircxx . . $ std/pair#<symm_trans_tcxx . . $ symm_trans_t#, Cell_Translationcxx . . $ Cell_Translation#> &symm_trans);
255
256 // Tinker with asc (actually, internally, the mmdb::CMMDBCryst of asc)
257 //
258 // Return 1 on success, 0 on failure.
259 int set_mmdb_cell_and_symmcxx . . $ set_mmdb_cell_and_symm(12417a5beffa055b).(atom_selection_container_tcxx . . $ atom_selection_container_t# asc,
260 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<float>, stdcxx . . $ std/::stringcxx . . $ std/string#> cell_spgr);
261
262
263 #endif // MMDB_CRYSTAL