28 UHBD (
char *,
char *,
bool,
float);
29 UHBD (
char *,
float,
bool,
float);
94 template <
typename type>
97 template <
typename type>
100 template <
typename type>
106template <
typename T1>
template <
typename type>
110 grd =
new type ** [
dim.i];
111 for (
int x=0; x<
dim.i; x++){
112 grd[x] =
new type * [
dim.j];
113 for (
int y=0; y<
dim.j; y++)
114 grd[x][y] =
new type [
dim.k];
123template <
typename T1>
template <
typename type>
126 for (
int x=0; x<
dim.i; x++){
127 for (
int y=0; y<
dim.j; y++)
137template <
typename T1>
template <
typename type>
140 for (
int x=0; x<
dim.i; x++){
141 for (
int y=0; y<
dim.j; y++){
142 for (
int z=0; z<
dim.k; z++){
159template <
typename T1>
163 std::cout <<
"No UHBD file! \n !!! Assuming an exclusion grid object !!!" << std::endl;
166 std::cout <<
"Loading the PDB file ..." << std::endl;
167 std::ifstream pdbfile (pdbfilename);
172 Title =
new char [72];
173 strcat(
Title,
"Exclusion grid created by UHBD2dtgrid");
213template <
typename T1>
219 Title =
new char [72];
220 std::cout <<
"Opening the UHBD file..." << std::endl;
224 file.open(Input, std::ifstream::in | std::ifstream::binary);
226 file.open(Input, std::ifstream::in);
228 Grid = Allocate <T1> ();
229 Initialize <T1> (
Grid);
235 std::cout <<
"Loading the PDB file ..." << std::endl;
236 std::ifstream pdbfile (pdbfilename);
250template <
typename T1>
256 Title =
new char [72];
257 std::cout <<
"Opening the UHBD file..." << std::endl;
260 file.open(Input, std::ifstream::in | std::ifstream::binary);
262 file.open(Input, std::ifstream::in);
264 Grid = Allocate <T1> ();
265 Initialize <T1> (
Grid);
272template <
typename T1>
276 Deallocate <bool> (
Skin);
280 Deallocate <T1> (
Grid);
292template <
typename T1>
294 std::string slice_n, out_name;
295 slice_n =
static_cast<std::ostringstream*
>( &(std::ostringstream() << k) )->str();
296 out_name =
"exclusion" + slice_n +
"slice.txt";
298 std::ofstream excl_slice;
299 excl_slice.open (out_name.c_str(), std::ios::out);
301 for (
int i=0; i<
dim.i; i++){
302 for (
int j=0; j<
dim.j; j++){
303 if (
Skin[i][j][k] ==
true )
326template <
typename T1>
328 int klim, nb_true_excl;
331 int c3d_1, c3d_2, c3d_3;
333 int ix, jx, kk, jj, ii;
334 double rexmax, hdexcl, rexcl, rexcl2;
335 double xv1, xv2, xv3, xa1, xa2, xa3;
336 double zk, ztemp, yj, ytemp, xi, xtemp, dist2;
344 rexmax = (double)
structure->max_vdw + probep;
345 hdexcl = hexclusion / 2.0;
346 klim = (int) ((rexmax + hexclusion * 1.5) / hexclusion);
348#pragma omp parallel shared(hdexcl, hexclusion, klim, nb_true_excl, probep, IEV) \
349 private(i, j, k, c3d_1, c3d_2, c3d_3, ix, jx, kk, jj, ii, xv1, xv2, xv3, xa1, xa2, xa3, \
350 rexcl, rexcl2, zk, ztemp, yj, ytemp, xi, xtemp, dist2, dummy_lim)
352 #pragma omp for schedule(dynamic) nowait reduction(+:nb_true_excl)
353 for (ix = 0; ix <
structure->Number_of_Residues; ix++){
354 for (jx = 0; jx <
structure->Residues[ix].Number_of_Atoms; jx++){
363 rexcl = (double)
structure->Residues[ix].Atoms[jx].radii + probep;
364 rexcl2 = rexcl * rexcl;
366 c3d_1 = (int) ((xa1 - oex) / hexclusion);
367 c3d_2 = (int) ((xa2 - oey) / hexclusion);
368 c3d_3 = (int) ((xa3 - oez) / hexclusion);
370 for (kk = -klim; kk <= klim; kk++){
373 if (k <= 0 or k >
dim.k){
378 zk = (double) k * hexclusion + oez;
384 for (jj = -klim; jj <= klim; jj++){
387 if (j <= 0 or j >
dim.j){
392 yj = (double) j * hexclusion + oey;
398 for (ii = -klim; ii <= klim; ii++){
401 if (i <= 0 or i >
dim.i){
406 if (IEV[i-1][j-1][k-1] ==
true)
409 xi = (double) i * hexclusion + oex;
411 dist2 = xtemp * xtemp + ytemp * ytemp + ztemp * ztemp;
417 IEV[i-1][j-1][k-1] =
true;
429 if (
structure->Dummy.Number_of_Atoms > 0){
430 for (jx = 0; jx <
structure->Dummy.Number_of_Atoms; jx++){
439 rexcl = (double)
structure->Dummy.Atoms[jx].radii + probep;
440 rexcl2 = rexcl * rexcl;
442 c3d_1 = (int) ((xa1 - oex) / hexclusion);
443 c3d_2 = (int) ((xa2 - oey) / hexclusion);
444 c3d_3 = (int) ((xa3 - oez) / hexclusion);
446 dummy_lim = (int) ((rexcl + hexclusion * 1.5) / hexclusion);
448 #pragma omp for schedule(dynamic) nowait
449 for (kk = -dummy_lim; kk <= dummy_lim; kk++){
452 if (k <= 0 or k >
dim.k)
455 zk = (double) k * hexclusion + oez;
461 for (jj = -dummy_lim; jj <= dummy_lim; jj++){
464 if (j <= 0 or j >
dim.j)
467 yj = (double) j * hexclusion + oey;
473 for (ii = -dummy_lim; ii <= dummy_lim; ii++){
476 if (i <= 0 or i >
dim.i)
479 if (IEV[i-1][j-1][k-1] ==
true)
482 xi = (double) i * hexclusion + oex;
484 dist2 = xtemp * xtemp + ytemp * ytemp + ztemp * ztemp;
490 IEV[i-1][j-1][k-1] =
true;
509template <
typename T1>
513 int xmin, xmax, ymin, ymax, zmin, zmax;
514 int klim, nb_true_excl;
515 int nxex, nyex, nzex;
516 int c3d_1, c3d_2, c3d_3;
518 double rexmax, hdexcl, rexcl, rexcl2;
519 double xv1, xv2, xv3, xa1, xa2, xa3;
520 double oex, oey, oez;
521 double zk, ztemp, yj, ytemp, xi, xtemp, dist2;
522 double hexclusion, probep;
534 rexmax = (double)
structure->max_vdw + probep;
535 hdexcl = hexclusion / 2.0;
536 klim = (int) ((rexmax + hexclusion * 1.5) / hexclusion);
541 std::cout <<
"Generate exclusion grid with hexclusion: " << hexclusion <<
" probep: " << probep << std::endl;
546 for (
int ix = 0; ix <
structure->Number_of_Residues; ix++){
548 for (
int jx = 0; jx <
structure->Residues[ix].Number_of_Atoms; jx++){
552 c3d_1 = (int) (xv1 / hexclusion);
553 c3d_2 = (int) (xv2 / hexclusion);
554 c3d_3 = (int) (xv3 / hexclusion);
555 if (c3d_1 < xmin) xmin = c3d_1;
556 if (c3d_1 > xmax) xmax = c3d_1;
557 if (c3d_2 < ymin) ymin = c3d_2;
558 if (c3d_2 > ymax) ymax = c3d_2;
559 if (c3d_3 < zmin) zmin = c3d_3;
560 if (c3d_3 > zmax) zmax = c3d_3;
571 std::cout <<
"Min & max grid points x: " << xmin <<
" " << xmax << std::endl;
572 std::cout <<
"Min & max grid points y: " << ymin <<
" " << ymax << std::endl;
573 std::cout <<
"Min & max grid points z: " << zmin <<
" " << zmax << std::endl;
575 nxex = xmax - xmin + 2;
576 nyex = ymax - ymin + 2;
577 nzex = zmax - zmin + 2;
579 oex = hexclusion * ((double) xmin - 0.5) - hexclusion;
580 oey = hexclusion * ((double) ymin - 0.5) - hexclusion;
581 oez = hexclusion * ((double) zmin - 0.5) - hexclusion;
588 o.x = (float)((
double)
structure->CoG.X + oex);
589 o.y = (float)((
double)
structure->CoG.Y + oey);
590 o.z = (float)((
double)
structure->CoG.Z + oez);
592 std::cout <<
"Exclusion grid information ..." << std::endl;
593 std::cout <<
"Grid dimensions : " <<
dim.i <<
" " <<
dim.j <<
" " <<
dim.k << std::endl;
594 std::cout <<
"Grid spacing : " <<
spacing << std::endl;
595 std::cout <<
"Grid origin : " <<
o.x <<
" " <<
o.y <<
" " <<
o.z << std::endl;
596 std::cout << std::endl;
599 Skin = Allocate <bool> ();
605 std::cout <<
"The number of points in exclusion grid assigned value 1: " << nb_true_excl << std::endl;
606 std::cout <<
"The number of atoms in the PDB file: " <<
structure->Number_of_Atoms << std::endl;
623template <
typename T1>
627 output_file = fopen(
"test_excluded_volume.bin.grd",
"wb");
630 int binary_uhbd_type = 4;
631 int binary_file_vmd_flag = 160;
632 std::cout <<
"Writing the UHBD (binary) to the output file ..." << std::endl;
633 fwrite(&binary_file_vmd_flag,
sizeof(
int),1,output_file);
634 fwrite(
Title,
sizeof(
char), 72, output_file);
635 fwrite(&
scale,
sizeof(
float),1,output_file);
636 fwrite(&
dummy1,
sizeof(
float),1,output_file);
637 fwrite(&binary_uhbd_type,
sizeof(
int),1,output_file);
638 fwrite(&
idummy1,
sizeof(
int),1,output_file);
639 fwrite(&
idummy2,
sizeof(
int),1,output_file);
640 fwrite(&
one,
sizeof(
int),1,output_file);
641 fwrite(&
idummy3,
sizeof(
int),1,output_file);
642 fwrite(&
dim.i,
sizeof(
int),1,output_file);
643 fwrite(&
dim.j,
sizeof(
int),1,output_file);
644 fwrite(&
dim.k,
sizeof(
int),1,output_file);
645 fwrite(&
spacing,
sizeof(
float),1,output_file);
646 fwrite(&
o.x,
sizeof(
float),1,output_file);
647 fwrite(&
o.y,
sizeof(
float),1,output_file);
648 fwrite(&
o.z,
sizeof(
float),1,output_file);
649 fwrite(&
dummy2,
sizeof(
float),1,output_file);
650 fwrite(&
dummy3,
sizeof(
float),1,output_file);
651 fwrite(&
dummy4,
sizeof(
float),1,output_file);
652 fwrite(&
dummy5,
sizeof(
float),1,output_file);
653 fwrite(&
dummy6,
sizeof(
float),1,output_file);
654 fwrite(&
dummy7,
sizeof(
float),1,output_file);
655 fwrite(&
idummy4,
sizeof(
int),1,output_file);
656 fwrite(&
idummy5,
sizeof(
int),1,output_file);
662 i_value =
sizeof(char) * 72 +
sizeof(
int) * 11 +
sizeof(float) * 11;
663 fwrite(&i_value,
sizeof(
int),1,output_file);
665 for (
int k=0; k <
dim.k ; k++){
666 i_value =
sizeof(int) * 3;
667 fwrite(&i_value,
sizeof(
int),1,output_file);
669 fwrite(&i_value,
sizeof(
int),1,output_file);
670 fwrite(&(
dim.i),
sizeof(
int),1,output_file);
671 fwrite(&(
dim.j),
sizeof(
int),1,output_file);
672 i_value =
sizeof(int) * 3;
673 fwrite(&i_value,
sizeof(
int),1,output_file);
674 i_value =
sizeof(float) *
dim.i *
dim.j;
675 fwrite(&i_value,
sizeof(
int),1,output_file);
676 for (
int j=0; j <
dim.j ; j++){
677 for (
int i=0; i <
dim.i ; i++){
678 f_value = (float)
Skin[i][j][k];
679 fwrite(&f_value,
sizeof(
float),1,output_file);
682 i_value =
sizeof(float) *
dim.i *
dim.j;
683 fwrite(&i_value,
sizeof(
int),1,output_file);
692template <
typename T1>
695 std::ifstream file_bt;
696 file_bt.open(Input, std::ifstream::in | std::ifstream::binary);
699 file_bt.read((
char *) &flag,
sizeof(
int));
702 char * buffer =
new char [120];
703 file_bt.read(buffer, 120);
706 binary_test = (
char*) memchr (buffer,
'\n', 120);
712 if (binary_test == NULL) {
713 binary_test = (
char*) memchr (buffer,
'\0', 120);
714 if (binary_test == NULL) {
736template <
typename T1>
771 file.read((
char *) &
scale,
sizeof(
float));
776 file.read((
char *) &
one,
sizeof(
int));
778 file.read((
char *) &
dim.i,
sizeof(
int));
779 file.read((
char *) &
dim.j,
sizeof(
int));
780 file.read((
char *) &
dim.k,
sizeof(
int));
782 file.read((
char *) &
o.x,
sizeof(
float));
783 file.read((
char *) &
o.y,
sizeof(
float));
784 file.read((
char *) &
o.z,
sizeof(
float));
798 std::cout <<
"ERROR: Cannot open the UHBD file!" << std::endl;
804 std::string title_str, line;
805 std::string scale_str, dum1_str, grdflag_str, idum1_str, idum2_str, one_str, idum3_str;
806 std::string i_str, j_str, k_str;
807 std::string spacing_str, ox_str, oy_str, oz_str;
808 std::string dum2_str, dum3_str, dum4_str, dum5_str;
809 std::string dum6_str, dum7_str, idum4_str, idum5_str;
813 title_str = line.substr(0,72);
815 scale_str = line.substr(0,12);
816 dum1_str = line.substr(12,12);
817 grdflag_str = line.substr(24,7);
818 idum1_str = line.substr(31,7);
819 idum2_str = line.substr(38,7);
820 one_str = line.substr(45,7);
821 idum3_str = line.substr(52,7);
823 i_str = line.substr(0,7);
824 j_str = line.substr(7,7);
825 k_str = line.substr(14,7);
826 spacing_str = line.substr(21,12);
827 ox_str = line.substr(33,12);
828 oy_str = line.substr(45,12);
829 oz_str = line.substr(57,12);
831 dum2_str = line.substr(0,12);
832 dum3_str = line.substr(12,12);
833 dum4_str = line.substr(24,12);
834 dum5_str = line.substr(36,12);
836 dum6_str = line.substr(0,12);
837 dum7_str = line.substr(12,12);
838 idum4_str = line.substr(24,7);
839 idum5_str = line.substr(31,7);
842 std::strncpy (
Title, title_str.c_str(), 72);
844 std::stringstream (scale_str) >>
scale;
845 std::stringstream (dum1_str) >>
dummy1;
846 std::stringstream (grdflag_str) >>
grdflag;
847 std::stringstream (idum1_str) >>
idummy1;
848 std::stringstream (idum2_str) >>
idummy2;
849 std::stringstream (one_str) >>
one;
850 std::stringstream (idum3_str) >>
idummy3;
851 std::stringstream (i_str) >>
dim.i;
852 std::stringstream (j_str) >>
dim.j;
853 std::stringstream (k_str) >>
dim.k;
854 std::stringstream (spacing_str) >>
spacing;
855 std::stringstream (ox_str) >>
o.x;
856 std::stringstream (oy_str) >>
o.y;
857 std::stringstream (oz_str) >>
o.z;
858 std::stringstream (dum2_str) >>
dummy2;
859 std::stringstream (dum3_str) >>
dummy3;
860 std::stringstream (dum4_str) >>
dummy4;
861 std::stringstream (dum5_str) >>
dummy5;
862 std::stringstream (dum6_str) >>
dummy6;
863 std::stringstream (dum7_str) >>
dummy7;
864 std::stringstream (idum4_str) >>
idummy4;
865 std::stringstream (idum5_str) >>
idummy5;
868 std::cout <<
"ERROR: Cannot open the UHBD file" << std::endl;
878template <
typename T1>
881 std::cout <<
"Reading the UHBD grid ..." << std::endl;
882 std::cout <<
"Grid dimensions : " <<
dim.i <<
" " <<
dim.j <<
" " <<
dim.k << std::endl;
883 std::cout <<
"Grid spacing : " <<
spacing << std::endl;
884 std::cout <<
"Grid origin : " <<
o.x <<
" " <<
o.y <<
" " <<
o.z << std::endl;
885 std::cout << std::endl;
890 int kx, im, jm, ufo1, ufo2, ufo3, ufo4 ;
892 for (
int k = 0; k<
dim.k; k++){
894 file.read((
char *) &ufo1,
sizeof(
float));
895 file.read((
char *) &ufo2,
sizeof(
float));
896 file.read((
char *) &kx,
sizeof(
float));
897 file.read((
char *) &im,
sizeof(
float));
898 file.read((
char *) &jm,
sizeof(
float));
899 file.read((
char *) &ufo3,
sizeof(
float));
900 file.read((
char *) &ufo4,
sizeof(
float));
903 for (
int j = 0; j<
dim.j; j++){
904 for (
int i = 0; i<
dim.i; i++){
905 file.read((
char *) &data_buffer,
sizeof(
float));
907 Grid[i][j][k] = data_buffer;
915 std::cout <<
"ERROR: Cannot open the UHBD file" << std::endl;
926 for (
int k = 0; k<
dim.k; k++){
927 for (
int j = 0; j<
dim.j; j++){
928 for (
int i = 0; i<
dim.i; i++){
942 std::cout <<
"ERROR: Cannot open the UHBD file" << std::endl;
970template <
typename T1>
973 std::cout <<
"Generating the molecule skin points ..." << std::endl;
976 double oex, oey, oez;
977 int ih, jh, kh, KK, JJ, II;
1001 Skin = Allocate <bool> ();
1003 for (
int i = 0; i <
dim.i; i ++){
1004 for (
int j = 0; j <
dim.j; j++){
1005 for (
int k = 0; k <
dim.k; k++){
1006 if (IEX[i][j][k]==
true){
1007 Skin[i][j][k]=
false;
1010 if (ISK[i][j][k]==
true)
1013 Skin[i][j][k]=
false;
1027 if (iterate_inside_skin != 0){
1028 for (
int i_skin = 0; i_skin < iterate_inside_skin; i_skin++){
1029 for (
int i = 0; i <
dim.i; i ++){
1030 for (
int j = 0; j <
dim.j; j++){
1031 for (
int k = 0; k <
dim.k; k++){
1032 if (
Skin[i][j][k] ==
true){
1033 if ((i+1 <
dim.i) && (IEX[i+1][j][k] ==
true))
1035 if ((i-1 >= 0) && (IEX[i-1][j][k] ==
true))
1037 if ((j+1 <
dim.j) && (IEX[i][j+1][k] ==
true))
1039 if ((j-1 >= 0) && (IEX[i][j-1][k] ==
true))
1041 if ((k+1 <
dim.k) && (IEX[i][j][k+1] ==
true))
1043 if ((k-1 >= 0) && (IEX[i][j][k-1] ==
true))
1051 for (
int i = 0; i <
dim.i; i ++){
1052 for (
int j = 0; j <
dim.j; j++){
1053 for (
int k = 0; k <
dim.k; k++){
1054 if (IIN[i][j][k] ==
true){
1055 Skin[i][j][k] =
true;
1056 IEX[i][j][k] =
false;
Group functions to read-write PDB files and describe the molecular structures inside (Header).
Definition PDBstructure.hpp:78
float spacing
Definition UHBDgrd.hpp:44
float dummy6
Definition UHBDgrd.hpp:53
void Test_Format_Grid(char *)
Determine the type of grid: binary or ascii?
Definition UHBDgrd.hpp:693
int idummy5
Definition UHBDgrd.hpp:59
void print_slice_grid(int)
Print a 2D slice of an excluded volume grid.
Definition UHBDgrd.hpp:293
float dummy3
Definition UHBDgrd.hpp:50
void Generate_Skin(float, int)
Calculate the molecule skin (molecular interaction field).
Definition UHBDgrd.hpp:971
char * Title
grid spacing/resolution
Definition UHBDgrd.hpp:45
type *** Allocate()
create a 3d array and allocate memory for it.
Definition UHBDgrd.hpp:107
float probes
Boolean for Skin! expanded for other types, though.
Definition UHBDgrd.hpp:80
int exclusion_flag
Binary : 0, ASCII : 1.
Definition UHBDgrd.hpp:85
UHBD(char *, char *, bool, float)
UHBD constructor - 2.
Definition UHBDgrd.hpp:214
int idummy4
Definition UHBDgrd.hpp:58
int excluded_volume(bool ***, double, double, double, double)
Calculate the excluded volume.
Definition UHBDgrd.hpp:327
float dummy5
Definition UHBDgrd.hpp:52
struct UHBD::dimensions dim
void Deallocate(type ***)
deallocate the memory for a 3D array
Definition UHBDgrd.hpp:124
float dummy2
Definition UHBDgrd.hpp:49
int grdflag
scaling for every value
Definition UHBDgrd.hpp:42
bool *** Skin
Store the grid data in a 3d array.
Definition UHBDgrd.hpp:76
~UHBD()
UHBD destructor.
Definition UHBDgrd.hpp:273
void make_exclusion_grid()
construct the excluded volume grid
Definition UHBDgrd.hpp:510
void Read_Header(char *)
Read the header of an input UHBD file.
Definition UHBDgrd.hpp:737
float scale
Definition UHBDgrd.hpp:41
float dummy1
Text header kept in the UHBD file.
Definition UHBDgrd.hpp:48
float dummy4
Definition UHBDgrd.hpp:51
int iform
structure object for the input molecule
Definition UHBDgrd.hpp:84
void write_uhbd_grid()
Exclusion : 1, Non-exclusion : 0.
Definition UHBDgrd.hpp:624
void Initialize(type ***)
initialize values of a given 3D array to zero
Definition UHBDgrd.hpp:138
int idummy1
Definition UHBDgrd.hpp:55
int one
flag for the type of grid: UHBD, DT-Grid, etc.
Definition UHBDgrd.hpp:43
std::ifstream file
Definition UHBDgrd.hpp:40
float dummy7
Definition UHBDgrd.hpp:54
T1 *** Grid
grid origin coordinates
Definition UHBDgrd.hpp:75
int idummy3
Definition UHBDgrd.hpp:57
void Read_Data()
Read the body of the input UHBD file.
Definition UHBDgrd.hpp:879
PDB * structure
probe size
Definition UHBDgrd.hpp:83
int idummy2
Definition UHBDgrd.hpp:56
subroutine make_exclusion_grid(sgrid, tmp_atom_pos, tmp_nat, center, atom_vdw, max_vdw, probep, hexclusion)
Use intermediate module mod_exclusion_grid.
Definition make_exclusion_grid.f90:55
Definition UHBDgrd.hpp:63
int k
number of grid points in y direction
Definition UHBDgrd.hpp:66
int i
Definition UHBDgrd.hpp:64
int j
number of grid points in x direction
Definition UHBDgrd.hpp:65
dimensions of the grid (number of grid points)
Definition UHBDgrd.hpp:69
float x
Definition UHBDgrd.hpp:70
float z
origin y coordinate
Definition UHBDgrd.hpp:72
float y
origin x coordinate
Definition UHBDgrd.hpp:71