utilities Package

clusteringUtilities Module

AdaptivePELE.utilities.clusteringUtilities.writeStructures(clusteringObject, listStructures, checker=<function <lambda>>, outputPath='cluster.pdb')[source]

Print all clusters in listStructures that meet the condition specified by the checker

Parameters
  • clusteringObject (Clustering) – Clustering object with clusters to print

  • checker (function) – Lambda function with the checker that should evaluate to True for intersted structures

  • outputPath (str) – Output cluster pdb filename

utilities Module

class AdaptivePELE.utilities.utilities.Topology(path)[source]

Bases: object

Container object that points to the topology used in each trajectory

cleanTopologies()[source]

Remove the written topology files

getTopology(epoch, trajectory_number)[source]

Get the topology for a particular epoch and trajectory number

Parameters
  • epoch (int) – Epoch of the trajectory of interest

  • trajectory_number (int) – Number of the trajectory to select

Returns

list – List with topology information

getTopologyFile(epoch, trajectory_number)[source]

Get the topology file for a particular epoch and trajectory number

Parameters
  • epoch (int) – Epoch of the trajectory of interest

  • trajectory_number (int) – Number of the trajectory to select

Returns

str – Path to the topology file

getTopologyFromIndex(index)[source]

Get the topology for a particular index

Parameters

index (int) – Index of the trajectory of interest

Returns

list – List with topology information

getTopologyIndex(epoch, trajectory_number)[source]

Get the topology index for a particular epoch and trajectory number

Parameters
  • epoch (int) – Epoch of the trajectory of interest

  • trajectory_number (int) – Number of the trajectory to select

Returns

int – Index of the corresponding topology

mapEpochTopologies(epoch, trajectoryMapping)[source]

Map the trajectories for the next epoch and the used topologies

Parameters
  • epoch (int) – Epoch of the trajectory selected

  • trajectoryMapping (list) – Mapping of the trajectories and the corresponding topologies

readMappingFromDisk(epochDir, epoch)[source]

Read the processorsToClusterMapping from disk

Parameters

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

setTopologies(topologyFiles, cleanFiles=True)[source]

Set the topologies for the simulation. If topologies were set before they are deleted and set again

Parameters
  • topologyFiles (list) – List of topology files

  • cleanFiles (bool) – Flag wether to remove previous files

topologyFilesIterator()[source]
writeMappingToDisk(epochDir, epoch)[source]

Write the topology mapping to disk

Parameters

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

writeTopologyObject()[source]

Dump the contents of the topology object using pickle

class AdaptivePELE.utilities.utilities.TopologyCompat(pdb_file)[source]

Bases: object

getTopology(epoch, trajectory_number)[source]

Get the topology for a particular epoch and trajectory number

Parameters
  • epoch (int) – Epoch of the trajectory of interest

  • trajectory_number (int) – Number of the trajectory to select

Returns

list – List with topology information

getTopologyFile(epoch, trajectory_number)[source]
getTopologyIndex(epoch, trajectory_number)[source]

Get the topology index for a particular epoch and trajectory number

Parameters
  • epoch (int) – Epoch of the trajectory of interest

  • trajectory_number (int) – Number of the trajectory to select

Returns

int – Index of the corresponding topology

topologyFilesIterator()[source]
AdaptivePELE.utilities.utilities.assertSymmetriesDict(symmetries, PDB)[source]

Asserts the symmetry list in a PDB

Parameters
  • symmetries (list of str) – List of symmetry groups

  • PDB (PDB) – PDB object to check symmetry list against

Raises

AssertionError – If an atom is not found in the structure

AdaptivePELE.utilities.utilities.calculateContactMapEigen(contactMap)[source]

Calculates eigenvectors and values of an extended contact map

Parameters

contactMap (np.array) – Contact map

Returns

(numpy.ndarray, numpy.ndarray) – eigenvalues, eigenvectors

AdaptivePELE.utilities.utilities.cleanup(tmpFolder)[source]

Remove folder if exists

Parameters

tmpFolder (str) – Folder to remove

AdaptivePELE.utilities.utilities.convert_trajectory_to_pdb(trajectory, topology, output, output_folder)[source]

Write a trajectory from a non-pdb trajectory to pdb format

Parameters
  • trajectory (str) – Trajectory to convert

  • topology (str) – Topology file

  • output (str) – Filename of the ouput file

  • output_folder (str) – Folder where to store the output trajectory

AdaptivePELE.utilities.utilities.distanceCOM(coords1, coords2)[source]
AdaptivePELE.utilities.utilities.ensure_connectivity_msm(msm)[source]
AdaptivePELE.utilities.utilities.gen_atom_name(index)[source]
AdaptivePELE.utilities.utilities.generateRotationMatrixAroundAxis(axis, angle)[source]
AdaptivePELE.utilities.utilities.getAtomNames(values)[source]

Assign to each value an atomname, O for negatives, H for 0 and N for positives. This function is created for assign atomnames for custom pdbs

