Package schrodinger :: Package application :: Package matsci :: Module clusterstruct
[hide private]
[frames] | no frames]

Module clusterstruct

Functions to aid in pulling dimers or clusters of nearest neighbors from a larger structure. Also functions for replacing atoms in neighboring molecules with partial charges for Jaguar calculations.

Copyright Schrodinger, LLC. All rights reserved.

Classes [hide private]
  Neighbor
Neighbor(home_atom, neighbor_atom, dsq)
  SpeciesData
Tracks information about each chemically distinct molecule in a system
  Dimer
Class to hold and process a pair of neighboring molecules.
Functions [hide private]
schrodinger.infra.structure.PBC
create_pbc(struct)
Create an infrastructure PBC
schrodinger.infra.structure.DistanceCell, pbc
create_distance_cell(struct, distance, pbc=None)
Create an infrastructure Distance Cell.
int or None
get_extracted_atom_index(atom_indexes, index)
Get the index of the atom that has atom.index = index in a new structure that would be created by extracting the atoms in atom_indexes
dict
find_atoms_closest_to_atoms(struct, atoms, cell, only_greater=False)
Find all the atoms that are within a certain distance of the provided atoms, returning information about those atoms.
dict
find_molecules_closest_to_atoms(struct, atoms, cell, only_greater=False)
Find all the molecules that are within a certain distance of the provided atoms, returning information about those molecules
list of Dimer
get_dimers_with_molecule(struct, molecule, cell, pbc=None, only_greater=False, struct_index=0)
Get a Dimer object for every molecule within a given distance of the provided molecule
list of Dimer
get_dimers_in_structure(struct, cell=None, pbc=None, distance=None, struct_index=0)
Get a Dimer object for every dimer in struct
 
move_atoms_next_to_atom(pbc, struct1, home_atom, struct2, neighbor_atom, moving_indexes=None)
Move a structure to be at the PBC image that is closest to home_atom.
 
contract_by_molecule(struct, pbc=None, anchors=None)
Contract each molecule in a structure so that all the atoms within a given molecule are at the same PBC image.
 
contract_structure(struct, pbc=None, cell=None, distance=10.0, contract_on_atoms=None, also_keep_stationary=False)
Contract a structure so that the entire structure has chemically sensible coordinates even if the PBC is removed - i.e.
list
create_dimer_structures(struct, atoms, pbc=None, nearest_neighbors=None, cell=None, distance=None)
Create structures for each dimer that the atoms in the atoms list form
schrodinger.structure.Structure
create_nearest_neighbor_cluster(struct, atoms, cell, pbc=None)
Return a structure that has the given atoms surrounded by their nearest neighbor molecules
schrodinger.structure.Structure
create_non_pbc_cluster(struct, molnumbers)
Create a cluster of the given molecules
list
get_all_atoms_marked_as_neighbors(struct)
Return a list of all atom objects in struct that are marked as neighbors
 
add_neighbor_charges_to_jaginput(struct, qprop, jfile)
Add point charges that represent neighboring atoms to an existing jaguar input file.
 
set_neighbor_atoms_basis_set(struct, basis, jfile)
Set all atoms marked as neighbors with the NEIGHBOR_ATOM_PROP property to use the provided basis set.
dict
find_species(structs)
Find all chemically distinct (as determined via unique SMILES strings) species in the given structures
dict, list
compute_esp_charges(structs, basis, species=None, tpp=None, logger=None, quiet=False)
Compute ESP charges for a representative example of each species found in structs.
 
populate_with_charges(structs, species, prop='r_matsci_ESP_Charges')
For every molecule in structs, add an atom property that contains the previously computed charges for the species it belongs to.
dict, list, str
compute_and_populate_charges(structs, basis, tpp=None, logger=None, quiet=False, species=None)
Determine the unique chemical species of each molecule in structs, compute the ESP charges with Jaguar for each species and then apply those charges as atom properties to each atom in structs.
Variables [hide private]
  __doc__ = ...
  NEIGHBOR_ATOM_PROP = 'b_matsci_cluster_neighbor'
  APPROACH_PROP = 'r_matsci_closest_approach_(Angstrom)'
  ESP_CHARGE_PROP = 'r_matsci_ESP_Charges'
  DEFAULT_CHARGE_PROP = 'r_m_charge1'
  BASIS_FLAG = '-basis'
  USE_Q_FLAG = '-use_charges'
  ESP_ARGPARSE_VALUE = 'esp'
  NO_MOLS = 'no'
  ONE_ONLY_MOL = 'one and only one'
  AT_LEAST_ONE_MOL = 'at least one'
  TWO_MOLS = 'two'
  CRITERIA = ['no', 'one and only one', 'at least one', 'two']
  __package__ = 'schrodinger.application.matsci'
