Package schrodinger :: Package application :: Package desmond :: Package packages :: Module analysis
[hide private]
[frames] | no frames]

Module analysis

Classes and functions for trajectory-based analysis

Copyright Schrodinger, LLC. All rights reserved.

Classes [hide private]
  _Const
  Pbc
  GeomAnalyzerBase
Base class of all geometry analyzer classes
  _CompositeAnalyzer
This analyzer contains one or more analyzers as its components.
  Vector
Calculate the vector between two xids.
  Distance
Calculate the distance between two xids.
  Angle
Calculate the angle formed between three xids.
  Torsion
Calculate the torsion formed between four xids.
  CenterOf
N.B.: The calculated center is an unwrapped coordinate.
  Com
Class for computing averaged position weighted by atomic mass, under the periodic boundary condition.
  Coc
Class for computing center of charge under periodic boundary condition.
  Centroid
Class for computing centroid under periodic boundary condition.
  Gyradius
Class for computing radius of gyration under periodic boundary condition.
  MassAvgVel
Class for computing mass-averaged velocity
  PosTrack
Class for tracking positions of selected atoms in a trajectory.
  RadiusOfGyration
Class for computing radius of gyration under periodic boundary condition.
  CenterOfMotion
Class for computing mass-averaged velocity
  Position
Class for tracking positions of selected atoms in a trajectory.
  _Ramachandran
Calculate the Phi and Psi torsions for selected atoms, with GIDs as input.
  Ramachandran
Calculate the Phi and Psi torsions for selected atoms.
  _MaestroAnalysis
All analyzer classes whose calculations require the full-system CT could inherit this base class, which will provide an intermediate data that contains a trajectory frame and a full-system CT.
  PosAlign
This analyzer first aligns the geometric center of the solute atoms to that of cms_model, then calculates the rotation/translation transformation for converting the structure (fit_aids) of a centered trajectory frame to a given geometry (fit_ref_pos) and finally applies the transformation to a position array of only the selected atoms (aids).
  RMSD
Root Mean Square Deviation from reference positions, with optional alignment fitting.
  RMSF
Root Mean Square Fluctuation from reference positions (averaged position over the trajectory) for each atom, with optional alignment fitting.
  LigandRMSD
Ligand Root Mean Square Deviation from reference positions, with optional alignment fitting.
  ProteinRMSF
Root Mean Square Fluctuation from reference positions (averaged positions over the trajectory) for each residue, with optional alignment fitting
  Dipole
Electric dipole moment of the selected atoms, in unit of debye.
  AxisDirector
Basis vector of 3D axis
  MomentOfInertia
Moment of inertia tensor
  MomentOfInertiaDirector
Direction of the principal moment of inertia for each molecule
  SmartsDirector
Direction of atom pairs from SMARTS pattern.
  SystemDipoleDirector
Direction of electric dipole moment of all the selected atoms
  DipoleDirector
Dipole direction for each molecule in the selection
  LipidDirector
Direction of CH bond for carbon atoms on lipid tail
  OrderParameter
Given the director (local or global), and the descriptor (local or global), calculate the order parameter <P2> for each frame S = 1/N sum_i ((3 * (n dot m_i)^2 -1) / 2) Where n is the director vector and m is the descriptor vector.
  SecondaryStructure
Calculate the secondary-structure property for selected atoms.
  SolventAccessibleSurfaceAreaByResidue
Calculate the relative SASA broken down by residues.
  MolecularSurfaceArea
Calculate the molecular surface area.
  SolventAccessibleSurfaceArea
Calculate solvent accessible surface area for selected atoms.
  PolarSurfaceArea
Calculate polar surface area for selected atoms.
  HydrogenBondFinder
Find hydrogen bonds present between two sets of atoms.
  _KeyPartial
Extend partial such that the function instead of the partial instance is used as dictionary key.
  CustomMaestroAnalysis
Compute the result of a custom function on centered models.
  _Ligand
_Ligand(aids, frags, rings, aid2frag, aid2label)
  _HydrophobicInter
Compute protein-ligand hydrophobic interaction candidates: protein atoms on hydrophobic residues and ligand aromatic/aliphatic atoms within hydrophobic distance cutoff.
  HydrophobicInter
Calculate hydrophobic interactions between protein and ligand, with hbonds and pi-pi interactions excluded.
  _ProtLigPolarInter
