BFEE2.commonTools
BFEE2.commonTools.commonSlots
- BFEE2.commonTools.commonSlots.openFileDialog(fileType, lineEdit)[source]
- return a openFile function that opens special type of files
the openFile dialog is connected with a lineEdit widget
- Parameters:
fileType (str) – the file type for opening
lineEdit (QLineEdit) – the QLineEdit that connects to the QFileDialog
- Returns:
slot function opening special type of files
- Return type:
function obj
- BFEE2.commonTools.commonSlots.openFilesDialog(fileType, listWidget)[source]
- return a openFile function that opens a series of files
the openFile dialog is connected with a QListWidget
- Parameters:
fileType (str) – the file type for opening
listWidget (QListWidget) – the QListWidget that connects to the QFileDialog
- Returns:
slot function opening a series of files
- Return type:
function obj
BFEE2.commonTools.fileParser
- BFEE2.commonTools.fileParser.amberToGromacs(parmFile, rstFile, PBC, outputPrefix)[source]
convert a set of Amber files (parm7 + rst7) into the Gromacs format
- Parameters:
parmFile (str) – path of the parm7 file
rstFile (str) – path of the rst7 file
PBC (list of flost) – pbc information
outputPrefix (str) – path + prefix of the output file
- BFEE2.commonTools.fileParser.charmmToGromacs(psfFile, pdbFile, prmFiles, PBC, outputPrefix)[source]
convert a set of CHARMM files (psf + pdb + prm + pbc) into the Gromacs format
- Parameters:
psfFile (str) – path of the psf file
pdbFile (str) – path of the pdb file
prmFiles (list of str) – pathes of the prm files
PBC (list of flost) – pbc information
outputPrefix (str) – path + prefix of the output file
- class BFEE2.commonTools.fileParser.fileParser(topFile, coorFile='')[source]
Bases:
objecttopology and coordinate parser, this class implements basic method for the topology and coordinate file, used by BFEE
- centerSystem()[source]
move all the atoms in the loaded file, such that the center of system be (0,0,0)
- getResid(selection)[source]
- return a string listing the resid of the selection
may be used to generate amber masks
- Parameters:
selection (str) – MDAnalysis selection
- Raises:
SelectionError – if the selection corresponds to nothing
- Returns:
a list of resid, e.g. (4,5,6,7,8,9,10)
- Return type:
str
- measureCenter(selection)[source]
mimic vmd measure center
- Parameters:
selection (str) – selection of atoms
- Raises:
SelectionError – if the selection corresponds to nothing
- Returns:
(x, y, z)
- Return type:
np.array (3, float)
- measureDistance(selection1, selection2)[source]
- measure the distance between the center of mass
of two atom groups
- Parameters:
selection1 (str) – selection of atom group 1
selection2 (str) – selection of atom group 2
- Returns:
distance between the center of mass of the two atom groups
- Return type:
float
- measureMinmax(selection)[source]
mimic VMD measure minmax
- Parameters:
selection (str) – selection of atoms
- Raises:
SelectionError – if the selection corresponds to nothing
- Returns:
((minX, minY, minZ), (maxX, maxY, maxZ))
- Return type:
np.array (2*3, float)
- measurePBC()[source]
measure periodic boundary condition of the file
- Returns:
((lengthX, lengthY, lengthZ), (centerX, centerY, centerZ))
- Return type:
np.array (2*3, float)
- measurePolarAngles(selectionPro, selectionLig)[source]
calculation the polar angles based on selectionPro and selectionLig
- Parameters:
selectionPro (str) – selection of the host molecule
selectionLig (str) – selection of the ligand molecule
- Returns:
(theta, phi) in degrees
- Return type:
np.array (2, float)
- moveSystem(moveVector)[source]
move all the atoms in the loaded file
- Parameters:
moveVector (np.array, 3, float) – the vector of moving
- rotateSystem(axis, degrees)[source]
rotate all the atoms in the loaded file
- Parameters:
axis (str) – ‘x’ or ‘y’ or ‘z’
degrees (float) – degrees to move by
- saveFile(selection, targetPath, targetType, saveTop=False, topPath='')[source]
- save the coordinate file to the target type
this function cannot really ‘save’ the topology file, it can only copy the original topology to the target path
- Parameters:
selection (str) – selection of atoms to save
targetPath (str) – path for the coor file to be saved
targetType (str) – type of the coor file (pdb, xyz)
saveTop (bool) – whether the topology file will be saved. Defaults to False.
topPath (str, optional) – path for the topology file to be saved. Defaults to ‘’.
- Raises:
SelectionError – if the selection corresponds to nothing
- saveNDX(selections, names, targetPath, nonHydrogen=True)[source]
save an ndx file, including the selections
- Parameters:
selections (list of str) – the selections for the ndx file
names (list of str) – the name in ndx of each selection
targetPath (str) – path for the file to be saved
nonHydrogen (bool, optional) – whether only non-H atoms are considered. Defaults to True.
- Raises:
SelectionError – if the selection corresponds to nothing
- setBeta(selection, beta)[source]
set beta for the selected atoms
- Parameters:
selection (str) – selection of atoms to change beta
beta (int) – beta value
- Raises:
SelectionError – if the selection corresponds to nothing
- BFEE2.commonTools.fileParser.gromacsToAmber(topFile, groFile, PBC, outputPrefix)[source]
convert a set of Gromacs files (top + gro/pdb) into the Amber format
- Parameters:
topFile (str) – path of the top file
groFile (str) – path of the gro file
PBC (list of flost) – pbc information
outputPrefix (str) – path + prefix of the output file
BFEE2.commonTools.ploter
- BFEE2.commonTools.ploter.calcRMSD(inputArray)[source]
calculate RMSD of a np.array with respect to (0,0,0,…0)
- Parameters:
inputArray (1D np.array) – the input array
- Returns:
RMSD of a np.array with respect to (0,0,0,…0)
- Return type:
float
- BFEE2.commonTools.ploter.correctGaWTM(pmfFile, correctionFile=None)[source]
read a 1D namd PMF file and correct it using cumulant.pmf file
- Parameters:
pmfFile (str) – path to the pmf File
correctionFile (str, optional) – path to the correction file. If None, will try to find it in the same directory (legacy behavior).
- Returns:
1D PMF
- Return type:
np.array (N*2)
- BFEE2.commonTools.ploter.correctGaWTMHist(histPmfFile, correctionFile, is_hist_correction=True)[source]
Apply GaWTM correction to a History PMF file.
- Parameters:
histPmfFile (str) – path to the history PMF file (.hist.czar.pmf)
correctionFile (str) – path to the correction file
is_hist_correction (bool) – True if correction file is history format (.hist.pmf), False if single-frame format (.pmf)
- Returns:
list of corrected PMF frames
- Return type:
list[np.array]
- BFEE2.commonTools.ploter.getGaWTMBaseName(filePath)[source]
Extract the base name from a GaWTM PMF file or its correction file.
- For example:
‘path/to/001.czar.pmf’ -> ‘001’ ‘path/to/001.reweightamd1.cumulant.pmf’ -> ‘001’ ‘path/to/step1.czar.pmf’ -> ‘step1’
- Parameters:
filePath (str) – path to the file
- Returns:
base name of the file (without extensions)
- Return type:
str
- BFEE2.commonTools.ploter.getGaWTMBaseNames(filePath)[source]
Extract all possible base names from a GaWTM PMF file for flexible matching.
This function returns a list of candidate base names to support flexible pairing. For example:
'path/to/abf_1.abf1.czar.pmf' -> ['abf_1.abf1', 'abf_1'] 'path/to/001.czar.pmf' -> ['001'] 'path/to/step1.abf2.czar.pmf' -> ['step1.abf2', 'step1']
- Parameters:
filePath (str) – path to the file
- Returns:
list of possible base names (primary first, then alternatives)
- Return type:
list[str]
- BFEE2.commonTools.ploter.getGaWTMHistBaseName(filePath)[source]
Extract the base name from a GaWTM History PMF file or its correction file.
- For example:
‘path/to/001.hist.czar.pmf’ -> ‘001’ ‘path/to/001.reweightamd1.cumulant.hist.pmf’ -> ‘001’ ‘path/to/001.reweightamd1.cumulant.pmf’ -> ‘001’ ‘path/to/step1.hist.czar.pmf’ -> ‘step1’
- Parameters:
filePath (str) – path to the file
- Returns:
base name of the file (without extensions)
- Return type:
str
- BFEE2.commonTools.ploter.getGaWTMHistBaseNames(filePath)[source]
Extract all possible base names from a GaWTM History PMF file for flexible matching.
This function returns a list of candidate base names to support flexible pairing. For example:
'path/to/abf_1.abf1.hist.czar.pmf' -> ['abf_1.abf1', 'abf_1'] 'path/to/001.hist.czar.pmf' -> ['001']
- Parameters:
filePath (str) – path to the file
- Returns:
list of possible base names (primary first, then alternatives)
- Return type:
list[str]
- BFEE2.commonTools.ploter.interpolateHistPMFFrames(all_hist_pmfs, target_num_frames)[source]
Interpolate history PMF frames to a target number of frames.
Each PMF file may have different number of frames. This function interpolates the frame values to achieve a uniform frame count across all files.
- Parameters:
all_hist_pmfs (list[list[np.array]]) – list of history PMFs, each is a list of frames
target_num_frames (int) – target number of frames to interpolate to
- Returns:
interpolated history PMFs with uniform frame count
- Return type:
list[list[np.array]]
- BFEE2.commonTools.ploter.isGaWTM(pmfFiles)[source]
determine whether the input PMFs indicate Ga-WTM simulations
- Parameters:
pmfFiles (list[str]) – path to a set of PMFs (and pmf corrections)
- Returns:
GaWTM simulation or not
- Return type:
bool
- BFEE2.commonTools.ploter.isGaWTMHist(pmfFiles)[source]
determine whether the input History PMFs indicate Ga-WTM simulations
- Parameters:
pmfFiles (list[str]) – path to a set of History PMFs (and pmf corrections)
- Returns:
GaWTM simulation or not
- Return type:
bool
- BFEE2.commonTools.ploter.mergeHistPMF(all_hist_pmfs)[source]
Merge multiple history PMF files frame-by-frame.
Each input is a list of frames (from different PMF windows). The function first interpolates all to have the same number of frames, then merges each frame using the standard mergePMF function.
- Parameters:
all_hist_pmfs (list[list[np.array]]) – list of history PMFs, each is a list of frames from one window
- Returns:
merged history PMF (list of merged frames)
- Return type:
list[np.array]
- BFEE2.commonTools.ploter.mergePMF(pmfFiles)[source]
merge several PMF files
- Parameters:
pmfFiles (list of np.arrays) – list of 1D pmfs
- Returns:
merged PMF if the PMFs overlap, pmfFiles[0] otherwise
- Return type:
np.array (N*2)
- BFEE2.commonTools.ploter.pairGaWTMFiles(pmfFiles)[source]
Pair GaWTM PMF files with their corresponding correction files.
This function looks for files with matching base names: - xxx.czar.pmf paired with xxx.reweightamd1.cumulant.pmf
Files without a corresponding correction file are returned as unpaired. Orphan correction files (without matching czar.pmf) are also returned separately. Wrong correction files (.reweightamd1.reweight.pmf instead of .cumulant.pmf) are also detected.
- Parameters:
pmfFiles (list[str]) – list of all PMF file paths (including correction files)
- Returns:
- (paired_list, unpaired_czar_list, orphan_correction_list, other_files, wrong_correction_files)
paired_list: list of tuples (pmf_file_path, correction_file_path) unpaired_czar_list: list of czar.pmf file paths without correction orphan_correction_list: list of correction file paths without matching czar.pmf other_files: list of other PMF files wrong_correction_files: list of .reweightamd1.reweight.pmf files (wrong type)
- Return type:
tuple
- BFEE2.commonTools.ploter.pairGaWTMHistFiles(pmfFiles)[source]
Pair GaWTM History PMF files with their corresponding correction files.
This function looks for files with matching base names: - xxx.hist.czar.pmf paired with xxx.reweightamd1.cumulant.hist.pmf or xxx.reweightamd1.cumulant.pmf
Files without a corresponding correction file are returned as unpaired. Orphan correction files (without matching hist.czar.pmf) are also returned separately. Wrong correction files (.reweightamd1.reweight.pmf instead of .cumulant.pmf) are also detected.
- Parameters:
pmfFiles (list[str]) – list of all History PMF file paths (including correction files)
- Returns:
(paired_list, unpaired_czar_list, orphan_correction_list, other_files, wrong_correction_files)
paired_listis a list of tuples(pmf_file_path, correction_file_path, is_hist_correction).is_hist_correctionis True if correction is .hist.pmf and False if it is a single-frame .pmf. Other returned lists contain unpaired hist.czar.pmf files, orphan correction files, other PMF files, and wrong .reweightamd1.reweight.pmf correction files.- Return type:
tuple
- BFEE2.commonTools.ploter.parseHistFile(histPath)[source]
parse a hist.czar.pmf file and return frame-RMSD list
- Parameters:
histPath (str) – path to a hist.czar.pmf file
- Returns:
time evolution of RMSD with respect to zero array
- Return type:
1D np.array
- BFEE2.commonTools.ploter.plotConvergence(rmsdList)[source]
plot the time evolution of PMF rmsd
- Parameters:
rmsdList (list or 1D np.array, float) – time evolution of RMSD with respect to zero array
- BFEE2.commonTools.ploter.plotHysteresis(forwardProfile, backwardProfile)[source]
- plot the profile describing the hysteresis between forward and backward
simulations
- Parameters:
forwardProfile (np.array, N*2) – forward free-energy profile to be plotted
backwardProfile (np.array, N*2) – backward free-energy profile to be plotted
- BFEE2.commonTools.ploter.plotPMF(pmf)[source]
plot a pmf
- Parameters:
pmf (np.array, N*2) – pmf to be plotted
- BFEE2.commonTools.ploter.readFrame(input)[source]
read a frame of Colvars hist file and calculate its RMSD with respect to zero array
- Parameters:
input (python file object) – input object
- Returns:
RMSD with respect to zero array
- Return type:
float
- BFEE2.commonTools.ploter.readHistPMF(histPmfFile)[source]
Read a History PMF file and return a list of PMF frames.
Each frame is a 2D numpy array with shape (N, 2) where N is the number of points.
- Parameters:
histPmfFile (str) – path to the history PMF file
- Returns:
list of PMF frames, each as (N, 2) array
- Return type:
list[np.array]
- BFEE2.commonTools.ploter.readPMF(pmfFile)[source]
read a 1D namd PMF file
- Parameters:
pmfFile (str) – path to the pmf File
- Returns:
1D PMF
- Return type:
np.array (N*2)
- BFEE2.commonTools.ploter.saveConvergence(rmsdList, filePath)[source]
save the PMF RMSD convergence data to a text file
- Parameters:
rmsdList (list or 1D np.array, float) – time evolution of RMSD with respect to zero array
filePath (str) – path to save the data file
- BFEE2.commonTools.ploter.saveHysteresis(forwardProfile, backwardProfile, filePath)[source]
save the hysteresis data to a text file
- Parameters:
forwardProfile (np.array, N*2) – forward free-energy profile data
backwardProfile (np.array, N*2) – backward free-energy profile data
filePath (str) – path to save the data file