Xmipp  v3.23.11-Nereus
symmetries.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar S. Sorzano (coss@cnb.csic.es)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 /* ------------------------------------------------------------------------- */
26 /* SYMMETRIES */
27 /* ------------------------------------------------------------------------- */
28 #ifndef _CORE_SYMMETRIES_HH
29 #define _CORE_SYMMETRIES_HH
30 
31 #include "matrix1d.h"
32 #include "matrix2d.h"
33 #include "xmipp_funcs.h"
34 #include "args.h"
35 #include "transformations.h"
36 #include "metadata_base.h"
37 #include "metadata_row_base.h"
38 
51 //define the crystallographic groups
52 //symmetry matices from http://cci.lbl.gov/asu_gallery/
53 #define sym_undefined -1
54 #define sym_P1 1
55 #define sym_P2 3//c-axis, b-axis
56 #define sym_P2_1 4
57 #define sym_C2 12
58 #define sym_P222 16
59 #define sym_P2_122 17
60 #define sym_P22_12 1717
61 //#define sym_P22_12 17
62 #define sym_P22_12_1 18
63 #define sym_P4 75
64 #define sym_P422 89
65 #define sym_P42_12 90
66 #define sym_P3 143
67 #define sym_P312 150
68 #define sym_P6 168
69 #define sym_P622 177
70 // This constant is obsolete and should be revised with the use of
71 // matrix euality accuracy
72 #define SYM_ACCURACY 1e-6
73 //point group symmetries
74 #define pg_CI 200
75 #define pg_CS 201
76 #define pg_CN 202
77 #define pg_CNV 203
78 #define pg_CNH 204
79 #define pg_SN 205
80 #define pg_DN 206
81 #define pg_DNV 207
82 #define pg_DNH 208
83 #define pg_T 209
84 #define pg_TD 210
85 #define pg_TH 211
86 #define pg_O 212
87 #define pg_OH 213
88 #define pg_I 214 //default xmipp icosahedaral symmetry
89 #define pg_IH 215
90 
91 #define pg_I1 216 //no crowther 222
92 #define pg_I2 217 //crowther 222-> default in xmipp
93 #define pg_I3 218 //52 as used by spider
94 #define pg_I4 219 //another 52
95 #define pg_I5 220 //another another 52 (used by EMBL-matfb)
96 
97 #define pg_I1H 221 //no crowther 222, + mirror plane
98 #define pg_I2H 222 //crowther 222-> default in xmipp+ mirror plane
99 #define pg_I3H 223 //52 as used by spider+ mirror plane
100 #define pg_I4H 224 //another 52+ mirror plane
101 #define pg_I5H 225 //another another 52 (used by EMBL-matfb)+ mirror plane
102 
110 #define SYMINDEX(SL, sym_no, i, numIMG) \
111  numIMG+SL.__L.mdimy/4*i+sym_no
112 
138 class SymList
139 {
140 private:
141  // Crystallographic space group. This is only a guess based on angles.
142  // No check on vectors magnitude is made
143  int space_group;
144 public:
145  // L and R matrices
147  Matrix2D<double> __shift; // It is used for crystallographic symmetries
149 
150  // As the symmetry elements form a subgroup, this is the number of
151  // true symmetry elements belonging to the list, the rest of
152  // the list are simply the elements to fill the subgroup
154 
155  // Number of Axis, mirrors, ...
157 
158 public:
163  {
164  __sym_elements = true_symNo = space_group = 0;
165  }
166 
170  SymList(const FileName& fn_sym, double accuracy = SYM_ACCURACY)
171  {
172  readSymmetryFile(fn_sym, accuracy);
173  }
174 
179  bool isSymmetryGroup(FileName fn_sym, int &pgGroup, int &pgOrder);
180 
182  void fillSymmetryClass(const FileName &symmetry, int pgGroup, int pgOrder,
183  std::vector<std::string> &fileContent);
184 
200  bool homogeneous=true) const;
201 
214  void setMatrices(int i, const Matrix2D<double> &L,
215  const Matrix2D<double> &R);
216 
219  void getShift(int i, Matrix1D<double> &shift) const;
220 
223  void setShift(int i, const Matrix1D<double> &shift);
224 
228  void addShift(const Matrix1D<double> &shift);
229 
235  int readSymmetryFile(FileName fn_sym, double accuracy = SYM_ACCURACY);
236 
246  void addMatrices(const Matrix2D<double> &L, const Matrix2D<double> &R,
247  int chain_length);
248 
257  void computeSubgroup(double accuracy = SYM_ACCURACY);
258 
268  int symsNo() const
269  {
270  return MAT_YSIZE(__L) / 4;
271  }
275  int spaceGroup() const
276  {
277  return space_group;
278  }
283  int trueSymsNo() const
284  {
285  return true_symNo;
286  }
287 
295  int crystallographicSpaceGroup(double mag_a,
296  double mag_b,
297  double ang_a2b_deg) const;
298 
301  double nonRedundantProjectionSphere(int pgGroup, int pgOrder);
302 
313  double computeDistance(double rot1, double tilt1,
314  double psi1, double &rot2, double &tilt2, double &psi2,
315  bool projdir_mode, bool check_mirrors, bool object_rotation=false,
316  bool write_mirrors = true);
345  void computeDistance(MetaData &md,
346  bool projdir_mode, bool check_mirrors,
347  bool object_rotation=false);
351  void breakSymmetry(double rot1, double tilt1, double psi1,
352  double &rot2, double &tilt2, double &psi2
353  );
354 
355 };
357 #endif
double nonRedundantProjectionSphere(int pgGroup, int pgOrder)
#define MAT_YSIZE(m)
Definition: matrix2d.h:124
#define SYM_ACCURACY
Definition: symmetries.h:72
void getMatrices(int i, Matrix2D< double > &L, Matrix2D< double > &R, bool homogeneous=true) const
Definition: symmetries.cpp:348
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
Definition: symmetries.cpp:33
bool isSymmetryGroup(FileName fn_sym, int &pgGroup, int &pgOrder)
Definition: symmetries.cpp:601
int symsNo() const
Definition: symmetries.h:268
void getShift(int i, Matrix1D< double > &shift) const
Definition: symmetries.cpp:391
Matrix1D< int > __chain_length
Definition: symmetries.h:148
int __sym_elements
Definition: symmetries.h:156
Matrix2D< double > __shift
Definition: symmetries.h:147
void computeSubgroup(double accuracy=SYM_ACCURACY)
Definition: symmetries.cpp:467
#define i
void fillSymmetryClass(const FileName &symmetry, int pgGroup, int pgOrder, std::vector< std::string > &fileContent)
Definition: symmetries.cpp:879
void setMatrices(int i, const Matrix2D< double > &L, const Matrix2D< double > &R)
Definition: symmetries.cpp:378
int crystallographicSpaceGroup(double mag_a, double mag_b, double ang_a2b_deg) const
Definition: symmetries.cpp:541
double computeDistance(double rot1, double tilt1, double psi1, double &rot2, double &tilt2, double &psi2, bool projdir_mode, bool check_mirrors, bool object_rotation=false, bool write_mirrors=true)
Matrix2D< double > __R
Definition: symmetries.h:146
void addMatrices(const Matrix2D< double > &L, const Matrix2D< double > &R, int chain_length)
Definition: symmetries.cpp:418
void addShift(const Matrix1D< double > &shift)
Definition: symmetries.cpp:408
Matrix2D< double > __L
Definition: symmetries.h:146
int true_symNo
Definition: symmetries.h:153
void breakSymmetry(double rot1, double tilt1, double psi1, double &rot2, double &tilt2, double &psi2)
void setShift(int i, const Matrix1D< double > &shift)
Definition: symmetries.cpp:399
SymList(const FileName &fn_sym, double accuracy=SYM_ACCURACY)
Definition: symmetries.h:170
int spaceGroup() const
Definition: symmetries.h:275
int trueSymsNo() const
Definition: symmetries.h:283