Function Details [hide private]

create_pbc(struct)

 

Create an infrastructure PBC

Parameters:
Returns: schrodinger.infra.structure.PBC
The infrastructure PBC created from the Chorus box properties
Raises:
  • ValueError - If the Chorus box properties are not set

create_distance_cell(struct, distance, pbc=None)

 

Create an infrastructure Distance Cell. If struct has the Chorus box properties, the Distance Cell will be PBC-aware.

Parameters:
  • struct (schrodinger.structure.Structure) - The input structure, may have the Chorus box properties
  • distance (float) - The cutoff for finding nearest neighbor atoms
  • pbc (schrodinger.infra.structure.PBC) - The infrastructure PBC for this structure. If not provided, an attempt will be made to create one from the Chorus box properties set on the structure - if this attempt fails, a non-PBC DistanceCell will be created.
Returns: schrodinger.infra.structure.DistanceCell, pbc
An infrastructure Distance Cell that accounts for the PBC, and the pbc used to create it. If no pbc was used, pbc=None. If the pbc was passed in, the same pbc is passed out unchanged.

get_extracted_atom_index(atom_indexes, index)

 

Get the index of the atom that has atom.index = index in a new structure that would be created by extracting the atoms in atom_indexes

Parameters:
  • atom_indexes (list of int) - The atom indexes that will be extracted to form a new structure
  • index (int) - The atom index of the atom of interest
Returns: int or None
The new index of the atom in the extracted structure, or None if index is not found in atom_indexes

find_atoms_closest_to_atoms(struct, atoms, cell, only_greater=False)

 

Find all the atoms that are within a certain distance of the provided atoms, returning information about those atoms.

Parameters:
Returns: dict
Dictionary with keys that are molecule numbers and values that are a list of Neighbor objects for each atom in that molecule that is nearby one of the atoms in the atoms list. Atoms that are nearby multiple atoms in the atoms list will appear multiple times, once for each atom it is nearby.

find_molecules_closest_to_atoms(struct, atoms, cell, only_greater=False)

 

Find all the molecules that are within a certain distance of the provided atoms, returning information about those molecules

Parameters:
Returns: dict
Dictionary with keys that are molecule numbers and values are Neighbor objects for the atom in that molecule that is closest to one of the atoms in the atoms list

get_dimers_with_molecule(struct, molecule, cell, pbc=None, only_greater=False, struct_index=0)

 

Get a Dimer object for every molecule within a given distance of the provided molecule

Parameters:
  • struct (schrodinger.structure.Structure) - The structure object containing the molecules to search
  • molecule (schrodinger.structure._Molecule) - The molecule to find dimers of
  • cell (schrodinger.infra.structure.DistanceCell) - The distance cell to use for finding nearby molecules
  • pbc (schrodinger.infra.structure.PBC) - The PBC object used to create the distance cell
  • only_greater (bool) - Whether to only find Dimers with molecules that have indexes greather than the provided molecule
  • struct_index (int) - An index for the structure that is providing these dimers. This is passed to the Dimer class and can be used by calling routines to track Dimers from different structures.
Returns: list of Dimer
A Dimer object for each dimer that molecule forms

get_dimers_in_structure(struct, cell=None, pbc=None, distance=None, struct_index=0)

 

Get a Dimer object for every dimer in struct

Parameters:
  • struct (schrodinger.structure.Structure) - The structure object containing the dimers to find
  • cell (schrodinger.infra.structure.DistanceCell) - The distance cell to use for finding dimers
  • pbc (schrodinger.infra.structure.PBC) - The PBC object used to create the distance cell
  • distance (float) - The distance to use in creating a distance cell if none is provided
  • struct_index (int) - An index for the structure that is providing these dimers. This is passed to the Dimer class and can be used by calling routines to track Dimers from different structures.
Returns: list of Dimer
A Dimer object for each dimer that molecule forms
Raises:
  • RuntimeError - If neither cell nor distance are provided

move_atoms_next_to_atom(pbc, struct1, home_atom, struct2, neighbor_atom, moving_indexes=None)

 

Move a structure to be at the PBC image that is closest to home_atom. The atoms in the structure are moved as a single group so that they maintain their coordinates relative to each other.

Parameters:

Note: The difference between the method in this function and the pbc.getNearestImages() method for finding atom locations is that this function is guaranteed to move all atoms with the same vector. getNearestImages() is not and can potentially split groups of atoms into different images.

