main.cpp 3.95 KB
Newer Older
lvs's avatar
lvs committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//#include <stdio.h>
//#include <stdlib.h>
#include <time.h>

#include "processgrid.h"
//include "processresult.h"
#include "processligand.h"
#include "getparameters.h"
#include "performdocking.h"


// ------------------------
// Correct time measurement
// Moved to performdocking.cpp to skip measuring build time
#include <sys/time.h>
// ------------------------

int main(int argc, char* argv[])
{

	//=======================================================================
	// Docking Algorithm
	//=======================================================================

	Gridinfo mygrid;
	Liganddata myligand_init;
	Dockpars mypars;

	clock_t clock_start_program, clock_stop_program;


	clock_start_program = clock();

	// ------------------------
	// Correct time measurement
	// Moved to performdocking.cpp to skip measuring build time
	double num_sec, num_usec, elapsed_sec;
	timeval time_start,time_end;
	gettimeofday(&time_start,NULL);
	// ------------------------

	//------------------------------------------------------------
	// Capturing names of grid parameter file and ligand pdbqt file
	//------------------------------------------------------------

	// Filling the filename and coeffs fields of mypars according to command line arguments
	if (get_filenames_and_ADcoeffs(&argc, argv, &mypars) != 0)
		return 1;

	//------------------------------------------------------------
	// Processing receptor and ligand files
	//------------------------------------------------------------

	// Filling mygrid according to the gpf file
	if (get_gridinfo(mypars.fldfile, &mygrid) != 0)
		return 1;

58
59
60
61
62
	//allocating CPU memory for floatgrids
	size_t size_fgrid_nelems = (mygrid.num_of_atypes+2) * mygrid.size_xyz[0] * mygrid.size_xyz[1] * mygrid.size_xyz[2];
	vector<float,aligned_allocator<float>> floatgrids(size_fgrid_nelems);


lvs's avatar
lvs committed
63
64
65
66
67
68
69
70
71
	// Filling the atom types filed of myligand according to the grid types
	if (init_liganddata(mypars.ligandfile, &myligand_init, &mygrid) != 0)
		return 1;

	// Filling myligand according to the pdbqt file
	if (get_liganddata(mypars.ligandfile, &myligand_init, mypars.coeffs.AD4_coeff_vdW, mypars.coeffs.AD4_coeff_hb) != 0)
		return 1;

	//Reading the grid files and storing values in the memory region pointed by floatgrids
72
	if (get_gridvalues_f(&mygrid, floatgrids.data()) != 0)
lvs's avatar
lvs committed
73
74
75
76
77
78
79
80
81
82
		return 1;

	//------------------------------------------------------------
	// Capturing algorithm parameters (command line args)
	//------------------------------------------------------------
	get_commandpars(&argc, argv, &(mygrid.spacing), &mypars);

	//------------------------------------------------------------
	// Calculating energies of reference ligand if required
	//------------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
83
#if 0
lvs's avatar
lvs committed
84
85
	if (mypars.reflig_en_reqired == 1)
		print_ref_lig_energies_f(myligand_init, mygrid, floatgrids, mypars.coeffs.scaled_AD4_coeff_elec, mypars.coeffs.AD4_coeff_desolv, mypars.qasp);
Leonardo Solis's avatar
Leonardo Solis committed
86
87
88
89
90
#endif
	if (mypars.reflig_en_reqired == 1) {
		print_ref_lig_energies_f(myligand_init,
					 mypars.smooth,
					 mygrid,
91
					 floatgrids.data(),
Leonardo Solis's avatar
Leonardo Solis committed
92
93
94
95
					 mypars.coeffs.scaled_AD4_coeff_elec,
					 mypars.coeffs.AD4_coeff_desolv,
					 mypars.qasp);
	}
lvs's avatar
lvs committed
96
97
98
99

	//------------------------------------------------------------
	// Starting Docking
	//------------------------------------------------------------
100
	if (docking_with_gpu(&mygrid, floatgrids.data(), &mypars, &myligand_init, &argc, argv, clock_start_program) != 0)
lvs's avatar
lvs committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
		return 1;

/*
	clock_stop_program = clock();
	printf("Program run time: %.3f sec\n", ELAPSEDSECS(clock_stop_program, clock_start_program));
*/

	// ------------------------
	// Correct time measurement
	// Moved to performdocking.cpp to skip measuring build time
	gettimeofday(&time_end,NULL);
	num_sec     = time_end.tv_sec  - time_start.tv_sec;
	num_usec    = time_end.tv_usec - time_start.tv_usec;
	elapsed_sec = num_sec + (num_usec/1000000);
	printf("Program run time %.3f sec (CORRECTED, used for EVALUATION)\n",elapsed_sec);
	//// ------------------------

	return 0;
}