schrodinger.comparison.neighbors module

methods for handling neighbors with ase

class schrodinger.comparison.neighbors.MoleculeNeighbor(molecule_number, ix, iy, iz)

Bases: tuple

ix

Alias for field number 1

iy

Alias for field number 2

iz

Alias for field number 3

molecule_number

Alias for field number 0

schrodinger.comparison.neighbors.get_n_subunits_wrapper(st: Structure, ref: Structure, zprime2: bool) int

Function wrapping common component ID validation for cluster alignment functions below.

Logic is equivalent to struc.get_n_subunits_in_asu(), but we perform extra validation and implement a backwards compatibility policy: because many test files were created before component IDs are implemented, we log a warning and default to assuming a Z’=1 single-molecule ASU only if zprime2 = False and all molecules have the same number of atoms. If those conditions aren’t met, an error is raised.

Parameters:
  • st – The input test structure

  • ref – The input reference structure

  • zprime2 – True for a Z’=2 search.

Returns:

Number of distinct molecules/ions in the ASU of st.

schrodinger.comparison.neighbors.com_cell_atoms(st, unit_cell, symbol='C')

Construct an Atoms instance where each atom represents the COM of a molecule in st

params:

st (Structure): the input crystal unit_cell (3x3 np.array): lattice vectors are rows symbol (str): symbol for each atom in COM cell

returns:

An Atoms instance that gives the COM cell

schrodinger.comparison.neighbors.spherical_cluster(st, Rcut)

Construct a spherical cluster of radius Rcut about each molecules center of mass in st. The Nth value of the generator is centered about the Nth molecule.

params:

st (Structure): represents the conventional cell unit_cell (3x3 np.array): lattice vectors as rows Rcut (float): cutoff for including molecules

returns:

Generator of clusters

schrodinger.comparison.neighbors.spherical_atomic_cluster(st: Structure, Rcut: float, center_idx=1)

Construct a cluster of neighbors centered about the center_idx’th molecule. This implementation includes any molecule that has any atom inside the cutoff radius with respect to the central molecule.

Parameters:
  • st – represents the conventional cell

  • Rcut – cutoff for including molecules

  • center_idx – molecule index for the spherical cluster center

schrodinger.comparison.neighbors.search_cluster_radius(st, Ncluster_min=25, Ncluster_max=35, r=4.0, cluster_at_r=None, dRthresh=0.01, center_idx=1) Tuple[Structure, float]

Search for a cluster radius that gives a spherical cluster of a certain size. If a cluster that satisfies the limits is not found a RuntimeError.

Parameters:
  • st (Structure) – the crystal

  • Ncluster_min (int) – minimum number of molecules in cluster

  • Ncluster_max (int) – maximum number of molecules in cluster

  • r (float) – radius to start search

  • cluster_at_r (Optional[Structure]) – the cluster produced by spherical_atomic_cluster at radius r

  • Rthresh (float) – stop search if we can’t find Ncluster_min < N < Ncluster_max within precision dRthresh

Returns:

tuple of Structure, radius

schrodinger.comparison.neighbors.preprocess_st(st: Structure, *, remove_hydrogens=True, remove_asl='water', copy=False) Structure

Return preprocessed structure

schrodinger.comparison.neighbors.prepare_data(st: Structure, is_spherical_cluster: bool = False, remove_hydrogens: bool = True, remove_asl: str = 'water', copy: bool = False, min_molecules: int = 25, max_molecules: int = 35, zprime2: bool = False, regenerate_unitcell: bool = False) List[Structure]

Top-level function for constructing spherical clusters for crystal alignment, deduplication and RMSD-N calculation.

Returns a list of 1 or 2 spherical clusters centered on ASU subunits. If zprime2 = False, 1 cluster will be returned. If zprime2 = True, 2 clusters (each centered on a different subunit) will be returned, unless the 2nd subunit in the ASU is an excipient which has too few atoms to fix an alignment, in which case only the cluster centered on the conformer will be returned. The different subunits are assumed to be the first Z’ molecules of st.

Parameters:
  • st – Input structure. Assumed to be one of - pre-prepared spherical cluster, in which case is_spherical_cluster should be True and this is a no-op (not supported for Z’=2) - a unitcell with lattice properties set. - an ASU with lattice properties set and regenerate_unitcell=True. The unitcell will be regenerated automatically for Z’>1 if ASU component IDs are not set.

  • is_spherical_cluster – Set to true if input is already a spherical cluster.

  • remove_hydrogens – True to remove Hs from output.

  • remove_asl – ASL expression to remove additional atoms from output.

  • min_molecules – target minimum number of mols in each returned cluster

  • max_molecules – target max number of mols in each returned cluster

  • zprime2 – True if Z’=2

  • regenerate_unitcell – True to recreate the unit cell from the first Z’ molecules of st; otherwise input assumed to be a unit cell.