contract_by_molecule(struct, pbc=None, anchors=None)

 

Contract each molecule in a structure so that all the atoms within a given molecule are at the same PBC image. In this case, "same PBC image" means that the molecule has chemically correct coordinates even if the PBC is removed. Thus, it will turn |-- --| into | --|-- where | = pbc wall, - = atoms

Algorithm: Starting at an arbitrary atom (or the anchor atom if provided, #1, contract (move to nearest image) all atoms bound to #1. Keep a list of all atoms contracted. Pick an atom that has been contracted and repeat, adding its neighbors to the list of contracted atoms. Continue until the list of contracted atoms has been exhausted. If all atoms in the structure have been contracted, then work is complete. If some atoms in the structure have not been contracted, this means that there is more than one molecule. Pick an arbitrary new uncontracted atom and return to the top of the Algorithm. Repeat this outer loop until all atoms have been contracted. This algorithm ensures that atoms are always being moved next to an atom they are bonded to rather than an atom that is nearby due to the PBC. It does NOT in any way move molecules near each other except by coincidence.

Parameters:
  • struct (schrodinger.structure.Structure) - The structure to modify
  • pbc (schrodinger.infra.structure.PBC) - The PBC to use in determining images
  • anchors (list) - List of atom indexes that should not be moved and that all other atoms should be contracted towards. Note that the use of anchors means that not all atoms will be moved to the same image if more than one anchor comes from the same molecule and the anchors are not in the same image.
Raises:
  • IndexError - If an anchor index is not an atom index in struct

contract_structure(struct, pbc=None, cell=None, distance=10.0, contract_on_atoms=None, also_keep_stationary=False)

 

Contract a structure so that the entire structure has chemically sensible coordinates even if the PBC is removed - i.e. it uses only a single PBC image and would be suitable for a Jaguar calculation for instance. This involves two steps: 1) contracting each molecule so that the molecule itself is in a single image and then 2) contracting all molecules together so that they are all in the same image. In step 2 molecules close to a core set of atoms will be moved in such a way that preserves their closest possible approach to the core atoms. For computational speed optimization, molecules outside the specified cell/distance will be moved so that an arbitrary atom in the molecule is as close as possible to an arbitrary atom in the core. To avoid this, pass in a cell or distance that uses a large-enough distance that all molecules will fall inside that distance.

Parameters:
  • struct (schrodinger.structure.Structure) - The structure to modify
  • pbc (schrodinger.infra.structure.PBC) - The PBC to use in determining images
  • cell (schrodinger.infra.structure.DistanceCell) - The distance cell to use for finding closest approaches
  • distance (float) - The distance to use for finding closest approaches if cell is not provided
  • contract_on_atoms (list of int) - List of atom indexes that form the core that all other molecules will be contracted towards in step 2. If not provided, the first molecule will be used. Note that these molecules might still move as part of the Step 1 process.
  • also_keep_stationary (bool) - If contract_on_atoms is provided, setting this flag to True will ensure that these atoms do not move during the Step 1 contraction by molecule.

create_dimer_structures(struct, atoms, pbc=None, nearest_neighbors=None, cell=None, distance=None)

 

Create structures for each dimer that the atoms in the atoms list form

Parameters:
  • struct (schrodinger.structure.Structure) - The structure containing the dimers
  • atoms (list of int) - The atom indexes to find dimers for
  • pbc (schrodinger.infra.structure.PBC) - The PBC to use in determining images
  • nearest_neighbors (dict) - Dictionary with keys that are molecule numbers and values are Neighbor objects for the atom in that molecule that is closest to one of the atoms in the atoms list. Such a dictionary is provided by find_molecules_closest_to_atoms.
  • cell (schrodinger.infra.structure.DistanceCell) - The distance cell to use for finding dimers. Either distance or cell must be provided if nearest_neighbors is not provided.
  • distance (float) - The intermolecular distance to use for finding dimers if cell is not provided. Either distance or cell must be provided if nearest_neighbors is not provided.
Returns: list
A list of schrodinger.structure.Structure objects, one for each dimer found
Raises:
  • RuntimeError - If none of nearest_neighbors, cell nor distance are provided

create_nearest_neighbor_cluster(struct, atoms, cell, pbc=None)

 

Return a structure that has the given atoms surrounded by their nearest neighbor molecules

Parameters:
Returns: schrodinger.structure.Structure
A cluster that has the given atoms at the center and all nearest neighbors surrounding them. The given atoms appear first in the structure.

