spawning Package

densitycalculator Module

class AdaptivePELE.spawning.densitycalculator.ContinuousDensityCalculator[source]

Bases: AdaptivePELE.spawning.densitycalculator.DensityCalculator

calculate(contacts, contactThreshold)[source]

Calcuate the density value according to the contact ratio

Parameters
  • contacts (float) – Contacts ratio

  • contactThreshold (float) – Deprecated parameter

Returns

float – Density value for the value of the contacts ratio

class AdaptivePELE.spawning.densitycalculator.DensityCalculator[source]

Bases: object

abstract calculate(contacts, contactThreshold)[source]
class AdaptivePELE.spawning.densitycalculator.DensityCalculatorBuilder[source]

Bases: object

build(spawningBlock)[source]

Build the DensityCalculator object according to the parameters selcted

Parameters

spawningBlock (dict) – Spawning block of the control file

Returns

DensityCalculator – DensityCalculator object selected

class AdaptivePELE.spawning.densitycalculator.DensityCalculatorHeaviside(conditions=None, values=None)[source]

Bases: AdaptivePELE.spawning.densitycalculator.DensityCalculator

calculate(contacts, contactThreshold)[source]

Calcuate the density value according to the contact ratio

Parameters
  • contacts (float) – Contacts ratio

  • contactThreshold (float) – Deprecated parameter

Returns

float – Density value for the value of the contacts ratio

class AdaptivePELE.spawning.densitycalculator.ExitContinousDensityCalculator[source]

Bases: AdaptivePELE.spawning.densitycalculator.DensityCalculator

calculate(contacts, contactThreshold)[source]
class AdaptivePELE.spawning.densitycalculator.NullDensityCalculator[source]

Bases: AdaptivePELE.spawning.densitycalculator.DensityCalculator

calculate(contacts, contactThreshold)[source]

Calcuate the density value according to the contact ratio, in this case is always one

Parameters
  • contacts (float) – Contacts ratio

  • contactThreshold (float) – Deprecated parameter

Returns

float – Density value for the value of the contacts ratio

AdaptivePELE.spawning.densitycalculator.continousDensity(contacts)[source]

densitycalculatortypes Module

class AdaptivePELE.spawning.densitycalculatortypes.DENSITY_CALCULATOR_TYPES[source]

Bases: object

continuous = 2
exitContinous = 3
heaviside = 1
null = 0

spawning Module

class AdaptivePELE.spawning.spawning.DensitySpawningCalculator(densityCalculator=<AdaptivePELE.spawning.densitycalculator.NullDensityCalculator object>)[source]

Bases: AdaptivePELE.spawning.spawning.SpawningCalculator

Subclass of Spawning calculator that ensures the definition of a density calculator.

calculateDensities(clusters)[source]

Calculate the densities of the clusters

Parameters

clusters (Clusters) – Existing clusters

Returns

np.Array – Array containing the density of the clusters

class AdaptivePELE.spawning.spawning.EpsilonDegeneracyCalculator(parameters, densityCalculator=<AdaptivePELE.spawning.densitycalculator.NullDensityCalculator object>)[source]

Bases: AdaptivePELE.spawning.spawning.DensitySpawningCalculator

It uses epsilon * numTraj trajectories proportional to their energy and the rest inversely proportional to each cluster’s population We only consider the nclusters with best metric

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

divideProcessorsMetricProportional(clusters, trajToDistribute)[source]

Distribute the trajectories among the clusters according to their metric.

Parameters
  • clusters (Clusters) – Existing clusters

  • weights (np.Array) – Weight of each cluster

  • trajToDistribute (int) – Number of processors to distribute

Returns

list – List with the number of processors allocated to each cluster

log()[source]

Log spawning information

class AdaptivePELE.spawning.spawning.FASTDegeneracyCalculator(parameters, densityCalculator=<AdaptivePELE.spawning.densitycalculator.NullDensityCalculator object>)[source]

Bases: AdaptivePELE.spawning.spawning.DensitySpawningCalculator

