From f8332608bd434f7808a652d2192e137ce3b67bd6 Mon Sep 17 00:00:00 2001 From: skarozis Date: Thu, 2 Jul 2020 17:04:57 +0300 Subject: [PATCH] Initial support for gmx commands --- CHANGELOG | 11 +++++++ main.py | 90 ++++++++++++++++++++++++++++++++++++++++------------ tooba_gmx.py | 72 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+), 20 deletions(-) create mode 100644 tooba_gmx.py diff --git a/CHANGELOG b/CHANGELOG index 58a0195..73eb59c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.0.6] - 2020-07-02 +### Added +- Initial support for gmx commands +- Add gmx density profile function + +### Changed +- more dynamic I/O of gmx_ndx + +### Removed +- None + ## [0.0.5] - 2020-05-21 ### Added - Add progress bar per function diff --git a/main.py b/main.py index a69a97d..2ecb5f4 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import os import tooba_f as tbf +import tooba_gmx as tbgmx ################################################### #NOTICE: resids of head in each subdomain may differ in tail case # keep all atoms of group in the first occurent subdomain @@ -12,6 +13,7 @@ DISCET=[6, 6, 6] NUM_FR=1 TRAJ=SYSTEM_NAME+'/eq_traj.trr' GRO=SYSTEM_NAME+'/eq_final.gro' +TPR=SYSTEM_NAME+'/eq_run.tpr' ITP_DIC={'NS':'CER_SOVOVA.itp','FFA':'FFA_CG.itp','CHOL':'CHOL_CG.itp'} ################################################### # {NAME:[QUEUE OF PROCESSES]} @@ -19,18 +21,26 @@ ITP_DIC={'NS':'CER_SOVOVA.itp','FFA':'FFA_CG.itp','CHOL':'CHOL_CG.itp'} # NAME: It is user defined. A dictionary must follows with the same name. # The dict structure has to be: {res_type:[atom_types]} # -# if NAME is COMBINATION then it needs part or all tha info from aforementioned +# if NAME is COMBINE then it needs part or all the info from aforementioned # groups to execute a process. You cannot use combination as first group. # -# QUEUE OF PROCESSES: surf, vector, [save, [type], save_name] -# type: pkl, json, gmx_ndx (one ndx for every subdomain) +# QUEUE OF PROCESSES: surf, vector, tilt, index, density, gmx_ndx, [save, [type], save_name] +# +# surf: Determine surface from atoms (ex. Head of lipid) +# vector: Determine vector that fits atoms (ex. Tail of lipid) +# tilt: Use surf and vector result to calculate angle (if NAME is COMBINE) +# index: Creates unique code (md5) for every subdomain to use in data saving process +# density: Detrmine density profile of x,y,z and save peaks of directions with the least number +# gmx_ndx: Saves one ndx for every subdomain +# [save, [type], save_name]: Save function and properties aka, type: pkl, json, Name # -# if NAME is COMBINATION: [tilt] ################################################### -GROUPS={'HD_GROUP':['surf',['save', ['pkl','gmx_ndx', 'json'],'time_domain_c-normal-cg']], +GROUPS={'ALL':['gmx_ndx','index',['save', ['pkl'],'index'],'density',['save', ['pkl'],'dens']], + 'HD_GROUP':['surf',['save', ['pkl', 'json'],'time_domain_c-normal-cg']], 'TL_GROUP':['vector'], - 'COMBINE':['tilt'] + 'COMBINE':[['HD_GROUP','surf'],['TL_GROUP','vector'],['COMB','tilt']] } +ALL={'NS':['C6', 'Na', 'P4', 'P3', 'C7','C3', 'C4', 'C5', 'C8', 'C9', 'C10'], 'CHOL':['ROH','R1', 'R2', 'R3', 'R4', 'R5'], 'FFA':['AC','C1', 'C2', 'C3', 'C4']} HD_GROUP={'NS':['C6', 'Na', 'P4', 'P3', 'C7'], 'CHOL':['ROH'], 'FFA':['AC']} TL_GROUP={'NS':['C3', 'C4', 'C5', 'C8', 'C9', 'C10'], 'CHOL':['R1', 'R2', 'R3', 'R4', 'R5'], 'FFA':['C1', 'C2', 'C3', 'C4']} ################################################### @@ -74,7 +84,7 @@ for i in GROUPS.keys(): group_ndx=tbf.frompickle('./'+SYSTEM_NAME+'/'+SYSTEM_NAME+'_'+i+'_ndx.pkl') else: #Find atom type index in lists created above - group_ndx=tbf.atomid_data(res_num, res_type, atom_type, atom_num, group=HD_GROUP) + group_ndx=tbf.atomid_data(res_num, res_type, atom_type, atom_num, group=locals()[i]) tbf.topickle(fl=group_ndx, sv_name='./'+SYSTEM_NAME+'/'+SYSTEM_NAME+'_'+i+'_ndx') ################################################### if os.path.isfile('./'+SYSTEM_NAME+'/'+SYSTEM_NAME+'_'+i+'_box.pkl'): @@ -98,25 +108,65 @@ for i in GROUPS.keys(): for j in GROUPS[i]: if len(j) > 1: if j=='surf': + if j not in locals(): + surf={} #Creates dictionary with c, normal per subdomain for each frame - surf=tbf.coord2norm2cg(coord_vector,img=False) - sv_data=surf + surf[locals()[i]]=tbf.coord2norm2cg(coord_vector,img=False) + sv_data=surf[locals()[i]] if j=='vector': - vector=tbf.coord2vector(coord_vector) - sv_data=vector + if vector not in locals(): + vector={} + vector[locals()[i]]=tbf.coord2vector(coord_vector) + sv_data=vector[locals()[i]] + if j=='index': + uniq_id=tbgmx.ndx_index(SYSTEM_NAME) + sv_data=uniq_id + if j=='density': + dens_df={} + for iidd in uniq_id.keys(): + dens_df[iidd]={} + fl='./'+uniq_id[iidd]['system']+'/gmx_ndx/'+uniq_id[iidd]['domain'] + cnt=-1 + for mol in locals()[i].keys(): + cnt=cnt+1 + for d in ('x','y','z'): + peaks = tbgmx.density_picks(TRR=TRAJ,TPR=TPR,IND=fl,SLC=400,ST=1000,EN=-1,normal=d,fld='./'+uniq_id[iidd]['system'],arg=cnt,dist_pk=20) + if d=='x': + tmp=peaks + else: + print(len(tmp),len(peaks)) + if len(tmp)