create_non_pbc_cluster(struct, molnumbers)

 

Create a cluster of the given molecules

Parameters:
  • struct (schrodinger.structure.Structure) - The structure to extract molecules from
  • molnumbers (list of int) - The molecule numbers of the molecules to extract
Returns: schrodinger.structure.Structure
A cluster of molecules

get_all_atoms_marked_as_neighbors(struct)

 

Return a list of all atom objects in struct that are marked as neighbors

Parameters:
Returns: list
A list of all atom objects marked with the NEIGHBOR_ATOM_PROP property

add_neighbor_charges_to_jaginput(struct, qprop, jfile)

 

Add point charges that represent neighboring atoms to an existing jaguar input file. A point charge will be written for every atom that has the NEIGHBOR_ATOM_PROP set to True. The charges are added in a &pointch section.

Parameters:
  • struct (schrodinger.structure.Structure) - The structure to extract charges from
  • qprop (str) - The atom property to use as for the charge values
  • jfile (str) - The path to the Jaguar input file

set_neighbor_atoms_basis_set(struct, basis, jfile)

 

Set all atoms marked as neighbors with the NEIGHBOR_ATOM_PROP property to use the provided basis set. The basis set is specified in an &atomic section.

Parameters:
  • struct (schrodinger.structure.Structure) - The structure to extract charges from
  • basis (str) - The basis set to use for neighbor atoms
  • jfile (str) - The path to the Jaguar input file

find_species(structs)

 

Find all chemically distinct (as determined via unique SMILES strings) species in the given structures

Parameters:
Returns: dict
Keys are unique SMILES strings, values are SpeciesData objects for the species with that SMILES string

compute_esp_charges(structs, basis, species=None, tpp=None, logger=None, quiet=False)

 

Compute ESP charges for a representative example of each species found in structs.

Parameters:
  • structs (list of schrodinger.structure.Structure) - The structures to find species in to compute the charges of
  • basis (str) - The basis set to use when computing charges
  • species (dict) - Keys are unique SMILES strings, values are SpeciesData objects for the species with that SMILES string. If not provided, will be computed.
  • tpp (int) - The number of threads per Jaguar job. If not provided, -TPP will not be included in the Jaguar command - the job will run serially.
  • logger (logging.Logger) - The logger to use, if any. If not provided and quiet=False, messages will be printed to the terminal
  • quiet (bool) - If True, do not print or log any messages.
Returns: dict, list
Dict is the species - either those provided or those computed. List is the names of jobs that failed.

populate_with_charges(structs, species, prop='r_matsci_ESP_Charges')

 

For every molecule in structs, add an atom property that contains the previously computed charges for the species it belongs to.

This method expects the list of structs to be the same as the list that species was computed from.

Parameters:
  • structs (list of schrodinger.structure.Structure) - The structures to find species in to compute the charges of
  • species (dict) - Keys are unique SMILES strings, values are SpeciesData objects for the species with that SMILES string.
  • prop (str) - The atom property to set with the new charge
Raises:
  • RuntimeError - If things don't match up, such as structs being shorter than expected, there being a different number of molecules in a given structure, the atoms not being in expected order in a molecule, or a molecule having a different number of atoms than expected.

compute_and_populate_charges(structs, basis, tpp=None, logger=None, quiet=False, species=None)

 

Determine the unique chemical species of each molecule in structs, compute the ESP charges with Jaguar for each species and then apply those charges as atom properties to each atom in structs.

Parameters:
  • structs (list of schrodinger.structure.Structure) - The structures to find species in to compute the charges of
  • basis (str) - The basis set to use when computing charges
  • tpp (int) - The number of threads per Jaguar job
  • logger (logging.Logger) - The logger to use, if any. If not provided and quiet=False, messages will be printed to the terminal
  • quiet (bool) - If True, do not print or log any messages.
  • species (dict) - Keys are unique SMILES strings, values are SpeciesData objects for the species with that SMILES string. If not passed in, will be determined automatically. Must correspond to the structures in structs.
Returns: dict, list, str
Dict is the species computed. List is the names of ESP jobs that failed. str is any error message that occurred during the assignment of computed ESP charges to atoms in structs. If quiet=False, the names of failed jobs and msg will have already been logged.

Variables Details [hide private]

__doc__

Value:
"""
Functions to aid in pulling dimers or clusters of nearest neighbors fr\
om a
larger structure. Also functions for replacing atoms in neighboring mo\
lecules
with partial charges for Jaguar calculations.

Copyright Schrodinger, LLC. All rights reserved.
...