def run(self, input_params): trj_id = input_params['trj_id'] new_dict = self.run_min(input_params) print input_params in_fn = new_dict['simulation_in_fn'] bin = new_dict['charmm_bin'] log_fn = in_fn + '.log' nrg_fn = log_fn + '.nrg' mddb_utils.run_cmd_with_file(bin, in_fn, log_fn) st_io = self.parse_energies(log_fn, trj_id) with open(nrg_fn, 'w') as ofp: ofp.write(st_io.getvalue())
def run_min(self, script_params): done_min = False count = 1 start_from_anywhere = False start_from_anywhere = False phi_psi_array = script_params['phi_psi_array'] if len(phi_psi_array) == 0: phi_psi_array = map(lambda x: (-math.pi + random.random()*math.pi*2), [None] * (len(script_params['protein_seq'])-1)*2) script_params['phi_psi_array'] = phi_psi_array start_from_anywhere = True """Run Minimization using Charmm by default""" new_job_dict = None while True: new_job_dict = genpep.generate_scripts(script_params) pdb_fn = new_job_dict['pdb_file_name'] if os.path.isfile(pdb_fn): mddb_utils.run_cmd_with_retries("rm {0}".format(pdb_fn), 1000) minimization_in_fn = new_job_dict['minimization_in_fn'] while True: try: charmm_bin = script_params['charmm_bin'] st =mddb_utils.run_cmd_with_file(charmm_bin, minimization_in_fn, minimization_in_fn+".log") break except Exception, e: print str(e) time.sleep(0.2) if not os.path.isfile(pdb_fn): time.sleep(0.5) else: done_min = os.path.getsize(pdb_fn) > 0 if done_min: break neg_or_pos = [-1,1] print "Trial {0}: {1} {2}".format(count, script_params['phi_psi_array'], done_min) count = count + 1 if count < 50 and not start_from_anywhere: delta_phipsi = map(lambda x: neg_or_pos[random.randint(0,1)] * (random.uniform(0,10)*math.pi/180), [None] * (len(script_params['protein_seq'])-1)*2) script_params['phi_psi_array'] = map(lambda a,b: a-b, script_params['phi_psi_array'], delta_phipsi) else: sign = neg_or_pos[random.randint(0,1)] script_params['phi_psi_array'] = map(lambda x: sign* (-math.pi + random.randint(4,15)*math.pi/24), [None] * (len(script_params['protein_seq'])-1)*2)