BFEE2.templates_namd

BFEE2.templates_namd.configTemplate

class BFEE2.templates_namd.configTemplate.configTemplate[source]

Bases: object

generate NAMD/Gromacs/Colvars config files In the Colvars config file, ndx and xyz files are used to indicate the group of atoms The non-hydrogen atoms of protein are labeled as ‘protein’ in complex.ndx The non-hydrogen atoms of ligand are labeled as ‘ligand’ in complex.ndx The non-hydrogen atoms of user-defined reference are labeled as ‘reference’ in complex.ndx

cvABFTemplate(cv, unit='namd', czar=True)[source]

template for WTM-eABF bias

Parameters:
  • cv (str) – name of the colvars

  • unit (str, optional) – unit, ‘namd’ or ‘gromacs’. Default to namd.

  • czar (bool, optional) – whether call the czar estimator. Default to True.

Returns:

string of the WTM-eABF definition

Return type:

str

cvAngleTemplate(setBoundary, lowerBoundary, upperBoundary, angle, refFile, oldDefinition=True, extendedLagrangian=True, reflectingBoundary=False)[source]

Eulaer and polar angle template

Parameters:
  • setBoundary (bool) – whether set boundary (for free-energy calculation)

  • lowerBoundary (float) – lower boundary of free-energy calculaton

  • upperBoundary (float) – upper boundary of free-energy calculation

  • angle (str) – ‘eulerTheta’, ‘eulerPhi’, ‘eulerPsi’, ‘polarTheta’ or ‘polarPhi’

  • refFile (str) – path to the reference file

  • oldDefinition (bool, optional) – Whether use old definition of angles for compatibility. Defaults to True

  • extendedLagrangian (bool, optional) – Whether extended Lagrangian is added. Default to True

  • reflectingBoundary (bool, optional) – Whether use reflecting boundaries, requires setBoundary on. Default to False

cvEulerAngleTemplate(setBoundary, lowerBoundary, upperBoundary, angle, refFile, extendedLagrangian=True, reflectingBoundary=False)[source]

Euler angle template

Parameters:
  • setBoundary (bool) – whether set boundary (for free-energy calculation)

  • lowerBoundary (float) – lower boundary of free-energy calculaton

  • upperboundary (float) – upper boundary of free-energy calculation

  • angle (str) – ‘eulerTheta’, ‘eulerPhi’ or ‘eulerPsi’

  • refFile (str) – path to the reference file

  • extendedLagrangian (bool, optional) – Whether extended Lagrangian is added. Default to True

  • reflectingBoundary (bool, optional) – Whether use reflecting boundaries, requires setBoundary on. Default to False

Returns:

string of Euler angle definition

Return type:

string

cvHarmonicTemplate(cv, constant, center, tiWindows=0, tiForward=True, targetForceConstant=0, unit='namd')[source]

template for a harmonic restraint

Parameters:
  • cv (str) – name of the colvars

  • constant (float) – force constant of the restraint

  • center (float) – center of the restraint

  • tiWindows (int) – number of windows of the TI simulation (if runs a TI simulation). Defaults to 0.

  • tiForward (bool, optional) – whether the TI simulation is forward (if runs a TI simulation). Defaults to True.

  • targetForceConstant (int, optional) – targeted force constant of the restraint in TI simulation (if runs a TI simulation). Defaults to 0.

  • unit (str, optional) – unit, ‘namd’ or ‘gromacs’. Default to namd.

Returns:

string of the harmonic restraint definition

Return type:

str

cvHarmonicWallsTemplate(cv, lowerWall, upperWall, unit='namd')[source]

template of harmonic wall bias

Parameters:
  • cv (str) – name of the colvars

  • lowerWall (float) – lower wall of the bias

  • upperWall (float) – upper wall of the bias

  • unit (str, optional) – unit, ‘namd’ or ‘gromacs’. Default to namd.

Returns:

string of the harmonic wall bias definition

Return type:

str

cvHeadTemplate(indexFile, reweightAMD=False)[source]

return the head of colvars file

Parameters:
  • indexFile (str) – name of ndx file

  • reweightAMD (bool, optional) – if reweightAMD, there should be “smp off” in the head. Default to False.

Returns:

head of colvars file

Return type:

str

cvHistogramTemplate(cv)[source]

template for outputting the histogram of the CV

Parameters:

cv (str) – name of the colvars

Returns:

string of the histogram definition

Return type:

str

cvLambdaTemplate(bins)[source]

lambda CV template for WTM-lambdaABF

Parameters:

bins (int) – number of bins for the CV

Returns:

string of lambda definition

Return type:

str

cvPolarAngleTemplate(setBoundary, lowerBoundary, upperBoundary, angle, refFile, extendedLagrangian=True, reflectingBoundary=False)[source]

Polar angle template

Parameters:
  • setBoundary (bool) – whether set boundary (for free-energy calculation)

  • lowerBoundary (float) – lower boundary of free-energy calculaton

  • upperboundary (float) – upper boundary of free-energy calculation

  • angle (str) – ‘polarTheta’ or ‘polarPhi’

  • refFile (str) – path to the reference file

  • extendedLagrangian (bool, optional) – Whether extended Lagrangian is added. Default to True

  • reflectingBoundary (bool, optional) – Whether use reflecting boundaries, requires setBoundary on. Default to False