Returns:

List of length <= Z’. The list may be shorter than the number of subunits in the ASU due to skipping excipients that are too small to determine an alignment.

schrodinger.comparison.neighbors.get_spherical_cluster_RMSDn(st: Structure, ref: Structure, matching_cutoff: float = 2, matched_cutoff: int = 15, align_cluster=True, include_H=False, renumber_rmsd_thresh=0.8, allow_reflection=True, pg_symmetry_ops=(), n_thresh: int = 20, zprime2: bool = False) Tuple[int, float, Structure]

Return number of molecules matched, their RMSD, and the aligned st with respect to ref. The st and ref are assumed to be spherical clusters with ASU component IDs assigned.

Parameters:
  • st – test Structure to align

  • ref – reference Structure (unmoved)

  • matching_cutoff – If the centroid of a molecule is within the radius of another molecule from a different cluster, it is considered as matched.

  • matched_cutoff – If the number of matched centroids is less than this number, abort further computation

  • align_cluster – If not set, only align on the central molecules, i.e., the first molecules of the input structures; otherwise further align on all molecules

  • include_H – if False using heavy atom rmsd, else use all atom rmsd

  • renumber_rmsd_thresh – only attempt atom renumber if rmsd for 1st molecule is greater than this

  • allow_reflection – whether or not to allow reflection when optimizing rmsd in scoring method

  • pg_symmetry_ops – iterable of SymmOp instances, each representing a point group symmetry operation. If the iterable is not empty each operation is applied to the test cluster RMSD N analysis is performed. The best RMSD N is returned.

  • n_thresh – Centroid threshold for comparing spherical cluster alignments on the basis of RMSD only.

  • zprime2 – Flag to align Z’=2 crystals; if False, assume all molecules are equivalent by space group symmetry operations

Returns:

three-tuple: N matched, rmsd of match, st after renumbering/alignment A new structure is returned

schrodinger.comparison.neighbors.get_centroid_RMSDn(st: Structure, ref: Structure, matching_cutoff: float = 2, matched_cutoff: int = 15, allow_reflection=True, n_maybe=5, n_nb=3, n_thresh: int = 20, parity_seen=None, zprime2: bool = False) Iterator[Tuple[int, float, Structure]]

Return number of molecules matched, their RMSD, and the aligned st with respect to ref. The st and ref are assumed to be spherical clusters with ASU component IDs assigned.

Parameters:
  • matching_cutoff – If the centroid of a molecule is within the radius of another molecule from a different cluster, it is considered as matched.

  • matched_cutoff – If the number of matched centroids is less than this number, abort further computation

  • n_maybe – number of small radius centroids for maybe-inlier test

  • n_nb – number of neighboring centroids (besides the central one) for maybe-inlier test

  • n_thresh – Centroid threshold for comparing centroid alignments on the basis of RMSD only.

  • parity_seen – Only attempt centroid alignment if the corresponding parity has not been tried (proper or improper rotations)

  • zprime2 – Flag to align Z’=2 crystals; if False, assume all molecules are equivalent by space group symmetry operations

schrodinger.comparison.neighbors.run_centroid_rmsdn_then_spherical_rmsdn(test_cluster, ref_cluster, matching_cutoff: float = 2, matched_cutoff: int = 15, allow_reflection=True, renumber_rmsd_thresh=0.5, align_cluster=True, pg_symmetry_ops=(), n_thresh: int = 20, zprime2: bool = False)

Return atomic spherical RMSDn and the corresponding aligned cluster from running centroid RMSDn and atomic RMSDn sequentially.

See get_spherical_cluster_RMSDn for full argument docs

Parameters:
  • matching_cutoff – If the centroid of a molecule is within the radius of another molecule from a different cluster, it is considered as matched.

  • matched_cutoff – If the number of matched centroids is less than this number, abort further computation

  • n_thresh – Centroid threshold for comparing spherical cluster alignments on the basis of RMSD only.

  • zprime2 – Flag to align Z’=2 crystals; if False, assume all molecules are equivalent by space group symmetry operations

schrodinger.comparison.neighbors.compute_rmsdn(test_data: List[Structure], ref_data: List[Structure], use_point_group_symmetry=False, skip_centroid_rmsdn=False, matching_cutoff: float = 2, matched_cutoff: Optional[int] = None, renumber_rmsd_thresh=0.5, align_cluster=False, allow_reflection=True, n_thresh: int = 20, zprime2: bool = False) Tuple[int, float, Structure]

Here both test_data and ref_data correspond to 1 crystal structure. They don’t need to have the same Z’ value.

See get_spherical_cluster_RMSDn for full keyword argument docs