calculate(clusters, trajToDivide, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

calculateNormalisedMetrics(clusters)[source]
calculateNormalisedSizes(clusters)[source]
log()[source]

Log spawning information

normaliseArray(array)[source]
class AdaptivePELE.spawning.spawning.IndependentMSMCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.MSMCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

writeSpawningInitialStructures(outputPathConstants, degeneracyOfRepresentatives, clustering, iteration, topologies=None)[source]

Write last trajectory structure as initial one for the next iteration

Parameters
  • outputPathConstants (OutputPathConstants) – Output constants that depend on the path

  • degeneracyOfRepresentatives (list) – List with the degeneracy of each cluster (number of processors that will start from that state)

  • clustering (Clustering) – Clustering object

  • iteration (int) – Number of epoch

  • topology_file (str) – Topology file for non-pdb trajectories

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

Returns

int, list – number of processors, list with the snapshot from which the trajectories will start in the next iteration

class AdaptivePELE.spawning.spawning.IndependentMetricCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.SpawningCalculator

writeSpawningInitialStructures(outputPathConstants, degeneracyOfRepresentatives, clustering, iteration, topologies=None)[source]

Write last trajectory structure as initial one for the next iteration

Parameters
  • outputPathConstants (OutputPathConstants) – Output constants that depend on the path

  • degeneracyOfRepresentatives (list) – List with the degeneracy of each cluster (number of processors that will start from that state)

  • clustering (Clustering) – Clustering object

  • iteration (int) – Number of epoch

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

Returns

int, list – number of processors, list with the snapshot from which the trajectories will start in the next iteration

class AdaptivePELE.spawning.spawning.IndependentRunsCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.SpawningCalculator

writeSpawningInitialStructures(outputPathConstants, degeneracyOfRepresentatives, clustering, iteration, topologies=None)[source]

Write last trajectory structure as initial one for the next iteration

Parameters
  • outputPathConstants (OutputPathConstants) – Output constants that depend on the path

  • degeneracyOfRepresentatives (list) – List with the degeneracy of each cluster (number of processors that will start from that state)

  • clustering (Clustering) – Clustering object

  • iteration (int) – Number of epoch

  • topology_file (str) – Topology file for non-pdb trajectories

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

Returns

int, list – number of processors, list with the snapshot from which the trajectories will start in the next iteration

class AdaptivePELE.spawning.spawning.InverselyProportionalToPopulationCalculator(parameters, densityCalculator=<AdaptivePELE.spawning.densitycalculator.NullDensityCalculator object>)[source]

Bases: AdaptivePELE.spawning.spawning.DensitySpawningCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

log()[source]

Log spawning information

class AdaptivePELE.spawning.spawning.MSMCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.SpawningCalculator

calculatedG(clusters, outputPathConstants, currentEpoch)[source]

Calculate the ligand-binding dG from the estimated MSM

Parameters
  • clusters (np.ndarray) – Cluster centers

  • trajPath (str) – Path to the trajectories to analyse

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

  • currentEpoch (int) – Current iteration number

createPlots(outputPathConstants, currentEpoch, clustering)[source]

Create the plots to do a quick analysis of the MSM and dG calculation

Parameters
  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

  • currentEpoch (int) – Current iteration number

  • clustering – Existing clusters

estimateMSM(dtrajs, outputPathConstants, currentEpoch)[source]

Estimate and MSM using PyEMMA

Parameters
  • dtrajs (np.ndarray) – Discretized trajectories to estimate the Markov model

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

  • currentEpoch (int) – Current iteration number

Returns

object – Object containing the estimated MSM

getSASAvalues(clusters, outputPathConstants)[source]

Get the SASA value for each cluster from the report file

Parameters
  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

  • clusters (Clusters) – Existing clusters

class AdaptivePELE.spawning.spawning.MetastabilityMSMCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.MSMCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

class AdaptivePELE.spawning.spawning.NullSpawningCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.SpawningCalculator

calculate(clusters, trajToDivide, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters. In this particular class no spawning is performed, so this function just returns None

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

None

shouldWriteStructures()[source]
class AdaptivePELE.spawning.spawning.ProbabilityMSMCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.MSMCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

class AdaptivePELE.spawning.spawning.REAPCalculator(parameters, densityCalculator=<AdaptivePELE.spawning.densitycalculator.NullDensityCalculator object>)[source]

Bases: AdaptivePELE.spawning.spawning.DensitySpawningCalculator

Spawning following the Reinforcement learning based Adaptive samPling (REAP) (Shamsi et al., arXiv, Oct 2017), where the reward given by the exploration on several reaction coordinates is maximized

calculate(clusters, trajToDivide, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

log()[source]

Log spawning information

class AdaptivePELE.spawning.spawning.SameWeightDegeneracyCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.SpawningCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

log()[source]

Log spawning information

class AdaptivePELE.spawning.spawning.SimulatedAnnealingCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.SpawningCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

computeTemperature(epoch)[source]
log()[source]

Log spawning information

class AdaptivePELE.spawning.spawning.SpawningAlgorithmBuilder[source]

Bases: object

build(spawningBlock)[source]

Build the selected spawning calculator and spawning params objects

Parameters

spawningBlock (dict) – Block of the control file with the spawning parameters

Returns

SpawningCalculator, SpawningParams – SpawningCalculator and SpawningParams objects

class AdaptivePELE.spawning.spawning.SpawningBuilder[source]

Bases: object

buildSpawningCalculator(spawningBlock, spawningParams)[source]

Build the selected spawning calculator object

Parameters
  • spawningBlock (dict) – Block of the control file with the spawning parameters

  • spawningParams (SpawningParams) – Object containing the parameters of the spawning

Returns

SpawningCalculator – SpawningCalculator object

class AdaptivePELE.spawning.spawning.SpawningCalculator[source]

Bases: object

The purpose of this abstract class is to contain the behaviour of the different strategies for the spawning. Spawning is the way in which we split the different explorers at the begining of each epoch.

abstract calculate(clusters, trajToDivide, currentEpoch=None, outputPathConstants=None)[source]
abstract createPlots(outputPathConstants, currentEpoch, clusters)[source]

Create the plots to do a quick analysis of the MSM and dG calculation

Parameters
  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

  • currentEpoch (int) – Current iteration number

  • clusters (Clusters) – Existing clusters

divideInverselyProportionalToArray(array, trajToDistribute)[source]

Distribute the trajectories among the clusters inversely proportional to the values of an array.

Parameters
  • Array (np.Array) – Weight of each cluster

  • trajToDistribute (int) – Number of processors to distribute

Returns

list – List with the number of processors allocated to each cluster

divideProportionalToArray(array, trajToDistribute)[source]

Distribute the trajectories among the clusters according to the values of an array.

Parameters
  • Array (np.Array) – Weight of each cluster

  • trajToDistribute (int) – Number of processors to distribute

Returns

list – List with the number of processors allocated to each cluster

divideTrajAccordingToWeights(weights, trajToDistribute)[source]

Distribute the trajectories among the clusters according to their weight. Weights must be normalized (i.e. sum(weights) = 1)

Parameters
  • weights (np.Array) – Weight of each cluster

  • trajToDistribute (int) – Number of processors to distribute

Returns

list – List with the number of processors allocated to each cluster

getMetrics(clusters)[source]

Get the metric of the clusters

Parameters

clusters (Clusters) – Existing clusters

Returns

np.Array – Array containing the metric of the clusters

abstract log()[source]

Log spawning information

shouldWriteStructures()[source]
writeSpawningInitialStructures(outputPathConstants, degeneracyOfRepresentatives, clustering, iteration, topologies=None)[source]

Write initial structures for the next iteration

Parameters
  • outputPathConstants (OutputPathConstants) – Output constants that depend on the path

  • degeneracyOfRepresentatives (list) – List with the degeneracy of each cluster (number of processors that will start from that state)

  • clustering (Clustering) – Clustering object

  • iteration (int) – Number of epoch

  • topology_file (str) – Topology file for non-pdb trajectories

  • topology (list) – Topology like structure to write PDB from xtc files

Returns

int, list – number of processors, list with the snapshot from which the trajectories will start in the next iteration

class AdaptivePELE.spawning.spawning.SpawningParams[source]

Bases: object

buildSpawningParameters(spawningBlock)[source]

Build the selected spawning params objects

Parameters

spawningBlock (dict) – Block of the control file with the spawning parameters

Returns

SpawningParams – SpawningParams object

class AdaptivePELE.spawning.spawning.UCBCalculator(parameters, densityCalculator=<AdaptivePELE.spawning.densitycalculator.NullDensityCalculator object>)[source]

Bases: AdaptivePELE.spawning.spawning.DensitySpawningCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

log()[source]

Log spawning information

class AdaptivePELE.spawning.spawning.UncertaintyMSMCalculator(parameters)[source]

Bases: AdaptivePELE.spawning.spawning.MSMCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

calculate_q(counts, nclusters)[source]
class AdaptivePELE.spawning.spawning.VariableEpsilonDegeneracyCalculator(parameters, densityCalculator=<AdaptivePELE.spawning.densitycalculator.NullDensityCalculator object>)[source]

Bases: AdaptivePELE.spawning.spawning.DensitySpawningCalculator

calculate(clusters, trajToDistribute, currentEpoch=None, outputPathConstants=None)[source]

Calculate the degeneracy of the clusters

Parameters
  • clusters (Clusters) – Existing clusters

  • trajToDistribute (int) – Number of processors to distribute

  • currentEpoch (int) – Current iteration number

  • outputPathConstants (OutputPathConstants) – Contains outputPath-related constants

Returns

list – List containing the degeneracy of the clusters

calculateEpsilonValue(currentEpoch, clusters)[source]

Calculate variation of epsilon according to the selected parameters

Parameters
  • currentEpoch (int) – Current iteration number

  • clusters (Clusters) – Existing clusters

contactsVariation(clusters)[source]

Calculate the variation of epsilon according to the contacts ratio

Parameters

clusters (Clusters) – Existing clusters

linearVariation(currentEpoch)[source]

Calculate linear variation of epsilon with respect to the iteraetion

Parameters

currentEpoch (int) – Current iteration number

logVariableEpsilon(epsilon, epoch)[source]

Log spawning information

AdaptivePELE.spawning.spawning.calculateContactsVar(deltaR, epsMax)[source]

Calculate the variation of epsilon according to the contact ratio

Parameters
  • deltaR (float) – Change in contact ratio

  • epsMax (float) – Maximum value of epsilon

Returns

float – Epsilon variation

AdaptivePELE.spawning.spawning.getSizes(clusters)[source]

Get the size of the clusters

Parameters

clusters (Clusters) – Existing clusters

Returns

np.Array – Array containing the size of the clusters

AdaptivePELE.spawning.spawning.return_sign(i, m, n, r)[source]

Helper function, creates a three-piece step function

Parameters
  • i (int) – Value to compare

  • m (int) – Middle value

  • n (int) – Left extreme value

  • r (int) – Right extreme value

Returns

int – Three-piece sign

AdaptivePELE.spawning.spawning.reward(x, rews)[source]

spawningTypes Module

class AdaptivePELE.spawning.spawningTypes.EPSILON_VARIATION_TYPES[source]

Bases: object

contactsVariation = 1
linearVariation = 0
class AdaptivePELE.spawning.spawningTypes.SPAWNING_TYPES[source]

Bases: object

FAST = 4
IndependentMSMCalculator = 14
MetastabilityMSMCalculator = 12
ProbabilityMSMCalculator = 11
REAP = 8
UCB = 6
UncertaintyMSMCalculator = 13
epsilon = 2
independent = 7
independentMetric = 10
inverselyProportional = 1
null = 9
sameWeight = 0
simulatedAnnealing = 3
variableEpsilon = 5