Parameters

values (iterable) – Collection of numbers to assing an atom name for

Returns

list – List of atom names

AdaptivePELE.utilities.utilities.getCpuCount()[source]
AdaptivePELE.utilities.utilities.getFileExtension(trajectoryFile)[source]

Extract the extension of a trajectory

Parameters

trajectoryFile (str) – Name of the trajectory file

Returns

str – Extension of the trajectory

AdaptivePELE.utilities.utilities.getFileSuffix(filename, separator='_')[source]

Gets the suffix appendend to a file name

Parameters
  • filename (str) – filename

  • separator (str) – character used as separator for the suffix

Returns

int – Trajectory number

AdaptivePELE.utilities.utilities.getMetricsFromReportsInEpoch(reportName, outputFolder, nTrajs)[source]

Extract the metrics in report file from an epoch to a numpy array

AdaptivePELE.utilities.utilities.getPELEControlFileDict(templetizedControlFile)[source]

Parse a PELE control file into a python dictionary

AdaptivePELE.utilities.utilities.getPrmtopNum(prmtopFilename)[source]

Gets the prmtop number

Parameters

trajFilename (str) – prmtop filename

Returns

int – prmtop number

AdaptivePELE.utilities.utilities.getRMSD(traj, nativePDB, resname, reschain, resnum, symmetries, topology=None)[source]

Computes the RMSD of a trajectory, given a native and symmetries

Parameters
  • traj (str) – Trajecotry filename

  • nativePDB – Native PDB object

  • 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

  • symmetries (list of dict) – Symmetries dictionary list with independent symmetry groups

  • topology (list) – Topology for non-pdb trajectories

Returns

np.array – Array with the rmsd values of the trajectory

AdaptivePELE.utilities.utilities.getReportAndTrajectoryWildcard(JSONdict)[source]

Extract the trajectory and report filename from the pele control file

Parameters

JSONdict (dict) – Dictionary containing a parsed PELE control file

Returns

str, str – Report and trajectory wildcards

AdaptivePELE.utilities.utilities.getReportList(reportBase)[source]

Get a list of the report filenames in the path specified, filtering interstep reports

Parameters

reportBase (str) – Report file basename

Returns

list – List of report files

AdaptivePELE.utilities.utilities.getReportNum(reportFilename)[source]

Gets the report number

Parameters

reportFilename (str) – Trajectory filename

Returns

int – Report number

AdaptivePELE.utilities.utilities.getSASAcolumnFromControlFile(JSONdict)[source]
AdaptivePELE.utilities.utilities.getSnapshots(trajectoryFile, verbose=False, topology=None, use_pdb=False)[source]

Gets the snapshots

Parameters
  • trajectoryFile (str) – Trajectory filename

  • verbose (bool) – Add verbose to snapshots

Returns

iterable – Snapshots with information

AdaptivePELE.utilities.utilities.getSortedEigen(T)[source]
AdaptivePELE.utilities.utilities.getStationaryDistr(lowestEigenvector)[source]
AdaptivePELE.utilities.utilities.getTopologyFile(structure)[source]

Extract the topology information to write structures from xtc format

Parameters

structure (str) – Pdb file with the topology information

Returns

list of str – The lines of the topology file

AdaptivePELE.utilities.utilities.getTopologyObject(topology_file)[source]
AdaptivePELE.utilities.utilities.getTrajNum(trajFilename)[source]

Gets the trajectory number

Parameters

trajFilename (str) – Trajectory filename

Returns

int – Trajectory number

AdaptivePELE.utilities.utilities.get_available_backend()[source]
AdaptivePELE.utilities.utilities.get_epoch_folders(path)[source]

List the folders belonging to an adaptive simulation and containing trajectories and reports

Parameters

path (str) – Path where to check for the folders

Returns

list – List of folders belonging to the simulation, sorted

AdaptivePELE.utilities.utilities.get_file_extension(full_path)[source]

Get the extension of the file pointed by full_path

Parameters

full_path (str) – Path to the file

AdaptivePELE.utilities.utilities.get_file_name(full_path)[source]

Get the name of the file pointed by full_path

Parameters

full_path (str) – Path to the file

AdaptivePELE.utilities.utilities.get_file_name_extension(full_path)[source]

Get the name and the extension of the file pointed by full_path

Parameters

full_path (str) – Path to the file

AdaptivePELE.utilities.utilities.get_mdtraj_object_PDBstring(conformation, topology)[source]

Get the pdb string of a snapshot from a xtc trajectory to pdb

Parameters
  • conformation – Mdtraj trajectory object to write

  • topology (list) – Topology-like object

Returns

str – The pdb representation of a snapshot from a xtc

AdaptivePELE.utilities.utilities.get_string_from_array(array, sep=', ', decimals=None, remove_newlines=True)[source]

Get a string representation of an array, specifiying separator and decimal rounding

