26 int io,
int id,
int ktot)
29 for (k = 0; k < ktot; ++
k) {
31 pdb_duplicate[
id +
k].
x = pdb_original[
io].
x;
32 pdb_duplicate[
id +
k].
y = pdb_original[
io].
y;
33 pdb_duplicate[
id +
k].
z = pdb_original[
io].
z;
34 for (j = 0; j < 4; ++
j) pdb_duplicate[
id + k].segid[j] = pdb_original[io].segid[j];
35 pdb_duplicate[
id +
k].
serial =
id + k + 1;
36 for (j = 0; j < 7; ++
j) pdb_duplicate[
id + k].recd[j] = pdb_original[io].recd[j];
37 for (j = 0; j < 3; ++
j) pdb_duplicate[
id + k].
type[j] = pdb_original[io].
type[j];
38 for (j = 0; j < 3; ++
j) pdb_duplicate[
id + k].loc[j] = pdb_original[io].loc[j];
39 for (j = 0; j < 2; ++
j) pdb_duplicate[
id + k].alt[j] = pdb_original[io].alt[j];
40 for (j = 0; j < 5; ++
j) pdb_duplicate[
id + k].res[j] = pdb_original[io].res[j];
41 for (j = 0; j < 2; ++
j) pdb_duplicate[
id + k].chain[j] = pdb_original[io].chain[j];
42 pdb_duplicate[
id +
k].
seq = pdb_original[
io].
seq;
43 for (j = 0; j < 2; ++
j) pdb_duplicate[
id + k].icode[j] = pdb_original[io].icode[j];
47 for (j = 0; j < 3; ++
j) pdb_duplicate[
id + k].element[j] = pdb_original[io].element[j];
48 for (j = 0; j < 3; ++
j) pdb_duplicate[
id + k].charge[j] = pdb_original[io].charge[j];
57 char axis,
double angle)
61 double sint = sin(angle);
62 double cost = cos(angle);
66 for (
id = 0;
id < num_atoms; ++id) {
67 y = pdb_original[id].
y;
68 z = pdb_original[id].
z;
69 pdb_rotate[id].
x = pdb_original[id].
x;
70 pdb_rotate[id].
y = (cost * y + sint *
z);
71 pdb_rotate[id].
z = (cost * z - sint *
y);
75 for (
id = 0;
id < num_atoms; ++id) {
76 x = pdb_original[id].
x;
77 z = pdb_original[id].
z;
78 pdb_rotate[id].
y = pdb_original[id].
y;
79 pdb_rotate[id].
x = (cost * x + sint *
z);
80 pdb_rotate[id].
z = (cost * z - sint *
x);
84 for (
id = 0;
id < num_atoms; ++id) {
85 x = pdb_original[id].
x;
86 y = pdb_original[id].
y;
87 pdb_rotate[id].
z = pdb_original[id].
z;
88 pdb_rotate[id].
x = (cost * x + sint *
y);
89 pdb_rotate[id].
y = (cost * y - sint *
x);
99 unsigned num_atoms,
double psi,
double theta,
double phi)
102 double rot_matrix[3][3], currx, curry, currz;
106 for (
id = 0;
id < num_atoms; ++id) {
107 currx = pdb_original[id].
x;
108 curry = pdb_original[id].
y;
109 currz = pdb_original[id].
z;
110 pdb_rotate[id].
x = currx * rot_matrix[0][0] +
111 curry * rot_matrix[0][1] +
112 currz * rot_matrix[0][2];
113 pdb_rotate[id].
y = currx * rot_matrix[1][0] +
114 curry * rot_matrix[1][1] +
115 currz * rot_matrix[1][2];
116 pdb_rotate[id].
z = currx * rot_matrix[2][0] +
117 curry * rot_matrix[2][1] +
118 currz * rot_matrix[2][2];
126 unsigned num_atoms,
double x0,
double y0,
double z0)
130 for (
id = 0;
id < num_atoms; ++id) {
131 pdb_move[id].
x = pdb_original[id].
x +
x0;
132 pdb_move[id].
y = pdb_original[id].
y +
y0;
133 pdb_move[id].
z = pdb_original[id].
z +
z0;
141 double *cx,
double *cy,
double *cz)
144 const char *program =
"lib_pwk";
148 for (
id = 0;
id < num_atoms; ++id) {
154 *cx /= (num_atoms * 1.0);
155 *cy /= (num_atoms * 1.0);
156 *cz /= (num_atoms * 1.0);
171 for (
id = 0;
id < num_atoms; ++id)
172 mtot += pdb0[
id].weight;
180 double *cx,
double *cy,
double *cz)
184 const char *program =
"lib_pwk";
190 for (
id = 0;
id < num_atoms; ++id) {
192 *cx += pdb0[id].
x * pdb0[id].
weight;
193 *cy += pdb0[id].
y * pdb0[id].
weight;
194 *cz += pdb0[id].
z * pdb0[id].
weight;
210 double cx,
double cy,
double cz)
213 double maxradius, currradius;
214 const char *program =
"lib_pwk";
215 const char *shape =
"sphere";
218 for (
id = 0;
id < num_atoms; ++id) {
219 currradius = ((pdb0[id].
x - cx) * (pdb0[
id].
x - cx) +
220 (pdb0[id].
y - cy) * (pdb0[
id].
y - cy) +
221 (pdb0[id].
z - cz) * (pdb0[
id].
z - cz));
222 if (currradius > maxradius) maxradius = currradius;
225 if (maxradius >= 0.0) {
226 maxradius =
sqrt(maxradius);
238 double *minx,
double *miny,
double *minz,
239 double *maxx,
double *maxy,
double *maxz)
242 const char *program =
"lib_pwk";
243 const char *shape =
"box";
251 for (
id = 0;
id < num_atoms; ++id) {
252 if (*minx > pdb0[
id].
x) *minx = pdb0[id].
x;
253 if (*maxx < pdb0[
id].x) *maxx = pdb0[id].
x;
254 if (*miny > pdb0[
id].
y) *miny = pdb0[id].
y;
255 if (*maxy < pdb0[
id].y) *maxy = pdb0[id].
y;
256 if (*minz > pdb0[
id].
z) *minz = pdb0[id].
z;
257 if (*maxz < pdb0[
id].z) *maxz = pdb0[id].
z;
259 if (*minx < 1e20 && *miny < 1e20 && *minz < 1e20 && *maxx > -1e20 && *maxy > -1e20 && *maxz > -1e20)
return;
269 void project_mass(
double **outmap,
unsigned long nvox,
double widthx,
double widthy,
double widthz,
unsigned extx,
unsigned exty,
unsigned extz,
270 PDB *inpdb,
unsigned num_atoms,
double shift[3],
unsigned ignored[3])
275 double ab, ab1, a1b, a1b1;
276 int marglx, margly, marglz, margux, marguy, marguz;
284 if (marglx == 0) marglx = 1;
285 if (margly == 0) margly = 1;
286 if (marglz == 0) marglz = 1;
289 margux = extx - marglx;
290 marguy = exty - margly;
291 marguz = extz - marglz;
294 for (i = 0; i < num_atoms; ++
i) {
298 gx = extx / 2.0 + (inpdb[
i].
x + shift[0]) / widthx;
299 gy = exty / 2.0 + (inpdb[
i].
y + shift[1]) / widthy;
300 gz = extz / 2.0 + (inpdb[
i].
z + shift[2]) / widthz;
309 if (x1 >= marglx && x0 < margux && y1 >= margly && y0 < marguy && z1 >= marglz && z0 < marguz) {
318 a1b1 = (1 -
a) * (1 - b);
320 *(*outmap +
gidz_general(z0, y0, x0, exty, extx)) += ab * c * inpdb[i].weight;
321 *(*outmap +
gidz_general(z1, y0, x0, exty, extx)) += ab * a * inpdb[i].weight;
322 *(*outmap +
gidz_general(z0, y1, x0, exty, extx)) += ab1 * c * inpdb[i].weight;
323 *(*outmap +
gidz_general(z1, y1, x0, exty, extx)) += ab1 * a * inpdb[i].weight;
324 *(*outmap +
gidz_general(z0, y0, x1, exty, extx)) += a1b * c * inpdb[i].weight;
325 *(*outmap +
gidz_general(z1, y0, x1, exty, extx)) += a1b * a * inpdb[i].weight;
326 *(*outmap +
gidz_general(z0, y1, x1, exty, extx)) += a1b1 * c * inpdb[i].weight;
327 *(*outmap +
gidz_general(z1, y1, x1, exty, extx)) += a1b1 * a * inpdb[i].weight;
339 unsigned extx,
unsigned exty,
unsigned extz,
340 PDB *inpdb,
unsigned num_atoms,
double shift[3],
341 double *kernel,
unsigned kernel_size,
double normfac,
unsigned ignored[3],
342 double *lowmap,
double *corr_hi_low)
347 double ab, ab1, a1b, a1b1;
348 double dval1, dval2, dval3, dval4, dval5, dval6, dval7, dval8;
349 int indx2, indy2, indz2, margin;
352 double *idx_low1, *idx_low2, *idx_low3, *idx_low4;
353 int marglx, margly, marglz, margux, marguy, marguz;
355 inv_normfac = 1.0 / normfac;
356 margin = (kernel_size - 1) / 2;
359 marglx = margin + ignored[0];
360 margly = margin + ignored[1];
361 marglz = margin + ignored[2];
364 if (marglx == margin) marglx += 1;
365 if (margly == margin) margly += 1;
366 if (marglz == margin) marglz += 1;
369 margux = extx - marglx;
370 marguy = exty - margly;
371 marguz = extz - marglz;
373 for (i = 0; i < num_atoms; ++
i) {
377 gx = extx / 2.0 + (inpdb[
i].
x + shift[0]) / widthx;
378 gy = exty / 2.0 + (inpdb[
i].
y + shift[1]) / widthy;
379 gz = extz / 2.0 + (inpdb[
i].
z + shift[2]) / widthz;
388 if (x1 >= marglx && x0 < margux && y1 >= margly && y0 < marguy && z1 >= marglz && z0 < marguz) {
397 a1b1 = (1 -
a) * (1 - b);
400 dval1 = inv_normfac * ab * c * inpdb[
i].
weight;
401 dval2 = inv_normfac * a1b * c * inpdb[
i].
weight;
402 dval3 = inv_normfac * ab1 * c * inpdb[
i].
weight;
403 dval4 = inv_normfac * a1b1 * c * inpdb[
i].
weight;
404 dval5 = inv_normfac * ab * a * inpdb[
i].
weight;
405 dval6 = inv_normfac * a1b * a * inpdb[
i].
weight;
406 dval7 = inv_normfac * ab1 * a * inpdb[
i].
weight;
407 dval8 = inv_normfac * a1b1 * a * inpdb[
i].
weight;
410 for (indz2 = -margin; indz2 <= margin; indz2++) {
411 for (indy2 = -margin; indy2 <= margin; indy2++) {
412 idx_low1 = lowmap + (exty * extx * (z0 + indz2) + extx * (y0 + indy2) +
x0);
413 idx_low2 = lowmap + (exty * extx * (z0 + indz2) + extx * (y1 + indy2) +
x0);
414 idx_low3 = lowmap + (exty * extx * (z1 + indz2) + extx * (y0 + indy2) +
x0);
415 idx_low4 = lowmap + (exty * extx * (z1 + indz2) + extx * (y1 + indy2) +
x0);
416 for (indx2 = -margin; indx2 <= margin; indx2++) {
417 *corr_hi_low += *(idx_kern) *
418 (dval1 * *(idx_low1 + indx2)
419 + dval2 * *(idx_low1 + indx2 + 1)
420 + dval3 * *(idx_low2 + indx2)
421 + dval4 * *(idx_low2 + indx2 + 1)
422 + dval5 * *(idx_low3 + indx2)
423 + dval6 * *(idx_low3 + indx2 + 1)
424 + dval7 * *(idx_low4 + indx2)
425 + dval8 * *(idx_low4 + indx2 + 1));
442 unsigned extx,
unsigned exty,
unsigned extz,
443 PDB *inpdb,
unsigned num_atoms,
double shift[3])
448 int outside_error = 0;
450 for (i = 0; i < num_atoms; ++
i) {
452 gx = extx / 2.0 + (inpdb[
i].
x + shift[0]) / widthx;
453 gy = exty / 2.0 + (inpdb[
i].
y + shift[1]) / widthy;
454 gz = extz / 2.0 + (inpdb[
i].
z + shift[2]) / widthz;
461 if (x0 < 0) ++outside_error;
462 if (y0 < 0) ++outside_error;
463 if (z0 < 0) ++outside_error;
464 if (x1 >= extx) ++outside_error;
465 if (y1 >= exty) ++outside_error;
466 if (z1 >= extz) ++outside_error;
468 if (outside_error >= (1 - fraction)*num_atoms)
return outside_error;
double calc_mass(PDB *pdb0, unsigned num_atoms)
void project_mass_convolve_kernel_corr(double widthx, double widthy, double widthz, unsigned extx, unsigned exty, unsigned extz, PDB *inpdb, unsigned num_atoms, double shift[3], double *kernel, unsigned kernel_size, double normfac, unsigned ignored[3], double *lowmap, double *corr_hi_low)
__host__ __device__ float2 floor(const float2 v)
void rot_euler(PDB *pdb_original, PDB *pdb_rotate, unsigned num_atoms, double psi, double theta, double phi)
double calc_center_mass(PDB *pdb0, unsigned num_atoms, double *cx, double *cy, double *cz)
void sqrt(Image< double > &op)
unsigned long gidz_general(int k, int j, int i, unsigned ey, unsigned ex)
void error_no_bounding(int error_number, const char *program, const char *shape)
void calc_box(PDB *pdb0, unsigned num_atoms, double *minx, double *miny, double *minz, double *maxx, double *maxy, double *maxz)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
double calc_sphere(PDB *pdb0, unsigned num_atoms, double cx, double cy, double cz)
void rot_axis(PDB *pdb_original, PDB *pdb_rotate, unsigned num_atoms, char axis, double angle)
void copy_atoms(PDB *pdb_original, PDB *pdb_duplicate, int io, int id, int ktot)
void error_divide_zero(int error_number, const char *program)
void get_rot_matrix(double dump[3][3], double psi, double theta, double phi)
void translate(PDB *pdb_original, PDB *pdb_move, unsigned num_atoms, double x0, double y0, double z0)
void calc_center(PDB *pdb0, unsigned num_atoms, double *cx, double *cy, double *cz)
void project_mass(double **outmap, unsigned long nvox, double widthx, double widthy, double widthz, unsigned extx, unsigned exty, unsigned extz, PDB *inpdb, unsigned num_atoms, double shift[3], unsigned ignored[3])
double psi(const double x)
int check_if_inside(double fraction, double widthx, double widthy, double widthz, unsigned extx, unsigned exty, unsigned extz, PDB *inpdb, unsigned num_atoms, double shift[3])
void zero_vect(double *vect, unsigned long len)