END_TEST START_TEST(test_ieng) { zero_grads(test_ag); check_grads(test_ag, delta, ieng); }
END_TEST START_TEST(test_aeng) { zero_grads(test_ag); //check_grads(test_ag, delta, aeng); }
void check_grads(struct atomgrp *ag, double d, void (*efun)(struct atomgrp *, double*)) { int n=ag->natoms, i; double en, en1, t; double *fs=malloc(3*n*sizeof(double)); //en0 en=0; (*efun)(ag, &en); for(i=0; i<n; i++) { //x en1=0; t=ag->atoms[i].X; ag->atoms[i].X=d+t; (*efun)(ag, &en1); ag->atoms[i].X=t; fs[3*i]=(en-en1)/d; //y en1=0; t=ag->atoms[i].Y; ag->atoms[i].Y=d+t; (*efun)(ag, &en1); ag->atoms[i].Y=t; fs[3*i+1]=(en-en1)/d; //z en1=0; t=ag->atoms[i].Z; ag->atoms[i].Z=d+t; (*efun)(ag, &en1); ag->atoms[i].Z=t; fs[3*i+2]=(en-en1)/d; } en=0; zero_grads(ag); (*efun)(ag, &en); char msg[256]; for(i=0; i<n; i++) { sprintf(msg, "\n(atom: %d) calc: (%lf, %lf, %lf): numerical: (%lf, %lf, %lf)\n", i, ag->atoms[i].GX, ag->atoms[i].GY, ag->atoms[i].GZ, fs[3*i],fs[3*i+1],fs[3*i+2]); ck_assert_msg(fabs(ag->atoms[i].GX - fs[3*i]) < tolerance, msg); ck_assert_msg(fabs(ag->atoms[i].GY - fs[3*i+1]) < tolerance, msg); ck_assert_msg(fabs(ag->atoms[i].GZ - fs[3*i+2]) < tolerance, msg); } free(fs); }
void check_epeng_grads(struct atomgrp *ag, struct grid* pot, double d, void (*efun)(double, struct atomgrp *, double*, struct grid*)) { int n=ag->natoms, i; double en, en1, t; double *fs=(double*)_mol_malloc(3*n*sizeof(double)); //en0 en=0; // (*efun)(ag, &en); (*efun)(1.0,ag, &en, pot); for(i=0; i<n; i++) { //x en1=0; t=ag->atoms[i].X; ag->atoms[i].X=d+t; // (*efun)(ag, &en1); (*efun)(1.0,ag, &en1, pot); ag->atoms[i].X=t; fs[3*i]=(en-en1)/d; //y en1=0; t=ag->atoms[i].Y; ag->atoms[i].Y=d+t; // (*efun)(ag, &en1); (*efun)(1.0,ag, &en1, pot); ag->atoms[i].Y=t; fs[3*i+1]=(en-en1)/d; //z en1=0; t=ag->atoms[i].Z; ag->atoms[i].Z=d+t; // (*efun)(ag, &en1); (*efun)(1.0,ag, &en1, pot); ag->atoms[i].Z=t; fs[3*i+2]=(en-en1)/d; } en=0; zero_grads(ag); // (*efun)(ag, &en); (*efun)(1.0,ag, &en, pot); for(i=0; i<n; i++) { printf("%d calculated: %lf %lf %lf\n", i,ag->atoms[i].GX,ag->atoms[i].GY,ag->atoms[i].GZ); printf("%d numerical : %lf %lf %lf\n", i,fs[3*i],fs[3*i+1],fs[3*i+2]); } free(fs); }
int main(int argc, char* argv[]){ // Input Files // /* Intro Message */ printf("\n"); printf("A Program to Repack Protein Side-chains for Protein Docking Refinement Procedures\n"); printf("Copyright (c) 2014, Structural Bioinformatics Laboratory, Boston University\n"); printf("Author: Mohammad Moghadasi ([email protected]) \n"); if(argc!=10){ printf("Usage:\n ./main \n Complex_IN.pdb Complex_IN.psf Complex_IN.mol2 Complex_IN_Ligand.pdb\n Libmol-param-file charmm-param-file.prm charmm-rtf-file.rtf rotamer-library-binary-file.txt\n Complex_OUT.pdb\n \n"); exit(EXIT_FAILURE); } char* ifile = argv[1]; //pdb file of both receptor and ligand char* psffile = argv[2]; //charmm type psf file char* mol2file = argv[3]; //mol2 file char* pdbfilelig = argv[4]; //pdb file of ligand char* atom_prm_file = argv[5]; //libmol parameter file prmfile = argv[6]; //charmm type parameter file rtffile = argv[7]; //charmm type connectivity file char* rotamer_library_file = argv[8]; //rotamer raw library file char* ofile = argv[9]; //output file // Filling the atom_group struct // struct prm *atomprm = read_prm(atom_prm_file,_MOL_VERSION_); struct atomgrp* ag = read_file_atomgrp(ifile, atomprm, -1); read_ff_charmm(psffile, prmfile, rtffile, ag); if(!read_hybridization_states_from_mol2(mol2file,ag)){ exit (EXIT_FAILURE); } fix_acceptor_bases(ag,atomprm); struct List lig_list; read_fix(pdbfilelig,&lig_list.n,&lig_list.K); fixed_init(ag); fixed_update_unfreeze_all(ag); zero_grads(ag); fill_ingrp(ag); struct agsetup* ags; ags = malloc(sizeof(struct agsetup)); init_nblst(ag,ags); update_nblst(ag,ags); // Mark interface residues // int num_of_res_interface; int res_list_interface[ag->nres]; mark_interface_residues(ag,ags,lig_list, lig_rec_dist ,&num_of_res_interface,res_list_interface); // Initialize side chain rotamer library // //nrotCoef = 3; nrotCoef = 1; MAX_ROT = 245; MAX_RES = ag->nres;//needed for full_pack cutoff = 3; // Reslist // struct ifres_list* reslist; ifres_list_malloc( &reslist ); reslist->num_of_ifres = num_of_res_interface; for(int r = 0; r < reslist->num_of_ifres ; r++) reslist->ifres_num[r] = res_list_interface[r]; // Library // char *rotamer_lib; load_file_to_memory(rotamer_library_file, &rotamer_lib); struct rot_info *rotinf; init_rotinf(ag, num_of_res_interface, res_list_interface, rotamer_lib, &rotinf); struct ifres_list* reslist_minor; ifres_list_malloc( &reslist_minor ) ; // MAIN FUNCITION // // clock_t start, finish; start = clock(); full_pack(ag,lig_list,rotinf,num_of_res_interface, reslist_minor); finish = clock(); if(0) printf("Processing Time = %f\n",((double)(finish-start)/CLOCKS_PER_SEC)); // Writing the atom_group into a PDB // write_pdb_traj_nopar(ag,ifile,ofile); // Free memory // Free_ifres_list( &reslist_minor ); free(rotamer_lib); return 0; }
void check_speng_grads(int nstart, int nend, struct atomgrp *ag, double d, double stens, double* hx0, double* hy0, double* hz0, int nx, int ny, int nz, double dcx, double dcy, double dcz, double cx, double cy, double cz, double w, void (*efun)(double, double, struct atomgrp *, double*, double*, double*, double*, int,int,int, double,double,double, double,double,double,double)) { int n=ag->natoms, i; double en, en1, t; double *fs=(double*)_mol_malloc(3*n*sizeof(double)); //en0 en=0; // (*efun)(ag, &en); // (*efun)(1.0,ag, &en, pot); (*efun)( 1.0, stens, ag, &en, hx0,hy0,hz0, nx,ny,nz, dcx, dcy, dcz, cx,cy,cz,w); for(i=nstart; i<=nend; i++) { printf("i= %d\n",i); //x en1=0; t=ag->atoms[i].X; ag->atoms[i].X=d+t; // (*efun)(ag, &en1); // (*efun)(1.0,ag, &en1, pot); (*efun)( 1.0, stens, ag, &en1, hx0,hy0,hz0, nx,ny,nz, dcx, dcy, dcz, cx,cy,cz,w); ag->atoms[i].X=t; fs[3*i]=(en-en1)/d; //y en1=0; t=ag->atoms[i].Y; ag->atoms[i].Y=d+t; // (*efun)(ag, &en1); // (*efun)(1.0,ag, &en1, pot); (*efun)( 1.0, stens, ag, &en1, hx0,hy0,hz0, nx,ny,nz, dcx, dcy, dcz, cx,cy,cz,w); ag->atoms[i].Y=t; fs[3*i+1]=(en-en1)/d; //z en1=0; t=ag->atoms[i].Z; ag->atoms[i].Z=d+t; // (*efun)(ag, &en1); // (*efun)(1.0,ag, &en1, pot); (*efun)( 1.0, stens, ag, &en1, hx0,hy0,hz0, nx,ny,nz, dcx, dcy, dcz, cx,cy,cz,w); ag->atoms[i].Z=t; fs[3*i+2]=(en-en1)/d; } en=0; zero_grads(ag); // (*efun)(ag, &en); // (*efun)(1.0,ag, &en, pot); (*efun)( 1.0, stens, ag, &en, hx0,hy0,hz0, nx,ny,nz, dcx, dcy, dcz, cx,cy,cz,w); for(i=nstart; i<=nend; i++) { printf("%d calculated: %lf %lf %lf\n", i,ag->atoms[i].GX,ag->atoms[i].GY,ag->atoms[i].GZ); printf("%d numerical : %lf %lf %lf\n", i,fs[3*i],fs[3*i+1],fs[3*i+2]); } free(fs); }