Parameters
  • array (ndarray or list) – Input array

  • sep (str) – Separator

  • decimals (int) – Number of decimals to round the array

  • remove_newlines (bool) – Wheter to remove the newlines between dimensions

AdaptivePELE.utilities.utilities.get_workers_output(workers, wait_time=60)[source]

Get the output of a pool of workers without serializing the program at the get.

Parameters
  • workers (list) – List of AsyncResult objects created when passing work to the pool

  • wait_time (int) – Number of second to wait before checking if next worker is finished

Returns

list – List containing the output of all workers, if the function passed to the pool had no return value it will be a list of None objects

AdaptivePELE.utilities.utilities.glob_sorted(pattern, reverse=False, key=None, filter_func=None)[source]

Run glob and sort the output to ensure cross-platform compatibility

Parameters
  • pattern (str) – pathname to match files

  • reverse (bool) – If set to True, then the list elements are sorted as if each comparison were reversed

  • key (function) – Function of one argument that is used to extract a comparison key from each list element

Returns

list – List containing the output of all workers, if the function passed to the pool had no return value it will be a list of None objects

AdaptivePELE.utilities.utilities.isReport(reportFilename)[source]

Checks whether the file is a PELE report

Parameters

reportFilename (str) – Trajectory filename

Returns

bool – Whether the file is a PELE report

AdaptivePELE.utilities.utilities.join_coordinates_prob(coords, p)[source]

Join a MxN numpy array representing some cluster center coordinates with an 1XN array representing some metric of the clusters

Parameters
  • coords (np.array) – Coordinates of the clusters

  • p (np.array) – Metric of the clusters

AdaptivePELE.utilities.utilities.loadtxtfile(filename, usecols=None, postprocess=True, dtype=<class 'float'>)[source]

Load a table file from a text file

Parameters
  • filename (str) – Name of the file to load

  • usecols (int) – Which columns to read, with 0 being the first

  • postprocess (bool) – Whether to add an extra dimension if only one line present in the txt file

  • dtype (data-type) – Data-type of the resulting array, (default float)

Returns

np.ndarray – Contents of the text file

AdaptivePELE.utilities.utilities.makeFolder(outputDir)[source]

Makes folder

Parameters

outputDir (str) – Folder filename

AdaptivePELE.utilities.utilities.print_unbuffered(*args)[source]

Call print and immediately after flush the buffer

AdaptivePELE.utilities.utilities.readClusteringObject(clusteringObjectPath)[source]

Reads and returns a clustering object

Parameters

clusteringObjectPath (str) – Clustering object path

Raises

EOFError – If the object is empty

Returns

Clustering – clusteringObject

AdaptivePELE.utilities.utilities.readConstraints(folder, filename)[source]

Read the new constraints from disk

Parameters
  • folder (str) – Name of the folder where to write the constraints

  • filename (str) – Name of the file where to write the constraints

Returns

list – List with the new constraints

AdaptivePELE.utilities.utilities.readProcessorMappingFromDisk(folder, filename)[source]

Read the processorsToClusterMapping from disk

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

  • filename (str) – Name of the file where to write the processorMapping

Returns

list – List with the mapping of the trajectories to processors

AdaptivePELE.utilities.utilities.sign(x, tol=1e-07)[source]

Return the sign of a number

Parameters
  • x (numpy.array) – Array of number to evaluate the sign

  • tol (float) – Tolerance to define the zero

Returns

int – Sign of the number

AdaptivePELE.utilities.utilities.writeNewConstraints(folder, filename, constraints)[source]

Write the constraints to disk

Parameters
  • folder (str) – Name of the folder where to write the constraints

  • filename (str) – Name of the file where to write the constraints

  • constraints (list) – List of the constraints

AdaptivePELE.utilities.utilities.writeObject(filename, object_to_write, protocol=2)[source]
AdaptivePELE.utilities.utilities.writeProcessorMappingToDisk(folder, filename, processorMapping)[source]

Write the processorsToClusterMapping to disk

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

  • filename (str) – Name of the file where to write the processorMapping

  • processorMapping (list) – Mapping of the trajectories to processors

AdaptivePELE.utilities.utilities.write_PDB_clusters(pmf_xyzg, title='clusters.pdb', use_beta=False, elements=None)[source]
AdaptivePELE.utilities.utilities.write_mdtraj_object_PDB(conformation, output, topology)[source]

Write a snapshot from a xtc trajectory to pdb

Parameters
  • conformation – Mdtraj trajectory object to write

  • output (str) – Output where to write the object

  • topology (list) – Topology-like object

AdaptivePELE.utilities.utilities.write_xtc_to_pdb(filename, output_file, topology)[source]

Get the pdb string of a snapshot from a xtc trajectory to pdb

Parameters
  • filename (str) – Path to the xtc trajectory

  • output_file (str) – Output where to write the object

  • topology (str) – Topology file object

Returns

str – The pdb representation of a snapshot from a xtc