Calculate protein-ligand polar interaction candidates.
  ProtLigPolarInter
Calculate polar interactions between protein and ligand, with hbonds and water bridges excluded.
  MetalInter
Interactions between metal elements and protein/ligand atoms.
  _WatLigFragDistance
For all water molecules within distance (hbond_cutoff + 0.3) to the ligand, find the mininum distance between water oxygen atom and the closest ligand fragment centroid.
  WatLigFragDistance
Distance between water oxygen atom and its closest ligand fragment, with water bridges excluded.
  ProtLigInter
Composition of various protein ligand interactions.
  VolumeMapper
This class takes the coordinates of provided particles and maps them onto a discretized grid using kernel density estimation as implemented in scipy.
  _CustomCalc
An instance of this class will store custom calculation requests (keys) and results (values).
  GeomCalc
We use this class to batch the geometry calculations and avoid duplications.
  Positer
A class to create a positer object for use with the GeomCalc class.
  Rdf
Calculate radial distribution function (RDF) of provided selection.
  ProtProtPiInter
Protein-protein Pi interaction finder.
  ProtProtHbondInter
Protein-protein hydrogen bond finder.
  SaltBridgeFinder
Find salt bridges present between two sets of atoms.
  _ProtProtSaltBridges
Protein-protein salt bridge finder.
  ProtProtInter
Protein-protein interactions.
Functions [hide private]
 
is_small_struc(atoms)
A simple API to determine whether a molecular structure is small.
 
_pos2circ(data, pbc, fr, *_)
Convert a 3D vector (x, y, z) into a circular coordinate:
dict. Key = GID, value = a copy of the input frame instance fr. If previous frame is available in data, the atom coordinates are unwrapped with respect to their coordinates in the previous frame.
_unwrap_wrt_prevpos(data, pbc, fr, *_)
Unwrap every point wrt its coordinate in the prev frame, if available.
 
_center(data, pbc, fr, *_)
Center selected particles in the simulation box, and it will automatically make all molecules whole.
Nx3 numpy.ndarray
_align_pos(pos, fit_pos, fit_ref_pos, weights=None)
Align pos using transformations (rotation and translation) derived from converting fit_pos to fit_ref_pos.
 