Returns:

string of polar angle definition

Return type:

str

cvProteinTemplate(centerCoor, refFile, unit='namd')[source]

the template of restraining the protein

Parameters:
  • centerCoor (np.array, 3) – (x,y,z), center of the protein

  • refFile (str) – path of the reference file

  • unit (str, optional) – unit, ‘namd’ or ‘gromacs’. Default to namd.

Returns:

string of the restraining the protein

Return type:

str

cvRMSDTemplate(setBoundary, lowerBoundary, upperBoundary, refFile, extendedLagrangian=True, reflectingBoundary=False, unit='namd')[source]

RMSD CV template

Parameters:
  • setBoundary (bool) – whether set boundary (for free-energy calculation)

  • lowerBoundary (float) – lower boundary of free-energy calculaton

  • upperboundary (float) – upper boundary of free-energy calculation

  • refFile (str) – path to the reference file

  • extendedLagrangian (bool, optional) – Whether extended Lagrangian is added. Default to True

  • reflectingBoundary (bool, optional) – Whether use reflecting boundaries, requires setBoundary on. Default to False

  • unit (str, optional) – unit, ‘namd’ or ‘gromacs’. Default to namd.

Returns:

string of RMSD definition

Return type:

str

cvRTemplate(setBoundary, lowerBoundary, upperBoundary, extendedLagrangian=True, reflectingBoundary=False, unit='namd')[source]

r distance template

Parameters:
  • setBoundary (bool) – whether set boundary (for free-energy calculation)

  • lowerBoundary (float) – lower boundary of free-energy calculaton

  • upperboundary (float) – upper boundary of free-energy

  • extendedLagrangian (bool, optional) – Whether extended Lagrangian is added. Default to True

  • reflectingBoundary (bool, optional) – Whether use reflecting boundaries, requires setBoundary on. Default to False

  • unit (str, optional) – unit, ‘namd’ or ‘gromacs’. Default to namd.

Returns:

string of distance r definition

Return type:

str

cvReweightAMDTemplate(cv)[source]

template for reweight aMD results

Parameters:

cv (str) – name of the colvars

Returns:

string of the reweightamd definition

Return type:

str

gromacsConfigTemplate(forceFieldType, temperature, numSteps, membraneProtein=False, generateVelocities=True)[source]

the gromacs config file template

Parameters:
  • forceFieldType (str) – ‘charmm’ or ‘amber’

  • temperature (float) – temperature of the simulation

  • numSteps (int) – number of steps of the simulation

  • membraneProtein (bool, optional) – whether simulating a membrame protein. Defaults to False.

  • generateVelocities (bool, optional) – whether generate velocities. Defaults to True.

Returns:

a Gromacs config string if succeed, and empty string otherwise

Return type:

str

gromacsMinimizeConfigTemplate()[source]

the gromacs config file template for minimization

Returns:

a Gromacs config string if succeed, and empty string otherwise

Return type:

str

namdConfigTemplate(forceFieldType, forceFieldFiles, topFile, coorFile, NAMDRestartCoor, NAMDRestartVel, NAMDRestartXsc, PBCCondition, outputPrefix, temperature, numSteps, cvFile='', cvDefinitionFile='', CVRestartFile='', fepFile='', fepWindowNum=20, fepForward=True, fepDoubleWide=False, fepMinBeforeSample=False, membraneProtein=False, OPLSMixingRule=False, GaWTM=False, CUDASOAIntegrator=False, timestep=2.0, LDDMStep1=False, lambdaABF=False)[source]

the namd config file template

Parameters:
  • forceFieldType (str) – ‘charmm’ or ‘amber’

  • forceFieldFiles (list of str) – name of charmm force field files

  • topFile (str) – name of the topology file (psf, parm)

  • coorFile (str) – name of the coordinate file (pdb, rst)

  • NAMDRestartCoor (str) – name of namd binary restart coor file (if restart from a previous simulation)

  • NAMDRestartVel (str) – name of namd binary restart vel file

  • NAMDRestartXsc (str) – name of namd restart xsc file

  • PBCCondition (np.array, 2*3) – PBC vector, ((lengthX, lengthY, lengthZ),(centerX, centerY, centerZ))

  • outputPrefix (str) – prefix of output file

  • temperature (float) – temperature of the simulation

  • numSteps (int) – number of steps of the simulation

  • cvFile (str) – name of Colvars file. Defaults to ‘’.

  • cvDefinitionFile (str, optional) – name of a TCL file defining new CVs. Defaults to ‘’.

  • CVRestartFile (str, optional) – name of Colvars restart file. Defaults to ‘’.

  • fepFile (str, optional) – name of fep file, indicating which atoms will be generated/removed (if run alchemical simulation). Defaults to ‘’.

  • fepWindowNum (int, optional) – number of fep windows. Defaults to 20.

  • fepForward (bool, optional) – whether this is a forward fep simulation. Defaults to True.

  • fepDoubleWide (bool, optional) – whether this is a double-wide fep simulation. Defaults to False.

  • fepMinBeforeSample (bool, optional) – whether do minimization before sampling in each FEP window. Defaults to False.

  • membraneProtein (bool, optional) – whether simulating a membrame protein. Defaults to False.

  • OPLSMixingRule (bool, optional) – whether use the OPLS mixing rules. Defaults to False.

  • GaWTM (bool, optional) – Whether this is an GaWTM-eABF simulation. Default to False

  • CUDASOAIntegrator (bool, optional) – Whether CUDASOA integrator is used. Default to False

  • timestep (float, optional) – timestep of the simulation. Default to 2.0

  • LDDMStep1 (bool, optional) – whether this is the 1st step of a LDDM simulation. Default to False.

  • lambdaABF (bool, optional) – whether use WTM-lambdaABF. This option is incompatible with FEP. Default to False.

