def run_multiprocessing(a_grofileName): # -------------------------------------------------------------------- # Getting topology for molec0 and molec1 # -------------------------------------------------------------------- itpmolec0 = Topology.fromItpFile(workdir, molec0_ipt, Hydros0) itpmolec0.fromGroFile(workdir, a_grofileName) itpmolec1 = Topology.fromItpFile(workdir, molec1_itp, Hydros1) itpmolec1.fromGroFile(workdir, a_grofileName) # -------------------------------------------------------------------- # Getting the molecules0 and molecules1 corresponding to the itpmolec0 and itpmolec1, respectvely # -------------------------------------------------------------------- grofile = FileUtil.FileReader(workdir, a_grofileName).file print('\nGetting all molec0 molecules present in grofile: {}\n'.format(a_grofileName)) molecs0_dict = add.get_molecules(itpmolec0, grofile) print('\nGetting all molec1 molecules present in grofile: {}\n'.format(a_grofileName)) molecs1_dict = add.get_molecules(itpmolec1, grofile) # -------------------------------------------------------------------- # Getting h-bonds interactions # -------------------------------------------------------------------- # h-bonds interactions between molec0 and molec1. Where in molec0 we get X-H bond and in molec 1 we get Y # ------------------------------ print('\nThe hydrogen bonds found between X-H from molec0 and Y from molec1 present in grofile {} are:\n'.format(a_grofileName)) hbonds0_list = add.get_bonded_interactions(molecs0_dict, itpmolec0, molecs1_dict, Hydros1, Alkali1, dist_thres, angle_thres) if not hbonds0_list: print('\nNo hydrogen bonds found between X-H from molec0 and Y from molec1 present in grofile {}\n'.format(a_grofileName)) else: print('\nA total of {} hydrogen bonds found between X-H from molec0 and Y from molec1 present in grofile {}\n'.format(str(len(hbonds0_list)), a_grofileName)) # h-bonds interactions between molec0 and molec1. Where in molec0 we get X-H bond and in molec 1 we get Y # ------------------------------ print('\nThe hydrogen bonds found between X-H from molec1 and Y from molec0 present in grofile {} are:\n'.format(a_grofileName)) hbonds1_list = add.get_bonded_interactions(molecs1_dict, itpmolec1, molecs0_dict, Hydros0, Alkali0, dist_thres, angle_thres) if not hbonds1_list: print('\nNo hydrogen bonds found between X-H from molec1 and Y from molec0 present in grofile {}\n'.format(a_grofileName)) else: print('\nA total of {} hydrogen bonds found between X-H from molec1 and Y from molec0 present in grofile {}\n'.format(str(len(hbonds1_list)), a_grofileName)) # adding both list # ------------------------------ hbond_list = hbonds0_list + hbonds1_list # we just add them del(itpmolec0, itpmolec1, grofile, molecs0_dict, molecs1_dict, hbonds0_list, hbonds1_list) # delete things to free space in case we run out of memory during the multiprocessing return hbond_list
# ------------------------------------------------------------------------------------------------- # Plotting the number of hydrogen bonds for each one of the different grofiles # ------------------------------------------------------------------------------------------------- plotObj = HbondsPlotter(all_hbonds) # creating the HbondsPlotter object from the all_bonds list plotObj.plot(workdir, frame_time) # method to print all the h-bonds plots. print('\nFinished all plots!\n') # ------------------------------------------------------------------------------------------------- # Getting the density profile using gmx density # ------------------------------------------------------------------------------------------------- # Getting the residue name for molec0 and molec1 (see Topology.py for more info) # ------------------------------ molec0_residue= Topology.fromItpFile(workdir, molec0_ipt, Hydros0).residue molec1_residue = Topology.fromItpFile(workdir, molec1_itp, Hydros1).residue # Getting the z-axis length of the grofile (any grofile can be used) # ------------------------------ zBoxLen = float(FileUtil.FileReader(workdir, grofiles[-1]).file[-1].split()[2]) # Any grofile can be used. The last was selected. # Getting the density file file # ------------------------------ add.get_gmx_index_density_files(workdir, all_hbonds, molec0_residue, molec1_residue, zBoxLen, gmx_call, grofiles[-1], xtc_filename, tpr_filename, outdens_xvg) print('\nDensity profile was calculated sucessfully!\n')