EMAN2
pointarray.h
Go to the documentation of this file.
1/*
2 * Author: Wen Jiang, 08/11/2004 (jiang12@purdue.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#ifndef eman_pointarray_h_
33#define eman_pointarray_h_
34
35#include "emdata.h"
36#include "transform.h"
37
38#if defined USE_NFFT || USE_NFFT2
39extern "C"
40{
41 #include "nfft.h"
42 #include "utils.h"
43}
44#endif
45
46#include <sys/stat.h>
47
48namespace EMAN
49{
52 {
53 public:
55 {
57 };
58
59 public:
60 PointArray();
61 explicit PointArray(int nn);
63 void zero();
66 size_t get_number_points() const;
67 void set_number_points(size_t nn);
68 bool read_from_pdb(const char *file, const vector<int> &lines=vector<int>());
69 void save_to_pdb(const char *file);
71 void center_to_zero(); // shift center to zero
73 double *get_points_array();
74 Vec3f get_vector_at(int i); // get the ith vector in the list
75 double get_value_at(int i); // get the amplitude of the ith vector
76 void set_vector_at(int i,Vec3f vec,double value);
77 void set_vector_at(int i,vector<double>);
78 void set_points_array(double *p);
83 vector<float> get_points();
84
90 EMData *distmx(int sortrows=0); // computes a distance matrix
91
100 vector<int> match_points(PointArray *to,float max_miss=-1.0);
101
102
109 Transform *align_2d(PointArray *to,float max_dist); // computes the optimal alignment between two (non-identical) sets of points
110
111 void mask(double rmax, double rmin = 0.0);
112 void mask_asymmetric_unit(const string & sym);
113 void transform(const Transform& transform);
114
119
120 void set_from(vector<float>);
121 void set_from(PointArray * source, const string & sym = "", Transform *transform=0);
122 void set_from(double *source, int num, const string & sym = "", Transform *transform=0);
123 void set_from_density_map(EMData * map, int num, float thresh, float apix,
125 void sort_by_axis(int axis = 1); // x,y,z axes = 0, 1, 2
126 EMData *pdb2mrc_by_nfft(int map_size, float apix, float res); // return real space 3-D map
127 EMData *pdb2mrc_by_summation(int map_size, float apix, float res, int addpdbbfactor); // return real space 3-D map
128 EMData *projection_by_nfft(int image_size, float apix, float res = 0); // return 2-D Fourier Transform
129 EMData *projection_by_summation(int image_size, float apix, float res); // return 2-D real space image
130 void replace_by_summation(EMData *image, int i, Vec3f vec, float amp, float apix, float res); // changes a single Gaussian from the projection
131
139 void opt_from_proj(const vector<EMData*> & proj,float pixres);
140
142 inline double sim_pointpotential(double dist, double ang, double dihed) {
143 return pow(dist-dist0,2.0)*distc+ang*ang*angc+pow(dihed-dihed0,2.0)*dihedc;
144 }
145
147 double sim_potential();
148
150 double sim_potentiald(int ind);
151
153 double sim_potentialdxyz(int i,double dx, double dy, double dz);
154
156 void sim_updategeom();
157
159 Vec3f sim_descent(int i);
160
162 void sim_minstep(double maxshift);
163
165 void sim_minstep_seq(double meanshift);
166
168 void sim_rescale();
169
171 void sim_printstat();
172
174 void sim_set_pot_parms(double pdist0,double pdistc,double pangc, double pdihed0, double pdihedc, double pmapc, EMData *pmap,double pmindistc,double pdistpenc);
175
178 void sim_add_point_one();
179
181 double calc_total_length();
182
184 vector<double> fit_helix(EMData *pmap,int minlength,float mindensity,vector<int> edge,int twodir,size_t minl);
185
187 vector<float> do_pca(int start, int end);
188
190 vector<float> do_filter(vector<float> pts, float *ft, int num);
191
193 vector<double> construct_helix(int start,int end,float phs, float &score,int &dir);
194
196 void reverse_chain();
197
199 void merge_to(PointArray &pa, float thr);
200
202 float calc_helicity(vector<double> pts);
203
205 void save_pdb_with_helix(const char *file, vector<float> hlxid);
206
208 void delete_point(int id);
209
211 void remove_helix_from_map(EMData *m, vector<float> hlxid);
212
214 bool read_ca_from_pdb(const char *file);
215
219
220 private:
221 double *points;
222 size_t n;
223 double *bfactor;
224
225 // These are used internally for the simple dynamics/minimization code, and are otherwise unallocated
226 // Note that this is NOT for PDB MD, just for simplified point-chains, and mapping points into density
227 double *adist; // distance squared between the numbered point and the previous point with wrap-around
228 double *aang; // angle at the numbered point using the point before and the point after
229 double *adihed; // dihedral using 2 points before and one point after
230
245 bool map2d; // map is 2d
248 vector<Vec3f> oldshifts;
250 };
251}
252
253#endif
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
FloatPoint defines a float-coordinate point in a 1D/2D/3D space.
Definition: geometry.h:278
PointArray defines a double array of points with values in a 3D space.
Definition: pointarray.h:52
EMData * gradz
Definition: pointarray.h:247
EMData * projection_by_summation(int image_size, float apix, float res)
Transform * align_2d(PointArray *to, float max_dist)
Aligns one PointArray to another in 2 dimensions.
Definition: pointarray.cpp:281
void save_pdb_with_helix(const char *file, vector< float > hlxid)
Save the point array to pdb file, including helices information.
void save_to_pdb(const char *file)
Definition: pointarray.cpp:441
double * get_points_array()
Definition: pointarray.cpp:182
Transform calc_transform(PointArray *p)
Calculate the transform to another identical pointarray.
void sim_add_point_one()
void sim_add_point_double()
Add more points during the simulation.
EMData * distmx(int sortrows=0)
Calculates a (symmetrized) distance matrix for the current PointArray.
Definition: pointarray.cpp:192
void set_from_density_map(EMData *map, int num, float thresh, float apix, Density2PointsArrayAlgorithm mode=PEAKS_DIV)
Definition: pointarray.cpp:663
vector< double > fit_helix(EMData *pmap, int minlength, float mindensity, vector< int > edge, int twodir, size_t minl)
Fit helix from peptide chains.
double get_value_at(int i)
vector< float > get_points()
Returns all x,y,z triplets packed into a vector<float>
Definition: pointarray.cpp:594
void sim_minstep_seq(double meanshift)
Takes a step to minimize the potential.
PointArray * copy()
Definition: pointarray.cpp:149
void replace_by_summation(EMData *image, int i, Vec3f vec, float amp, float apix, float res)
void sim_updategeom()
Updates the dist, ang, dihed parameters.
Definition: pointarray.cpp:945
bool read_ca_from_pdb(const char *file)
Read only C-alpha atoms from a pdb file.
vector< int > match_points(PointArray *to, float max_miss=-1.0)
Will try to establish a 1-1 correspondence between points in two different PointArray objects (this a...
Definition: pointarray.cpp:217
EMData * projection_by_nfft(int image_size, float apix, float res=0)
void sim_minstep(double maxshift)
Takes a step to minimize the potential.
EMData * pdb2mrc_by_summation(int map_size, float apix, float res, int addpdbbfactor)
double * adist
Definition: pointarray.h:227
EMData * gradx
Definition: pointarray.h:247
double * points
Definition: pointarray.h:221
vector< double > construct_helix(int start, int end, float phs, float &score, int &dir)
Construct an ideal helix between the start and end points given phase.
FloatPoint get_center()
Definition: pointarray.cpp:453
vector< float > do_pca(int start, int end)
Do principal component analysis to (a subset of) the point array, used in helix fitting in pathwalker...
void opt_from_proj(const vector< EMData * > &proj, float pixres)
Optimizes a pointarray based on a set of projection images (EMData objects) This is effectively a 3D ...
PointArray & operator=(PointArray &pa)
Definition: pointarray.cpp:159
void merge_to(PointArray &pa, float thr)
Merge to another point array.
Vec3f get_vector_at(int i)
float calc_helicity(vector< double > pts)
Calculate the helicity of some points.
double * bfactor
Definition: pointarray.h:223
double * adihed
Definition: pointarray.h:229
void right_transform(const Transform &transform)
Does Transform*v as opposed to v*Transform (as in the transform function)
Definition: pointarray.cpp:617
EMData * pdb2mrc_by_nfft(int map_size, float apix, float res)
double sim_potentialdxyz(int i, double dx, double dy, double dz)
Compute a potential value for a perturbed point, including +-2 nearest neighbors which will also be i...
void set_from(vector< float >)
Definition: pointarray.cpp:658
Region get_bounding_box()
Definition: pointarray.cpp:482
void mask(double rmax, double rmin=0.0)
Definition: pointarray.cpp:507
void delete_point(int id)
Delete one point in the array.
double dist0
Used for simplistic loop dynamics simulation Assumes all points are connected sequentially in a close...
Definition: pointarray.h:244
double sim_potentiald(int ind)
Compute a single point potential value.
void sim_printstat()
prints some statistics to the screen
void set_vector_at(int i, Vec3f vec, double value)
void set_number_points(size_t nn)
Definition: pointarray.cpp:173
void reverse_chain()
Reverse the pointarray chain.
double calc_total_length()
Calculate total length.
EMData * grady
Definition: pointarray.h:247
void sort_by_axis(int axis=1)
bool read_from_pdb(const char *file, const vector< int > &lines=vector< int >())
Definition: pointarray.cpp:329
void set_points_array(double *p)
Definition: pointarray.cpp:187
void transform(const Transform &transform)
Definition: pointarray.cpp:605
void sim_set_pot_parms(double pdist0, double pdistc, double pangc, double pdihed0, double pdihedc, double pmapc, EMData *pmap, double pmindistc, double pdistpenc)
Sets the parameters for the energy function.
void remove_helix_from_map(EMData *m, vector< float > hlxid)
Remove the corresponding density of the helix point from a density map.
double sim_potential()
Computes overall potential for the configuration.
Definition: pointarray.cpp:988
void sim_rescale()
rescale the entire set so the mean bond length matches dist0
vector< float > do_filter(vector< float > pts, float *ft, int num)
Filter the point array to smooth the line, used in helix fitting in pathwalker.
double sim_pointpotential(double dist, double ang, double dihed)
Computes a potential value for a single point from a set of angles/distances using current energy set...
Definition: pointarray.h:142
Vec3f sim_descent(int i)
returns a vector pointing downhill for a single point
size_t get_number_points() const
Definition: pointarray.cpp:168
vector< Vec3f > oldshifts
Definition: pointarray.h:248
void mask_asymmetric_unit(const string &sym)
Definition: pointarray.cpp:534
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
Definition: geometry.h:497
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
E2Exception class.
Definition: aligner.h:40