def run(self): with open(self.docking_parameter_file, 'r') as p_file: for line in p_file: if line.startswith("intelec"): self.dock.dps.calc_inter_elec_e = True # Atomic bonding parameter file if line.startswith("b_prm"): self.dock.bond.read(line.split()[1]) if line.startswith("ligand_types"): for type in line.split('#')[0].split()[1:]: self.dock.ligand.atom_types.append(type) self.atom_type_map_files[type] = "" self.dock.bond.calc_internal_energy_tables( self.dock.ligand) if line.startswith("fld"): self.grid_field_file = "./Parameters/" + line.split()[1] self.dock.grid.field = Field(self.grid_field_file) if line.startswith("map"): filename = line.split()[1] type = filename.split('.')[1] self.atom_type_map_files[type] = "./Maps/" + filename self.dock.grid.maps[type] = AtomTypeMap( self.atom_type_map_files[type], self.dock.grid.field).map if line.startswith("elecmap"): self.electrostatic_map_file = "./Maps/" + line.split()[1] self.dock.grid.maps['e'] = ElectrostaticMap( self.electrostatic_map_file, self.dock.grid.field).map if line.startswith("desolvmap"): self.desolvation_map_file = "./Maps/" + line.split()[1] self.dock.grid.maps['d'] = DesolvationMap( self.desolvation_map_file, self.dock.grid.field).map # Set movable molecule (ligand) if line.startswith("move"): self.ligand_file = "./Inputs/" + line.split()[1] self.dock.ligand.read_pdbqt(self.ligand_file) # Set flexible portion of molecule (normally protein receptor) if line.startswith("flexres"): self.protein_file = "./Inputs/" + line.split()[1] self.dock.protein.read_flex_pdbqt(self.protein_file) if line.startswith("about"): about = Axis3(0.0, 0.0, 0.0) about.xyz = [float(axis) for axis in line.split()[1:4]] self.dock.ligand.about = about # Zero-out central point. Applicable only for all ligand # atoms (not protein atoms) for i in xrange(len(self.dock.ligand.ori_atoms)): self.dock.ligand.ori_atoms[i].tcoord -= about self.dock.ligand.reset_atoms() # Pre-energy calculation if line.startswith("pre_energy_calc"): # Get atomic non-bond lists self.dock.get_non_bond_list() # Calculate binding torsional free energy self.dock.torsional_energy = self.dock.bond.torsional_dof * \ self.dock.bond.fec_tors # --------------------------------------- Empirical Settings --- # 1-4 interactions if line.startswith("include_1_4_interactions"): # By default, 1-4 interactions is disabled. Only 1-1, 1-2, # and 1-3 interactions are considered. self.dock.bond.include_1_4_interactions = True # Torsional degrees of freedom (DoF) if line.startswith("torsdof"): self.dock.bond.torsional_dof = int(line.split()[1]) #---------------------------------------------- Optimization --- # Define optimization type to use if line.startswith("opt_type"): type = line.split()[1] if type == "ga": if self.accelerator == "sequential": self.optimization = \ Optimization.GeneticAlgorithm(self.dock) if self.accelerator == "opencl": self.optimization = \ Optimization.GeneticAlgorithmOpenCL(self.dock, \ self.cl_device_type) # Run optimization if line.startswith("opt_run"): self.optimization.run() #------------------------------------ Opt: Genetic Algorithm --- if line.startswith("opt_ga"): words = line.split() type = words[1] value = words[2] if type == "community_size": self.optimization.community_size = int(value) if type == "pop_size": self.optimization.population_size = int(value) if type == "num_generations": self.optimization.num_gen = int(value) #----------------------------------------------- Accelerator --- # Define parallel processing accelerator if line.startswith("accelerator"): self.accelerator = line.split()[1] if self.accelerator == "sequential": self.dock = Dock() if self.accelerator == "opencl": self.dock = DockOpenCL() # Define OpenCL device types if line.startswith("ocl_device_type"): self.cl_device_type = line.split()[1]
def testCalcEnergy(self): ligand = Ligand() ligand.read_pdbqt("./Inputs/ind.pdbqt") ligand.update_tcoord_model("./Results/ind_1.model") grid = Grid() grid.field = Field("./Parameters/hsg1_rigid.maps.fld") grid.maps['e'] = ElectrostaticMap("./Maps/hsg1_rigid.e.map", grid.field).map grid.maps['d'] = DesolvationMap("./Maps/hsg1_rigid.d.map", grid.field).map grid.maps['A'] = AtomTypeMap("./Maps/hsg1_rigid.A.map", grid.field).map grid.maps['C'] = AtomTypeMap("./Maps/hsg1_rigid.C.map", grid.field).map grid.maps['HD'] = AtomTypeMap("./Maps/hsg1_rigid.HD.map", grid.field).map grid.maps['N'] = AtomTypeMap("./Maps/hsg1_rigid.N.map", grid.field).map grid.maps['NA'] = AtomTypeMap("./Maps/hsg1_rigid.NA.map", grid.field).map grid.maps['OA'] = AtomTypeMap("./Maps/hsg1_rigid.OA.map", grid.field).map dock = Dock() dock.ligand = ligand dock.grid = grid dock.calc_energy() exp_elecs = [-0.037623435264000013, -0.11408866126250672, \ -0.13002690236871114, -0.11316478799697538, \ 0.079400682425344024, 0.16382104147968005, \ 0.35572237014565938, -0.13983584352051195, \ -0.14455922704497778, -0.2437679729095111, \ -0.2233031453627734, -0.057756149112888927, \ -0.079042238535680001, -0.032257681663999997, \ -0.14416303698488891, 0.10750629826486036, \ 0.24778700799999992, -0.084038775587896894, \ -0.106404338719744, -0.052751354779306661, \ 0.024654531648227552, -0.0042321141760000005, \ -0.00035986557866666673, -0.00033659216281599992, \ -0.0041046807466666672, 0.012465198300672001, \ -0.090822509727725043, -0.17177248957202962, \ 1.1082351947605333, -0.89707293013333311, \ 0.026757765866666665, -0.0020757145903407409, \ -0.00025216804266666674, -0, -0.00048987137962666649, \ -0.0041342845067377787, -0.077292167626752006, \ 0.0028771771022222214, -0.035468487893333331, \ 0.061588514183964438, -0.025041379570346665, \ -0.0055949960533333357, -0.0031704985600000007, \ -0.0069595652002702214, -0.012058230703198818, \ -0.0079140675343170441, -0.012375409536000002, \ 0.3866265132258988, -0.20299363642879997] self.assertEquals(dock.elecs, exp_elecs) exp_elec_total = -0.689862915434 self.assertLessEqual(dock.elec_total - exp_elec_total, 0.000000000001) self.assertGreaterEqual(dock.elec_total - exp_elec_total, -0.000000000001) exp_emaps = [-0.27127903027200001, -0.16588333043273959, \ -0.20299416690915556, -0.21193308408991288, \ -0.22342833248403907, -0.10887097308672009, \ -0.069412406582518515, -0.32392036196890539, \ -0.22020219191751092, -0.35971221242311113, \ -0.36151369650175996, -0.33589534698001067, \ -0.31399731050837326, -0.37602125178402135, \ -0.18051097352533335, -0.17621873305273847, \ -0.092143525887999983, -0.2309628750124183, \ -0.24049173290393594, -0.30815793025564453, \ -0.39344854528779372, -0.50645809636693317, \ -0.53159663755332287, -0.49475817361601443, \ -0.34577077998990213, -0.31340080937233067, \ 0.083165888601903395, -0.37009113352391104, \ -0.26495262599680025, -0.35829845333333321, \ -0.27628956787200004, -0.36140396483508141, \ -0.31815226712832012, -0.2094688831146666, \ -0.23815943764081771, -0.24906767845688918, \ -0.22192987677536707, -0.25745685461333312, \ -0.19937555381333344, -0.2350488774924894, \ -0.19400907040085333, -0.14228789478968887, \ -0.23528794258204436, -0.4346495467977386, \ -0.44998934942632773, -0.52384750919471401, \ -0.51774914410666673, -0.26729886470788744, \ 0.052065064174933465] self.assertEquals(dock.emaps, exp_emaps) exp_emap_total = -13.5485660526 self.assertLessEqual(dock.emap_total - exp_emap_total, 0.0000000001) self.assertGreaterEqual(dock.emap_total - exp_emap_total, -0.0000000001)