simulation Package¶
simulationTypes
Module¶
simulationrunner
Module¶
-
class
AdaptivePELE.simulation.simulationrunner.
ClusteringExitCondition
(ntrajs)[source]¶ Bases:
object
-
checkExitCondition
(clustering)[source]¶ Iterate over all unchecked cluster and check if the exit condtion is met
- Parameters
clustering (
Clustering
) – Clustering object- Returns
bool – Returns True if the exit condition has been met
-
-
class
AdaptivePELE.simulation.simulationrunner.
ExitConditionBuilder
[source]¶ Bases:
object
-
build
(exitConditionBlock, templetizedControlFile, nProcessors)[source]¶ Build the selected exit condition object
- Parameters
exitConditionBlock (dict) – Block of the control file corresponding to the exit condition
- Returns
MetricExitCondition
– MetricExitCondition object selected
-
-
class
AdaptivePELE.simulation.simulationrunner.
MDSimulation
(parameters)[source]¶ Bases:
AdaptivePELE.simulation.simulationrunner.SimulationRunner
-
checkSimulationInterrupted
(epoch, outputpath, restart)[source]¶ Check wether the simulation was interrupted before finishing
- Parameters
epoch (int) – Epoch number
outputpath (str) – Simulation output path
restart (bool) – Whether to restart a previous simulation
- Returns
bool – True if the simulations where interrupted
-
cleanCheckpointFiles
(checkpointDir)[source]¶ Clean the restart files generated if the simulation was interrupted before finishing
- Parameters
checkpointDir (str) – Directory with the checkpoints
-
createMultipleComplexesFilenames
(numberOfSnapshots, tmpInitialStructuresTemplate, iteration, equilibration=False)[source]¶ Creates the string to substitute the complexes in the PELE control file
- Parameters
numberOfSnapshots (int) – Number of complexes to write
tmpInitialStructuresTemplate (str) – Template with the name of the initial strutctures
iteration (int) – Epoch number
equilibration (bool) – Flag to mark wether the complexes are part of an equilibration run
- Returns
str with the files to be used
-
equilibrate
(initialStructures, outputPathConstants, reportFilename, outputPath, resnames, reschain, resnum, processManager, topologies=None)[source]¶ Run short simulation to equilibrate the system. It will run one such simulation for every initial structure (some of the arguments are not needed, such as (reportFilename, outputPath and topology) but they are kept to follow the same structure has the Super class definition)
- Parameters
initialStructures (list of str) – Name of the initial structures to copy
outputPathConstants (
OutputPathConstants
) – Contains outputPath-related constantsreportBaseFilename (str) – Name of the file that contains the metrics of the snapshots to cluster
outputPath (str) – Path where trajectories are found
resnames (list) – Residue name of the ligands in the system pdb
reschain (str) – Chain name of the ligand in the system pdb
resnum (int) – Residue number of the ligand in the system pdb
processManager (
ProcessesManager
) – Object to synchronize the possibly multiple processestopology – Topology object
- Returns
list – List with initial structures
-
extractLigand
(PDBtoOpen, resname, outputpath, id_replica)[source]¶ Extracts the ligand from a given PDB
- Parameters
PDBtoOpen (str) – string with the pdb to prepare
resname (str) – resname of the ligand to extract
outputPath (str) – Path where the pdb is written
id_replica (int) – Id of the current replica
- Returns
str – string with the ligand pdb
-
getWorkingProcessors
()[source]¶ Return the number of working processors, i.e. number of trajectories
-
prepareLigand
(antechamberDict, parmchkDict)[source]¶ Runs antechamber and parmchk2 to obtain the mol2 and frcmod of the ligand
- Parameters
antechamberDict (dict) – Dictonary containing the parameters to substitute in the antechamber command
parmchkDict (dict) – Dictonary containing the parameters to substitute in the parmchk2 command
-
processTrajectories
(output_path, topology, epoch)[source]¶ Post-process the simulation trajectories, i.e. superpose to initial frame
- Parameters
output_path (str) – Path that contains the trajectories
topology (
Topology
) – Topology object for the simulationepoch (int) – Current epoch of the simulation
-
runSimulation
(epoch, outputPathConstants, initialStructuresAsString, topologies, reportFileName, processManager)[source]¶ Run a MD simulation using OpenMM
- Parameters
epoch (int) – number of the epoch
outputPathConstants (
OutputPathConstants
) – Contains outputPath-related constantsinitialStructures (str) – Name of the initial structures to copy
topologies (
Topology
) – Topology object containing the set of topologies needed for the simulationreportFileName (str) – Name of the report file
processManager (
ProcessesManager
) – Object to synchronize the possibly multiple processes
-
-
class
AdaptivePELE.simulation.simulationrunner.
MetricExitCondition
(metricCol, metricValue, condition)[source]¶ Bases:
object
-
checkExitCondition
(clustering)[source]¶ Iterate over all clusters and check if the exit condtion is met
- Parameters
clustering (
Clustering
) – Clustering object- Returns
bool – Returns True if the exit condition has been met
-
-
class
AdaptivePELE.simulation.simulationrunner.
MetricMultipleTrajsExitCondition
(metricCol, metricValue, condition, reportWildCard, numTrajs, nProcessors)[source]¶ Bases:
object
-
checkExitCondition
(outputFolder)[source]¶ Iterate over all reports and check if the exit condtion is met
- Parameters
clustering (
Clustering
) – Clustering object- Returns
bool – Returns True if the exit condition has been met
-
-
class
AdaptivePELE.simulation.simulationrunner.
PeleSimulation
(parameters)[source]¶ Bases:
AdaptivePELE.simulation.simulationrunner.SimulationRunner
-
calculateEquilibrationLength
()[source]¶ Calculate the number of steps for the equilibration lenght accoding to the available processors
-
clusterEquilibrationStructures
(resname, reschain, resnum, trajWildcard, reportWildcard, topology=None)[source]¶ Cluster the equilibration run
- Parameters
resname (str) – Residue name of the ligand in the system pdb
reschain (str) – Chain name of the ligand in the system pdb
resnum (int) – Residue number of the ligand in the system pdb
trajWildcard (str) – Templetized path to trajectory files”
reportWildcard (str) – Templetized path to report files”
topology (list) – Topology for non-pdb trajectories
- Returns
list – List with the pdb snapshots of the representatives structures
-
createMultipleComplexesFilenames
(numberOfSnapshots, tmpInitialStructuresTemplate, iteration, equilibration=False)[source]¶ Creates the string to substitute the complexes in the PELE control file
- Parameters
numberOfSnapshots (int) – Number of complexes to write
tmpInitialStructuresTemplate (str) – Template with the name of the initial strutctures
iteration (int) – Epoch number
equilibration (bool) – Flag to mark whether the complexes are part of an equilibration run
- Returns
str – jsonString to be substituted in PELE control file
-
createSymbolicLinks
()[source]¶ Create symbolic links to Data and Documents folder if they don’t exist
-
equilibrate
(initialStructures, outputPathConstants, reportFilename, outputPath, resname, reschain, resnum, processManager, topologies=None)[source]¶ Run short simulation to equilibrate the system. It will run one such simulation for every initial structure and select appropiate structures to start the simulation
- Parameters
initialStructures (list of str) – Name of the initial structures to copy
outputPathConstants (
OutputPathConstants
) – Contains outputPath-related constantsreportBaseFilename (str) – Name of the file that contains the metrics of the snapshots to cluster
outputPath (str) – Path where trajectories are found
resname (str) – Residue name of the ligand in the system pdb
reschain (str) – Chain name of the ligand in the system pdb
resnum (int) – Residue number of the ligand in the system pdb
processManager (
ProcessesManager
) – Object to synchronize the possibly multiple processestopologies (
Topology
) – Topology object containing the set of topologies needed for the simulation
- Returns
list – List with initial structures
-
generatePELECommand
(runningControlFile)[source]¶ Generate the command to run PELE using the given parameters
- Parameters
runningControlFile (str) – Path of the control file to run
-
getEquilibrationControlFile
(peleControlFileDict)[source]¶ Filter unnecessary parameters and return a minimal PELE control file for equilibration runs
- Parameters
peleControlFileDict (dict) – Dictionary with pele control file options
- Returns
dict – Dictionary with pele control file options
-
getMetricColumns
(JSONdict)[source]¶ Extract the column of a similarity distance (RMSD or distance) from the pele control file
- Parameters
JSONdict (dict) – Dictionary containing a parsed PELE control file
- Returns
int – Column index of the similarity metric
-
getNextIterationBox
(outputFolder, resname, reschain, resnum, topologies=None, epoch=None)[source]¶ Select the box for the next epoch, currently selecting the COM of the cluster with max SASA
- Parameters
outputFolder (str) – Folder to the trajectories
resname (str) – Residue name of the ligand in the system pdb
reschain (str) – Chain name of the ligand in the system pdb
resnum (int) – Residue number of the ligand in the system pdb
topologies (
Topology
) – Topology object containing the set of topologies needed for the simulationepoch (int) – Epoch of the trajectories to analyse
- Returns str
– string to be substitued in PELE control file
-
getWorkingProcessors
()[source]¶ Return the number of working processors, i.e. number of trajectories
-
runEquilibrationPELE
(runningControlFile)[source]¶ Run a short PELE equilibration simulation
- Parameters
runningControlFile (str) – Path of the control file to run
-
runSimulation
(epoch, outputPathConstants, initialStructuresAsString, topologies, reportFileName, processManager)[source]¶ Run a short PELE simulation
- Parameters
epoch (int) – number of the epoch
outputPathConstants (
OutputPathConstants
) – Contains outputPath-related constantsinitialStructures (str) – Name of the initial structures to copy
topologies (
Topology
) – Topology object containing the set of topologies needed for the simulationreportFileName (str) – Name of the report file
processManager (
ProcessesManager
) – Object to synchronize the possibly multiple processes
-
selectEquilibratedStructure
(nTrajs, similarityColumn, resname, reschain, resnum, trajWildcard, reportWildcard, topology=None)[source]¶ Select a representative initial structure from the equilibration run
- Parameters
nTrajs (int) – Number of trajectories
similarityColumn (int) – Column number of the similarity metric (RMSD or distance)
resname (str) – Residue name of the ligand in the system pdb
reschain (str) – Chain name of the ligand in the system pdb
resnum (int) – Residue number of the ligand in the system pdb
trajWildcard (str) – Templetized path to trajectory files”
reportWildcard (str) – Templetized path to report files”
topology (list) – Topology for non-pdb trajectories
- Returns
list – List with the pdb snapshots of the representatives structures
-
selectEquilibrationLastSnapshot
(nTrajs, trajWildcard, topology=None)[source]¶ Select the last snapshot of each trajectory as a representative initial structure from the equilibration run
- Parameters
nTrajs (int) – Number of trajectories
trajWildcard (str) – Templetized path to trajectory files”
topology (list) – Topology for non-pdb trajectories
- Returns
list – List with the pdb snapshots of the representatives structures
-
selectInitialBoxCenter
(initialStructuresAsString, resname, reschain, resnum)[source]¶ Select the coordinates of the first box, currently as the center of mass of the first initial structure provided
- Parameters
initialStructuresAsString (str) – String containing the files of the initial structures
resname (str) – Residue name of the ligand in the system pdb
reschain (str) – Chain name of the ligand in the system pdb
resnum (int) – Residue number of the ligand in the system pdb
- Returns str
– string to be substitued in PELE control file
-
-
class
AdaptivePELE.simulation.simulationrunner.
RunnerBuilder
[source]¶ Bases:
object
-
build
(simulationRunnerBlock)[source]¶ Build the selected SimulationRunner object
- Parameters
simulationRunnerBlock (dict) – Block of the control file corresponding to the simulation step
- Returns
SimulationRunner
– SimulationRunner object selected
-
-
class
AdaptivePELE.simulation.simulationrunner.
SimulationRunner
(parameters)[source]¶ Bases:
object
-
checkExitCondition
(clustering, outputFolder)[source]¶ Check if the exit condition has been met
- Parameters
clustering (
Clustering
) – Clustering object- Returns
bool – True if the exit condition is met
-
checkSimulationInterrupted
(epoch, outputpath, restart)[source]¶ Check wether the simulation was interrupted before finishing
- Parameters
epoch (int) – Epoch number
outputpath (str) – Simulation output path
restart (bool) – Whether to restart a previous simulation
- Returns
bool – True if the simulations where interrupted
-
cleanCheckpointFiles
(epoch)[source]¶ Clean the restart files generated if the simulation was interrupted before finishing
- Parameters
epoch (int) – Epoch number
-
createMultipleComplexesFilenames
(numberOfSnapshots, tmpInitialStructuresTemplate, iteration, equilibration=False)[source]¶ Creates the string to substitute the complexes in the PELE control file
- Parameters
numberOfSnapshots (int) – Number of complexes to write
tmpInitialStructuresTemplate (str) – Template with the name of the initial strutctures
iteration (int) – Epoch number
equilibration (bool) – Flag to mark wether the complexes are part of an equilibration run
- Returns
str – jsonString to be substituted in PELE control file
-
getWorkingProcessors
()[source]¶ Return the number of working processors, i.e. number of trajectories
-
hasExitCondition
()[source]¶ Check if an exit condition has been set
- Returns
bool – True if an exit condition is set
-
makeWorkingControlFile
(workingControlFilename, dictionary, inputTemplate=None)[source]¶ Substitute the values in the templetized control file
- Parameters
workingControlFilename (str) – Name of the template control file
dictionary (dict) – Dictonary containing the parameters to substitute in the control file
inputFileTemplate (str) – Template control file
-
prepareControlFile
(epoch, outputPathConstants, peleControlFileDictionary)[source]¶ Substitute the parameters in the PELE control file specified with the provided in the control file
- Parameters
epoch (int) – Epoch number
outputPathConstants (
OutputPathConstants
) – Object that has as attributes constant related to the outputPath that will be used to create the working control filepeleControlFileDictionary (dict) – Dictonary containing the values of the parameters to substitute in the control file
-
processTrajectories
(output_path, topology, epoch)[source]¶ Post-process the simulation trajectories, i.e. superpose to initial frame
- Parameters
output_path (str) – Path that contains the trajectories
topology (
Topology
) – Topology object for the simulationepoch (int) – Current epoch of the simulation
-
readMappingFromDisk
(epochDir)[source]¶ Read the processorsToClusterMapping from disk
- Parameters
epochDir (str) – Name of the folder where to write the processorsToClusterMapping
-
runSimulation
(epoch, outputPathConstants, initialStructuresAsString, topologies, reportFileName, processManager)[source]¶
-
unifyReportNames
(spawningReportName)[source]¶ Ensure that the reportName in the simulation parameters is the same as the one provided in the spawning parameters
- Parameters
spawningReportName (str) – Name of the report file provided in the spawning parameters
-
-
class
AdaptivePELE.simulation.simulationrunner.
TestSimulation
(parameters)[source]¶ Bases:
AdaptivePELE.simulation.simulationrunner.SimulationRunner
Class used for testing
-
getWorkingProcessors
()[source]¶ Return the number of working processors, i.e. number of trajectories
-
makeWorkingControlFile
(workingControlFilename, dictionary, inputTemplate=None)[source]¶ Substitute the values in the templetized control file
- Parameters
workingControlFilename (str) – Name of the template control file
dictionary (dict) – Dictonary containing the parameters to substitute in the control file
inputFileTemplate (str) – Template control file
-
runSimulation
(epoch, outputPathConstants, initialStructuresAsString, topologies, reportFileName, processManager)[source]¶ Copy file to test the rest of the AdaptivePELE procedure
- Parameters
epoch (int) – number of the epoch
outputPathConstants (
OutputPathConstants
) – Contains outputPath-related constantsinitialStructures (str) – Name of the initial structures to copy
topologies (
Topology
) – Topology object containing the set of topologies needed for the simulationreportFileName (str) – Name of the report file
processManager (
ProcessesManager
) – Object to synchronize the possibly multiple processes
-
-
AdaptivePELE.simulation.simulationrunner.
processTraj
(input_files)[source]¶ Align a single trajectory file (helper function for parallelization)
- Parameters
input_files (tuple) – Tuple with (trajectory_file, topology_file)
-
AdaptivePELE.simulation.simulationrunner.
processTraj_mdanalysis
(input_files)[source]¶ Align a single trajectory file (helper function for parallelization)
- Parameters
input_files (tuple) – Tuple with (trajectory_file, topology_file)
-
AdaptivePELE.simulation.simulationrunner.
processTraj_mdtraj
(input_files)[source]¶ Align a single trajectory file (helper function for parallelization)
- Parameters
input_files (tuple) – Tuple with (trajectory_file, topology_file)
-
AdaptivePELE.simulation.simulationrunner.
updateConstraints
(constraints_orig, constraints_map)[source]¶