main.cpp 3.39 KB
Newer Older
1
#include "ext_headers.h"
lvs's avatar
lvs committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "processgrid.h"
#include "processligand.h"
#include "getparameters.h"
#include "performdocking.h"

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

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

	Gridinfo mygrid;
	Liganddata myligand_init;
	Dockpars mypars;

18
19
20
21
	clock_t clock_start_program;
	/*
	clock_t clock_stop_program;
	*/
lvs's avatar
lvs committed
22
23
24
25

	clock_start_program = clock();

	// ------------------------
26
	// Time measurement
lvs's avatar
lvs committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
	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;

48
49
50
51
52
	//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
53
54
55
56
57
58
59
60
61
	// 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
62
	if (get_gridvalues_f(&mygrid, floatgrids.data()) != 0)
lvs's avatar
lvs committed
63
64
65
66
67
68
69
70
71
72
		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
73
74
75
76
	if (mypars.reflig_en_reqired == 1) {
		print_ref_lig_energies_f(myligand_init,
					 mypars.smooth,
					 mygrid,
77
					 floatgrids.data(),
Leonardo Solis's avatar
Leonardo Solis committed
78
79
80
81
					 mypars.coeffs.scaled_AD4_coeff_elec,
					 mypars.coeffs.AD4_coeff_desolv,
					 mypars.qasp);
	}
lvs's avatar
lvs committed
82
83
84
85

	//------------------------------------------------------------
	// Starting Docking
	//------------------------------------------------------------
86
	if (docking_with_fpga(&mygrid, floatgrids.data(), &mypars, &myligand_init, &argc, argv, clock_start_program) != 0)
lvs's avatar
lvs committed
87
88
		return 1;

89
	/*
lvs's avatar
lvs committed
90
91
	clock_stop_program = clock();
	printf("Program run time: %.3f sec\n", ELAPSEDSECS(clock_stop_program, clock_start_program));
92
	*/
lvs's avatar
lvs committed
93
94

	// ------------------------
95
	// Time measurement
lvs's avatar
lvs committed
96
97
98
99
	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);
100
101
	printf("Full program-execution time %.3f secs\n",elapsed_sec);
	// ------------------------
lvs's avatar
lvs committed
102
103
104

	return 0;
}