_get_common_resname(resname, mapping={'ARN': 'ARG', 'ASH': 'ASP', 'CYX': 'CYS', 'GLH': 'GLU', 'HID'...)
 
_direction(v)
Normalize vector to unit vector
 
reduce_vec(n, m)
Calculate Legendre polynomial P2 using inner product of n and m as input
 
reduce_vec_list(n, m)
Calculate Legendre polynomial P2 using inner product of n and m as input
 
_select_asl(asl, data, custom)
This function is auxiliary to functions that work with _CustomMaestroAnalysis to provide ASL selection for each frame.
 
_res_near_lig(lig_asl, prot_asl, cutoff, data, _, __, custom)
Select residue atoms near ligand according to distance cutoff.
 
_wat_near_lig(lig_asl, cutoff, data, _, __, custom)
Select water atoms near ligand according to distance cutoff.
 
_ion_near_lig(ion_asl, lig_not_CH, lig_asl, cutoff, data, _, __, custom)
Select ions near ligand according to distance cutoff.
 
_hydrophobic_res_near_lig(lig_asl, cutoff, prot_cid, data, _, __, custom)
Select hydrophobic residues near ligand according to distance cutoff.
 
_prot_near_ion(cutoff, ion_cid, prot_cid, data, _, __, custom)
Select protein atoms near ions according to distance cutoff.
 
_aids2asl(aids)
Convert a list of AIDs to an ASL string.
list. Each element is a list of ints.
_get_ligand_fragments(lig_ct)
Decompose the ligand in several fragments using the murcko rules.
 
_prot_atom_label(fsys_ct, aid, res_only=False)
Return the protein atom label.
 
_has_unique_PDB_names(ct)
Return True if all atoms have unique s_m_pdb_atom_name
 
_lig_atom_label(fsys_ct, aid, frag_idx, is_name_unique)
 
_cleanup_water_ligand_distance(result)
Remove WaterBridges results from _WatLigFragDistance results.
 
_cleanup_polar_inter(result, label_res, aid2frag)
Remove ProtLigHbondInter and WaterBridges results from _ProtLigPolarInter results.
 
_cleanup_hydrophobic_inter(result, label_res, aid2frag)
Remove ProtLigHbondInter and ProtLigPiInter results from _HydrophobicInter results.
 
_memoize(func)
Decorator for memoization.
 
_get_lig_properties(*args)
 
_get_prot_charged_atoms(prot_ct)
Returns: dict.
 
_get_lig_charged_atoms(lig_ct)
Returns: dict.
 
ProtLigPiInter(*args)
Compute pi-pi and pi-cation interations between protein and ligand.
 
ProtLigHbondInter(*args)
Compute protein-ligand hydrogen bonds.
 
WaterBridges(*args)
Find water bridges between protein and ligand
dict
_dictmap(func, dictionary)
Map each key-value pair in a dictionary with a function func.
 
progress_report_frame_number(i, *_)
list
analyze(tr, analyzer, *arg, **kwarg)
Do analyses on the given trajectory tr, and return the results.
numpy.ndarray of floats
rmsd_matrix(msys_model, tr, rmsd_gids, fit_gids)
For all pairs of frames in the trajectory tr, we first superimpose the structures from the two frames on the atoms as specified by fit_gids, and then we calculate the RMSD for atoms as specified by rmsd_gids.
 
cluster(affinity_matrix)
Do clustering using the affinity propagation method.
Variables [hide private]
  __package__ = 'schrodinger.application.desmond.packages'
Function Details [hide private]

is_small_struc(atoms)

 

A simple API to determine whether a molecular structure is small.

Parameters:
  • atoms (list) - A list of atoms in the structure. The atoms can be atom IDs or atom-class instances.

_pos2circ(data, pbc, fr, *_)

 

Convert a 3D vector (x, y, z) into a circular coordinate:

  (array([cos_x', cos_y', cos_z',]), array([sin_x', sin_y', sin_z']),)

. This is needed for the center of mass (or charge, or centroid, for that matter)
calculations.

@type data: C{dict}. Key = GID, value = circular coordinate of the atom

_unwrap_wrt_prevpos(data, pbc, fr, *_)

 

Unwrap every point wrt its coordinate in the prev frame, if available.

Parameters:
  • data (dict. Key = GID, value = None for the first frame, otherwise value = the previous frame with unwrapped atom coordinates. All GIDs map to the same frame instance.)
Returns: dict. Key = GID, value = a copy of the input frame instance fr. If previous frame is available in data, the atom coordinates are unwrapped with respect to their coordinates in the previous frame.

_center(data, pbc, fr, *_)

 

Center selected particles in the simulation box, and it will automatically
make all molecules whole.
This function will copy the input trajectory frame (C{fr}), and in the copy
frame the selected particles will be centered. Optionally this function will
create a CMS model of the centered frame.

@type data: C{dict}
    key = C{(msys_model, cms_model, center_gids, allaid_gids)}
    value = (<centered-frame>, <centered-cms-model> or C{None})
where C{msys_model} and C{center_gids} are mandated, and C{cms_model} and
C{allaid_gids} can be C{None}s. C{center_gids} specifies the GIDs of the
particles to be centered, whereas C{allaid_gids} specifies the GIDs of all
the atoms in the full-system CT (this list does not equal to the all GIDs).
If C{cms_model} is C{None}, this function will NOT create the centered
cms model.

@return: Updated C{data}, where values are updated for the given C{fr}.

_align_pos(pos, fit_pos, fit_ref_pos, weights=None)

 

Align pos using transformations (rotation and translation) derived from converting fit_pos to fit_ref_pos. Weighted Kabsch algorithm is used to obtain the transformations.

Parameters:
  • fit_pos (Mx3 numpy.ndarray)
  • weights (length M numpy.ndarray, or None)
  • pos (Nx3 numpy.ndarray)
  • fit_ref_pos (Mx3 numpy.ndarray)
Returns: Nx3 numpy.ndarray
aligned pos

_get_common_resname(resname, mapping={'ARN': 'ARG', 'ASH': 'ASP', 'CYX': 'CYS', 'GLH': 'GLU', 'HID'...)

 
Parameters:
  • resname - residue name
  • mapping (dict from string to string)

_direction(v)

 

Normalize vector to unit vector

Parameters:
  • v (Nx3 numpy.array) - vectors

reduce_vec(n, m)

 

Calculate Legendre polynomial P2 using inner product of n and m as input

Parameters:
  • m (1x3 or Nx3 numpy.array)
  • n (1x3 or Nx3 numpy.array)

reduce_vec_list(n, m)

 

Calculate Legendre polynomial P2 using inner product of n and m as input

Parameters:
  • m (A list of Ni x3 numpy.array objects, where the row number Ni of each element may not agree)
  • n (1x3 numpy.array)

_select_asl(asl, data, custom)

 

This function is auxiliary to functions that work with _CustomMaestroAnalysis to provide ASL selection for each frame. It uses the centered CMS model from _MaestroAnalysis to evaluate ASL.

Parameters:
  • custom (_CustomCalc) - It contains the _MaestroAnalysis result.
  • data (dict key = (msys_model, cms_model, center_gids, allaid_gids) value = list of int, i.e., AIDs of the selected atoms)
Returns:
Updated data, where values are updated for the given frame.

_res_near_lig(lig_asl, prot_asl, cutoff, data, _, __, custom)

 

Select residue atoms near ligand according to distance cutoff. It works with CustomMaestroAnalysis. Also see _select_asl.

_wat_near_lig(lig_asl, cutoff, data, _, __, custom)

 

Select water atoms near ligand according to distance cutoff. It works with CustomMaestroAnalysis. Also see _select_asl.

_ion_near_lig(ion_asl, lig_not_CH, lig_asl, cutoff, data, _, __, custom)

 

Select ions near ligand according to distance cutoff. It works with CustomMaestroAnalysis. Also see _select_asl.

Parameters:
  • lig_not_CH (list of int) - AIDs of ligand atoms that are not carbon or hydrogen

_hydrophobic_res_near_lig(lig_asl, cutoff, prot_cid, data, _, __, custom)

 

Select hydrophobic residues near ligand according to distance cutoff. It works with CustomMaestroAnalysis. Also see _select_asl.

Parameters:

_prot_near_ion(cutoff, ion_cid, prot_cid, data, _, __, custom)

 

Select protein atoms near ions according to distance cutoff. It works with CustomMaestroAnalysis. Also see _select_asl.

Parameters:

_get_ligand_fragments(lig_ct)

 

Decompose the ligand in several fragments using the murcko rules.

Parameters:
  • lig_ct (schrodinger.structure.Structure)
Returns: list. Each element is a list of ints.
ligand fragments

_prot_atom_label(fsys_ct, aid, res_only=False)

 

Return the protein atom label.

Parameters:
  • res_only - set True to label up to the residue

_has_unique_PDB_names(ct)

 

Return True if all atoms have unique s_m_pdb_atom_name

Parameters:
  • ct (schrodinger.structure.Structure)

_lig_atom_label(fsys_ct, aid, frag_idx, is_name_unique)

 
Parameters:
  • frag_idx (int) - mapping AID to ligand fragment index
  • is_name_unique - True if all atoms have different PDB names

_cleanup_water_ligand_distance(result)

 

Remove WaterBridges results from _WatLigFragDistance results.

Parameters:
  • result (dict) - The result to be cleaned up. It must contain the results from the _WatLigFragDistance, WaterBridges analyzers, as keyed by "WaterBridgeResult" and "LigWatResult", respectively.

_cleanup_polar_inter(result, label_res, aid2frag)

 

Remove ProtLigHbondInter and WaterBridges results from _ProtLigPolarInter results.

Parameters:
  • result (dict) - The result to be cleaned up. It must contain the results from the _ProtLigPolarInter, WaterBridges and ProtLigHbondInter analyzers, as keyed by "PolarResult", "WaterBridgeResult", and "HBondResult" respectively.
  • label_res (callable) - label up to the residue
  • aid2frag (dict) - mapping ligand atom aid to fragment index

_cleanup_hydrophobic_inter(result, label_res, aid2frag)

 

Remove ProtLigHbondInter and ProtLigPiInter results from _HydrophobicInter results.

Parameters:
  • result (dict) - The result to be cleaned up. It must contain the results from the _HydrophobicInter, ProtLigPiInter and ProtLigHbondInter ananlyzers, as keyed by "HydrophobicResult" "PiPiResult", "PiCatResult", and "HBondResult" respectively.
  • label_res (callable) - label up to the residue
  • aid2frag (dict) - mapping ligand atom aid to fragment index

_memoize(func)

 

Decorator for memoization. Note all the func arguments need to be hashable. It may affect performance if the hash is expensive to compute, e.g., long tuples.

Parameters:
  • func (a callable)

_get_lig_properties(*args)

 
Decorators:
  • @_memoize

_get_prot_charged_atoms(prot_ct)

 
Parameters:
  • prot_ct (schrodinger.structure.Structure)
Returns:
dict. Keys are AIDs of the charged atoms, values are pseudocharges.

_get_lig_charged_atoms(lig_ct)

 
Parameters:
  • lig_ct (schrodinger.structure.Structure)
Returns:
dict. Keys are AIDs of the charged atoms, values are pseudocharges.

ProtLigPiInter(*args)

 

Compute pi-pi and pi-cation interations between protein and ligand.

Returns a list of dict. The length of this list is the number of frames. The dict keys are 'PiPiResult', and 'PiCatResult'. The value is a list of ProtLigPiInter.Pipi, ProgLigPiInter.PiLCatP, or ProgLigPiInter.PiPCatL objects, where frag_idx is the index of the ligand fragment, ca_aid is the AID of alpha carbon, prot_aid and lig_aid are the AID of the protein atom and ligand atom, ring_idx is the ligand ring index, type could be 'f2f' or 'e2f', distance and angle describe the geometry of the corresponding interaction.

ProtLigHbondInter(*args)

 

Compute protein-ligand hydrogen bonds.

Returns a list of dict. The length of this list is the number of frames. The dict key is 'HBondResult', and the value is a list of ProtLigHbondInter.Result, where prot_aid is the AID of the protein atom, prot_type is a string that denotes the acceptor/donor, backbone/side chain information, lig_aid is the AID of ligand atom.

WaterBridges(*args)

 

Find water bridges between protein and ligand

Returns a list of dict. The length of this list is the number of frames. The dict key is 'WaterBridgeResult', and the value is a list of WaterBridges.Result, where prot_aid and lig_aid are the AID of the protein atom and ligand atom, prot_type and lig_type are strings that denotes the acceptor/donor information, wat_res_num is the water residue number.

_dictmap(func, dictionary)

 

Map each key-value pair in a dictionary with a function func. This will create a new dict object with the same keys as in dictionary, but the corresponding value of each key will be ``mapped'' by calling func(key).

Parameters:
  • dictionary (dict)
  • func (Any callable object that takes a key from dictionary as the input argument and returns a new value.)
Returns: dict
A new dict object. dictionary will NOT be mutated.

analyze(tr, analyzer, *arg, **kwarg)

 

Do analyses on the given trajectory tr, and return the results. The analyses are specified as one or more positional arguements. Each analyzer should satisfy the interface requirements (see the docstring of GeomCalc.addAnalyzer).

Parameters:
  • tr (list of traj.Frames) - The simulation trajectory to analyze
  • arg - A list of analyzer objects
  • kwarg["progress_feedback"] (callable, e.g., func(i, fr, tr), where i is the current frame index, fr the current frame, tr the whole trajectory.) - This function will be called at start of analysis on the current frame. This function is intended to report the progress of the analysis.
Returns: list
For a single analyzer, this function will return a list of analysis results, and each element in the list corresponds to the result of the corresponding frame. For multiple analyzers, this function will return a list of lists, and each element is a list of results of the corresponding analyzer. If an analyzer has a reduce method, the reduce method will be called, and its result will be returned.

rmsd_matrix(msys_model, tr, rmsd_gids, fit_gids)

 

For all pairs of frames in the trajectory tr, we first superimpose the structures from the two frames on the atoms as specified by fit_gids, and then we calculate the RMSD for atoms as specified by rmsd_gids.

Parameters:
  • tr (list of traj.Frame objects) - Trajectory
  • rmsd_gids (list of ints) - GIDs of atoms for which to calculate the RMSD
  • fit_gids (list of ints) - GIDs of atoms on which to we align the structures
  • msys_model (msys.System)
Returns: numpy.ndarray of floats
A symetric square matrix of RMSDs

cluster(affinity_matrix)

 

Do clustering using the affinity propagation method.

Parameters:
  • affinity_matrix (numpy.ndarray of floats) - A square matrix of affinity/similarity values

    @rtype (list-of-ints, list-of-ints)

Returns:
The first list is the sample indices of the clusters' centers, the second list is a cluster label of all samples.