simulation Package

simulationTypes Module

class AdaptivePELE.simulation.simulationTypes.EXITCONDITION_TYPE[source]

Bases: object

CLUSTERING = 2
METRIC = 0
METRICMULTIPLETRAJS = 1
class AdaptivePELE.simulation.simulationTypes.SIMULATION_TYPE[source]

Bases: object

MD = 1
PELE = 0
TEST = 2

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

checkAmbertools()[source]
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 constants

  • reportBaseFilename (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 processes

  • topology – 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

getResname()[source]

Return the value of the ligand name

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 simulation

  • epoch (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 constants

  • initialStructures (str) – Name of the initial structures to copy

  • topologies (Topology) – Topology object containing the set of topologies needed for the simulation

  • reportFileName (str) – Name of the report file

  • processManager (ProcessesManager) – Object to synchronize the possibly multiple processes

runTleap(TleapControlFile)[source]

Method that runs the Tleap software form Ambertools

Parameters

TleapControlFile (str) – Path to the Tleap.in file

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.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

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 constants

  • reportBaseFilename (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 processes

  • topologies (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

getClusteringInfo()[source]

Return information relevant for MSMClustering

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 simulation

  • epoch (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 constants

  • initialStructures (str) – Name of the initial structures to copy

  • topologies (Topology) – Topology object containing the set of topologies needed for the simulation

  • reportFileName (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.SimulationParameters[source]

Bases: object

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

getClusteringInfo()[source]

Return information relevant for MSMClustering

getNumReplicas()[source]

Return the number of replicas, only useful for MD simulations

getResname()[source]

Return the value of the ligand name

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 file

  • peleControlFileDictionary (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 simulation

  • epoch (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]
setZeroMapping()[source]

Set the processorsToClusterMapping to zero

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

updateMappingProcessors(mapping)[source]

Update the value of the processorsToClusterMapping, a list with the snapshot from which the trajectories will start in the next iteration

Parameters

mapping (list) – List with the snapshot from which the trajectories will start in the next iteration

writeMappingToDisk(epochDir)[source]

Write the processorsToClusterMapping to disk

Parameters

epochDir (str) – Name of the folder where to write the processorsToClusterMapping

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 constants

  • initialStructures (str) – Name of the initial structures to copy

  • topologies (Topology) – Topology object containing the set of topologies needed for the simulation

  • reportFileName (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]