From d7b28f120bb8a5fdfb18d1e84d7504724ead30fe Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 2 Apr 2018 15:04:47 -0700 Subject: [PATCH] Add input bias parser to core functions. --- plumitas/core.py | 47 ++++++++++++++++++++++++++++++++++++++++ plumitas/data/plumed.dat | 37 +++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 plumitas/data/plumed.dat diff --git a/plumitas/core.py b/plumitas/core.py index b5817e4..5fa9124 100644 --- a/plumitas/core.py +++ b/plumitas/core.py @@ -1,4 +1,5 @@ import os +import re import pandas as pd @@ -68,3 +69,49 @@ def read_hills(filename='HILLS'): CVs and bias as columns, time as index. """ return read_colvar(filename) + + +def parse_bias(filename='plumed.dat', method=None): + """ + Function that takes experimental data and gives us the + dependent/independent variables for analysis. + + Parameters + ---------- + filename : string + Name of the plumed input file used for enhanced sampling run. + method : string + Name of bias method used during + Returns + ------- + bias_args : dict + Dictionary of key: value pairs from the plumed.dat file. Will + facilitate automatic reading of parameter reading once + core.SamplingProject class is implemented. + """ + if not method: + print('Parser requires method to identify biased CVs. ' + 'Please retry with valid method arg.') + return + + # read input file into string + full_path = os.path.abspath(filename) + input_string = '' + with open(full_path) as input_file: + for line in input_file: + input_string += line + + # isolate bias section + method = method.upper() + bias_string = input_string.split(method)[1].lower() + + # use regex to create dictionary of arguments + arguments = (re.findall(r'\w+=".+?"', bias_string) + + re.findall(r'\w+=[\S.]+', bias_string)) + + # partition each match at '=' + arguments = [(m.split('=')[0], m.split('=')[1].split(',')) + for m in arguments] + bias_args = dict(arguments) + + return bias_args diff --git a/plumitas/data/plumed.dat b/plumitas/data/plumed.dat new file mode 100644 index 0000000..5f047f4 --- /dev/null +++ b/plumitas/data/plumed.dat @@ -0,0 +1,37 @@ +RESTART +MOLINFO MOLTYPE=protein STRUCTURE=reference.pdb +WHOLEMOLECULES ENTITY0=1-55 + +CENTER ATOMS=20-28 LABEL=pos0 +CENTER ATOMS=45-47 LABEL=neg0 +dp0n0: DISTANCE ATOMS=pos0,neg0 + +#### DIHEDRALS #### +#phiA0: TORSION ATOMS=@phi-A2 +psiA0: TORSION ATOMS=@psi-2 +phiA1: TORSION ATOMS=@phi-3 +psiA1: TORSION ATOMS=@psi-3 +phiA2: TORSION ATOMS=@phi-4 +#psiA2: TORSION ATOMS=@psi-A4 + +#### Water COORDINATION #### +GROUP ATOMS=21,24,25,27,28 LABEL=pos_H +GROUP ATOMS=46,47 LABEL=neg_O +GROUP ATOMS=56-4118:3 LABEL=sol_O + +coord_H: COORDINATION GROUPA=pos_H GROUPB=sol_O D_0=0.19 R_0=0.03 +coord_O: COORDINATION GROUPA=neg_O GROUPB=sol_O D_0=0.27 R_0=0.03 + +PBMETAD ... +ARG=dp0n0,psiA0,phiA1,psiA1,phiA2,coord_H,coord_O +PACE=500 BIASFACTOR=10.0 HEIGHT=2.0 TEMP=300.0 +SIGMA=0.02,0.25,0.25,0.25,0.25,0.25,0.25 +FILE=HILLS_MTD0,HILLS_psiA0,HILLS_phiA1,HILLS_psiA1,HILLS_phiA2,HILLS_coord_H,HILLS_coord_O +GRID_MIN=0,-pi,-pi,-pi,-pi,-2,-2 +GRID_MAX=3.0,pi,pi,pi,pi,20,20 +LABEL=pb +WALKERS_MPI +... PBMETAD + +#make STRIDE = to your exchange attempt frequency!!! +PRINT FILE=COLVAR ARG=* STRIDE=500