Returns:

a NAMD config string if succeed, and empty string otherwise

Return type:

str

newCvEulerAngleTemplate(setBoundary, lowerBoundary, upperBoundary, angle, refFile, extendedLagrangian=True, reflectingBoundary=False)[source]

new definition Euler angle template, probably the pinning down the protein is not required

Parameters:
  • setBoundary (bool) – whether set boundary (for free-energy calculation)

  • lowerBoundary (float) – lower boundary of free-energy calculaton

  • upperboundary (float) – upper boundary of free-energy calculation

  • angle (str) – ‘eulerTheta’, ‘eulerPhi’ of ‘eulerPsi’

  • refFile (str) – path to the reference file

  • extendedLagrangian (bool, optional) – Whether extended Lagrangian is added. Default to True

  • reflectingBoundary (bool, optional) – Whether use reflecting boundaries, requires setBoundary on. Default to False

Returns:

string of Euler angle definition

Return type:

string

newCvPolarAngleTemplate(setBoundary, lowerBoundary, upperBoundary, angle, refFile, extendedLagrangian=True, reflectingBoundary=False)[source]

new definition of Polar angle template, probably the pinning down the protein is not required

Parameters:
  • setBoundary (bool) – whether set boundary (for free-energy calculation)

  • lowerBoundary (float) – lower boundary of free-energy calculaton

  • upperboundary (float) – upper boundary of free-energy calculation

  • angle (str) – ‘polarTheta’ or ‘polarPhi’

  • refFile (str) – path to the reference file

  • extendedLagrangian (bool, optional) – Whether extended Lagrangian is added. Default to True

  • reflectingBoundary (bool, optional) – Whether use reflecting boundaries, requires setBoundary on. Default to False

Returns:

string of polar angle definition

Return type:

str

BFEE2.templates_namd.scriptTemplate

BFEE2.templates_namd.scriptTemplate.charmmToGromacsTemplate(inputPrefix, forceFieldList)[source]

BFEE2.templates_namd.updateCenters

BFEE2.templates_namd.updateCenters.changeABFRange(filename, CVs, newCenters, originalCenters)[source]

change lowerboundary, upperboundary, lowerWalls, upperWalls of ABF in a *.in file

Parameters:
  • filename (str) – a Colvars config file

  • CVs (List[str]) – a list, showing the corresponding options of which CV blocks are to be replaced

  • newCenters (List[float]) – a list, containing the new values of Centers of these CVs

  • originalCenters (List[float]) – a list, containing the original values of Centers of these CVs

BFEE2.templates_namd.updateCenters.changeCenters(filename, CVs, newCenters)[source]

change Centers of harmonic restraints in a *.in file

Parameters:
  • filename (str) – a Colvars config file

  • CVs (List[str]) – a list, showing the Centers of which harmonic blocks are to be replaced

  • newCenters (List[float]) – a list, containing the new values of Centers

BFEE2.templates_namd.updateCenters.findOptimalCVs()[source]
read *.dat files generated through equilibration

and find out the most probable values of CVs

Returns:

the most probable values of RMSD, eulerTheta, eulerPhi, eulerPsi, polarTheta, polarPhi, r

Return type:

list[Float]

BFEE2.templates_namd.updateCenters.isGeometric()[source]
Check the route of the simulation, True for geometric,

False for alchemical.

Returns:

the route of the free-energy calculation. True for geometric,

False for alchemical

Return type:

bool

BFEE2.templates_namd.updateCenters.parseDat(filename)[source]

Parse a dat (histogram) file and return the most probable CV value

Parameters:

filename (str) – the dat file to be parsed with

Returns:

the most probable CV value

Return type:

float

BFEE2.templates_namd.updateCenters.readCenters(filename, CVs)[source]

find the value of centers of provided CVs in a *.in file

Parameters:
  • filename (str) – a Colvars config file

  • CVs (List[str]) – a list, showing the CVs whose centers are to be get

Returns:

centers of the provided CVs

Return type:

List[float]

BFEE2.templates_namd.updateCenters.updateAlchemicalFiles()[source]

Update the Centers of *.in files based on equilibration

BFEE2.templates_namd.updateCenters.updateGeometricFiles()[source]

Update the Centers of *.in files based on equilibration