diff --git a/.gitignore b/.gitignore index 8d04c25dcfa5145e0e8676a094db00a93db2434a..51a08d73f0d66cac7783a9a8a3b693ec16a90f50 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ __pycache__/ *.gro *.code-workspace *.itp -system/ \ No newline at end of file +system/ +20190322_10 \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG index a3f26c433e26546a9f0c1b069e0977a3bd1791c2..5c457a2886b7086a9178cdac5936de995bd78b04 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.1] - 2020-09-14 +### Added +- add atom2group funtion in order to keep fixed the molecules per domain id + +### Changed +- None + +### Removed +- None + ## [0.1.0] - 2020-07-31 ### Added - None diff --git a/main.py b/main.py index 1dfa9cea7b349e0c542fb57dadb2d780cfc1ba22..0b2b1f26bec406acebf1c843abfe58a13070e18f 100644 --- a/main.py +++ b/main.py @@ -8,9 +8,9 @@ import tooba_gmx as tbgmx # in case of tail is the one closest to the head, hence # the code is a good approximation ################################################### -SYSTEM_NAME='test' +SYSTEM_NAME='20190322_10' DISCET=[3.5, 3.5, 3.5] -NUM_FR=2 +NUM_FR=750 TRAJ=SYSTEM_NAME+'/eq_traj.trr' GRO=SYSTEM_NAME+'/eq_final.gro' TPR=SYSTEM_NAME+'/eq_run.tpr' @@ -164,7 +164,8 @@ for i in GROUPS.keys(): #Assign desired atoms (from above function) to subdomains ##result1: {step:{res:{atom_type:{atom_num:(subX,subYsubZ)}}}} ##result2: {step:{res:{atom_type:{(subX,subYsubZ):[atom_num]}}}} - _,box_res=tbf.atom2grid(data_all,box_p, group_ndx) + #todo keep fixed the initial domain name and the molecules that are grouped for all the steps + _,box_res=tbf.atom2group(data_all,box_p, group_ndx) tbf.topickle(fl=box_res, sv_name='./'+SYSTEM_NAME+'/'+SYSTEM_NAME+'_'+i+'_box') del data_all del group_ndx @@ -346,17 +347,18 @@ for i in GROUPS.keys(): #Input to COMBINE property if j[0]!='COMB': if j[1]=='surf': - surf=surf[j[0]] + surf_inuse=surf[j[0]] #del surf[j[0]] if j[1]=='vector': - vector=vector[j[0]] + vector_inuse=vector[j[0]] #del vector[j[0]] #Calculate COMBINE property if j[0]=='COMB': if j[1]=='tilt' and sv_index[i][str(j)]['status']=='not exist': - tilt=tbf.SurfVector_angle(surf,vector) - del surf - del vector + tilt=tbf.SurfVector_angle(surf_inuse,vector_inuse) + #ToDo: check "if str(value['domain']).strip() == str(sub).strip():" + del surf_inuse + del vector_inuse #Loop over timesteps and keep avgs tilts for each step avg={} for step in tilt.keys(): @@ -368,7 +370,7 @@ for i in GROUPS.keys(): avg[sub]=avgs else: avg[sub].append(avgs) - del tilt + #del tilt #Calculate total average tot_avg={} for sub in avg.keys(): diff --git a/tooba_f.py b/tooba_f.py index b3eaebfe3124c8cbc4188f11e9044a1afb78cc4f..f672b852412ad18d4f1a0a57b7b6a28fdd9cd125 100644 --- a/tooba_f.py +++ b/tooba_f.py @@ -515,6 +515,104 @@ def atom2grid(data, box_p, ndx): bar.finish() return box_res, box_res_rev +def atom2group(data, box_p, ndx): + """ + Assign atom number that corresponds to ndx (see 'def atomid_data') + to sudomains created from 'def domain_decomposition' only for the first step. + Then the same domain id is kept for the same group of molecules. The output + is a the box location (non zero based) in xyz-space for each atom number. + + parameters: data = {dictionary input from 'def fr_export'} + box_p = {dictionary input from 'def domain_decomposition'} + ndx = {dictionary input from 'def atomid_data'} + + output: dictionaries + 1. box_res = {step:{resid:{res_type:{atom_type:{atom_num:(subX,subYsubZ)}}}}} + 2. box_res_rev = {step:{resid:{res:{(subX,subYsubZ):[atom_num]}}}} + """ + print(' ') + print('Assing atom to group progress:') + print('==============================') + + step_cnt=0 + domain_list={} + box_res={} + box_res_rev = {} + for step in data.keys(): + step_cnt = step_cnt + 1 + #print('Step: '+step) + bar = Bar('Step: '+step, max=len(ndx.keys())) + box_res[step]={} + box_res_rev[step] = {} + for resid in ndx.keys(): + box_res[step][resid]={} + box_res_rev[step][resid] = {} + for res in ndx[resid].keys(): + box_res[step][resid][res]={} + box_res_rev[step][resid][res]={} + for atom in ndx[resid][res].keys(): + box_res[step][resid][res][atom]={} + box_res_rev[step][resid][res][atom] = {} + for atomnum in ndx[resid][res][atom]: + #data[step]['x'][atom_num-1][x(0),y(1),z(2)] + if step_cnt == 1: + xx=data[step]['x'][int(atomnum)-1][0] + cnt_x=-1 + prev=-1 + for ix in box_p[step]['x']: + cnt_x=cnt_x+1 + if xxprev: + prev=ix + break + + yy=data[step]['x'][int(atomnum)-1][1] + cnt_y=-1 + prev=-1 + for iy in box_p[step]['y']: + cnt_y=cnt_y+1 + if yyprev: + prev=iy + break + + zz=data[step]['x'][int(atomnum)-1][2] + cnt_z=-1 + prev=-1 + for iz in box_p[step]['z']: + cnt_z=cnt_z+1 + if zzprev: + prev=iz + break + + domain_list[atomnum]=(cnt_x,cnt_y,cnt_z) + box_res[step][resid][res][atom][atomnum]=(cnt_x,cnt_y,cnt_z) + else: + box_res[step][resid][res][atom][atomnum]=domain_list[atomnum] + + #Make subdomain position the key and group the residues + for key, value in sorted(box_res[step][resid][res][atom].items()): + box_res_rev[step][resid][res].setdefault(value, []).append(key.strip()) + #Remove atom_type as key of dictionary + box_res_rev[step][resid][res].pop(atom,None) + #If atoms of residue lie in more than one subdomain, put the all in the first one + if len(box_res_rev[step][resid][res]) > 1: + tmp=[] + flattened_list=[] + kk=[] + for sb in box_res_rev[step][resid][res].keys(): + kk.append(sb) + tmp.append(box_res_rev[step][resid][res][sb]) + #Remove keys + for k in kk: + box_res_rev[step][resid][res].pop(k,None) + #flatten the lists + flattened_list = [y for x in tmp for y in x] + #Keep first key and results + box_res_rev[step][resid][res][kk[0]]=flattened_list + #box_res_rev[step][resid][res]=[i for i, e in enumerate(box_res_rev[step][resid][res]) if e.strip() != .strip()] + bar.next() + bar.finish() + return box_res, box_res_rev + def sub_coord(box, data, res_num=[]): """ Use the box_res_rev from 'def atom2grid' and data from 'def fr_export'