def pump_at_res(self,res_ids,mode=0,frequency=1,force=100,time=500,velocity=False,temperature=300,cuda='0',ratio_threshold=2,top=5,window=1,rm_file=True,bb=False): ''' Run pumped md and return the pumped residues if index>0 ''' pdb_file = self.pdb if isinstance(res_ids,int): res_index = str(res_ids) if isinstance(res_ids,list): res_index = str() for temp_id in res_ids: res_index = res_index+str(temp_id)+'_' if self.index==0: self.index+=1 atom_ids = utils.get_atom_ids(pdb_file,res_ids) vec = self.calc_nm_vec(res_ids,mode) plumed_in = self.write_plumed_file(atom_ids,vec,frequency=frequency,force=force,res_index=res_index) in_file = self.write_prod_input_file(time,plumed_in,velocity=velocity,temperature=temperature) self.run(in_file,cuda,velocity=velocity) self.run_cpptraj() ''' traj_file = self.path_dir+'/prod'+str(index)+'_nm_nw.xtc' top_file = 'mol_nw.prmtop' traj_data = ana.calc_com(traj_file,top_file,bb=bb) _,y_temp = ana.calc_fps(traj_data,time) _,nr = ana.pick_peak(self.xf,self.y0,y_temp,ratio_threshold=ratio_threshold,top=top,window=window,freq=frequency) ''' if rm_file: os.system('rm '+self.path_dir+'/*mdcrd') self.index+=1 return None
def pump(self,res_ids,mode=0,frequency=1,force=100,time=500,velocity=False,cuda='0',threshold=3,window=1,rm_file=True,bb=False,temperature=300): ''' Run pumped md and return the pumped residues if index>0 ''' pdb_file = self.pdb index = self.index if index==0: if os.path.exists('control_dist.pkl'): f = open('control_dist.pkl','rb') mean,std = pickle.load(f) self.mean = mean self.std = std f.close() self.index += 1 else: print('Please run control simulation') return None ''' in_file = self.write_prod_input_file(time,None,velocity=velocity,temperature=temperature) self.run(in_file,cuda,velocity=velocity) self.run_cpptraj() self.strip_topology_wat() traj_file = self.path_dir+'/prod'+str(index)+'_nm_nw.xtc' top_file = 'mol_nw.prmtop' traj_data = ana.calc_com(traj_file,top_file,bb=bb) self.xf,self.y0 = ana.calc_fps(traj_data,time) f = open('control.pkl','wb') pickle.dump([self.xf,self.y0],f) f.close() self.index +=1 ''' index = self.index atom_ids = utils.get_atom_ids(pdb_file,res_ids) vec = self.calc_nm_vec(res_ids,mode) plumed_in = self.write_plumed_file(atom_ids,vec,frequency,force) in_file = self.write_prod_input_file(time,plumed_in,velocity=velocity,temperature=temperature) self.run(in_file,cuda,velocity=velocity) self.run_cpptraj() traj_file = self.path_dir+'/prod'+str(index)+'_nm_nw.xtc' top_file = 'mol_nw.prmtop' traj_data,rmsf_data = ana.calc_com(traj_file,top_file,bb=bb) xf,y_temp = ana.calc_fps(traj_data,rmsf_data,time) fps_temp = ana.calc_fps_at_freq(xf,y_temp,window=1,freq=frequency) nr = ana.pick_peak_new(self.mean,self.std,fps_temp,threshold=threshold) self.index +=1 if rm_file: os.system('rm '+self.path_dir+'/*mdcrd') return nr
def pump_at_res(self,res_ids,cuda='0',rm_file=True): ''' Run pumped MD given res_id ''' pdb_file = self.pdb if isinstance(res_ids,int): res_index = str(res_ids) if isinstance(res_ids,list): res_index = str() for temp_id in res_ids: res_index = res_index+'_'+str(temp_id) atom_ids = utils.get_atom_ids(pdb_file,res_ids) vec = self.calc_pump_vec(atom_ids) plumed_in = self.write_plumed_file(atom_ids,vec,res_index=res_index) prod_in = self.write_prod_input_file(plumed_in) self.run(prod_in,cuda=cuda) self.run_cpptraj() self.dump_traj() if rm_file: os.system('rm '+self.path_dir+'/*mdcrd') self.index+=1 return None
def write_cpptraj_vac_input_file(pdb_file, crd_file, vel_file, top_file, path): ''' write cpptraj input file to calculate VAC for each residue Input: crd_file: crd file name vel_file; vel file name top_file: topology file name path: path directory ''' res_num = utils.get_res_num(pdb_file) file_name = 'ctj_vac.in' f = open(file_name, 'w') f.write('parm ' + top_file + '\n') f.write('trajin ' + crd_file + ' mdvel ' + vel_file + '\n') for i in range(res_num): atom_ids = utils.get_atom_ids(pdb_file, i + 1, False) atom_ids_str_list = [str(id + 1) for id in atom_ids] atom_mask = ','.join(atom_ids_str_list) out_file = path + '/res_' + str(i + 1) + '_vac.dat' f.write('velocityautocorr @' + atom_mask + ' out ' + out_file + ' tstep 0.01 norm\n') f.close() return None
required=True, help= 'The ids of starting residues, saperate by \',\' no space, for example 1,2,3' ) parser.add_argument('--end_res', action='store', type=str, required=True, help='The ids of end residues, saperate by \',\' no space') parser.add_argument('--force', action='store', type=float, required=True, help='The amplitude of oscilation force, unit pN') parser.add_argument( '--frequency', action='store', type=float, required=True, help='Frequency of oscilation force, unit 1ps-1 or 10^12 Hz') args = parser.parse_args() start_res = args.start_res.split(',') end_res = args.end_res.split(',') start_res = [int(id) for id in start_res] end_res = [int(id) for id in end_res] index = 0 start_ids = utils.get_atom_ids(start_res) sys.write_plumed_files(start_ids, args.frequency, args.force, index)