schrodinger.application.matsci.rxn_channel module

Classes and functions for building reaction channels.

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.rxn_channel.detect_tetrahedral(bond_vecs)

Detect tetrahedral geometry

Parameters

bond_vecs (list(numpy.array)) – Each item is a numpy.array(x, y, z) for the vector from the atom in question along a bond

Return type

bool

Returns

Whether the atom with these bond vectors is tetrahedral (4 bonds with a bond angle sum >> 360

schrodinger.application.matsci.rxn_channel.trigonal_bonding_vector(bond_vecs, director=None)

Find the optimal 4th bond vector to add to a system with 3 existing bond vectors.

For the case of an atom with 3 bonds, the 4th bond vector should be normal to the plane formed by the 3 bonded atoms. The is true whether the system is trigonal planar or trigonal pyramidal.

Parameters
  • bond_vecs (list(numpy.array)) – Each item is a numpy.array(x, y, z) for the vector from the atom in question along a bond

  • director (numpy.array) – In the case where the chosen bond vector is at a 90 degree angle to the existing bond_vecs, the up/down direction of the bond vector is ambiguous. Choose the direction that best aligns with director.

Return type

numpy.array

Returns

The optimal next bonding vector pointing away from the atom

Raises

RuntimeError – If bond_vecs doesn’t have 3 items

schrodinger.application.matsci.rxn_channel.tetrahedral_bonding_vector(bond_vecs, director=None)

Find the optimal 5th bond vector to add to a system with 4 existing tetrahedral bond vectors.

For tetrahedral systems, the 5th vector gets added anti-parallel to one of the bonding vectors (classic Sn2-type reaction geometry). The first bond is chosen unless director is given, in which case the bond is chosen so that the new bond vector best aligns with the director.

Parameters
  • bond_vecs (list(numpy.array)) – Each item is a numpy.array(x, y, z) for the vector from the atom in question along a bond

  • director (numpy.array) – Chose the antiparallel bond vector that best aligns with this vector.

Return type

numpy.array

Returns

The optimal next bonding vector pointing away from the atom

Raises

RuntimeError – If bond_vecs doesn’t have 4 items

schrodinger.application.matsci.rxn_channel.find_best_match_with_director(candidates, director)

Find the vector in candidates that has the best alignment with director

Parameters
  • candidates (list(numpy.array)) – The vectors to choose from

  • director (numpy.array) – The chosen vector should be the one that aligns most strongly with this vector

Return type

numpy.array

Returns

The vector from candidates that best aligns with director

schrodinger.application.matsci.rxn_channel.find_good_bond_vector(atom, length=1.0, director=None, pbc=None)

Find a good vector to add a new bond given the existing bonds to this atom

Parameters
  • atom ('schrodinger.structure._StructureAtom`) – The atom to find the bond to

  • length (float) – The desired length of the bond vector

  • director (numpy.array) – In some cases, such as trigonal planar and tetrahedral, a simple choice is made by this function between several directions. If a director is supplied, the choice that best aligns with the director will be chosen.

  • pbc (infrastructure.PBC) – If given, will be used to find the closest image of all neighboring atoms

Return type

numpy.array

Returns

An array pointing from the given atom along the new bond vector

schrodinger.application.matsci.rxn_channel.random_choice(collection)

Return a random element from the given collection. Wraps numpy.random.RandomState.choice to allow for multi-dimensional input, i.e. cases where elements are also iterables. Choices are made using a uniform distribution.

Parameters

collection (iterable) – the collection from which to randomly choose an element

Return type

any

Returns

the chosen element, potentially an iterable

class schrodinger.application.matsci.rxn_channel.Constants

Bases: object

Manage some constants.

CHANNEL_FILE = 'CHANNEL_FILE'
NUM_RANDOM_CHANNELS = 0
ALL_RANDOM_CHANNELS = 'all'
NUM_RANDOM_CHANNELS_METAVAR = "INT or 'all'"
ASSOCIATION_TYPE = 'association'
DISSOCIATION_TYPE = 'dissociation'
SINGLE_DISPLACEMENT_TYPE = 'single_displacement'
DOUBLE_DISPLACEMENT_TYPE = 'double_displacement'
ALL_TYPES = 'all'
RANDOM_TYPES_CHOICES = ['association', 'dissociation', 'single_displacement', 'double_displacement', 'all']
DEFAULT_RANDOM_TYPES = ['double_displacement']
RANDOM_SEED = None
ALLOW_ADSORPTION_ONTO = {'graphene': '[c-0X3][c-0X3]([c-0X3]([c-0X3]([c-0X3])[c-0X3])[c-0X3]([c-0X3])[c-0X3])[c-0X3]'}
ALL_SMARTS = 'all'
SMARTS_WILDCARD = '[*]'
ALLOW_ADSORPTION_ONTO_METAVAR = "SMARTS or 'all'"
DISSOCIATION_BOND_LENGTH = 10.0
NO_MINIMIZATION = False
ISOLATE_PRODUCTS = False
NO_REACTIVE_H = False
SUPPORTED_IN_EXTS = ['.mae', '.mae.gz', '.maegz']
UNIQUE = False
schrodinger.application.matsci.rxn_channel.init_random_seed(random_seed, logger)

Process the seed to the random number generator.

Parameters
  • random_seed (None or int) – the seed for the random number generator

  • logger (logging.Logger) – output logger

Return type

int

Returns

final random seed

schrodinger.application.matsci.rxn_channel.is_polymer_builder_grow_atom(atom)

Return True if the given atom is a grow atom prepared by the polymer builder module.

Parameters

atom (schrodinger.structure._StructureAtom) – the atom

Return type

bool

Returns

True if a polymer builder grow atom

schrodinger.application.matsci.rxn_channel.is_mark_monomer_grow_atom(atom)

Return True if the given atom is a grow atom prepared by the mark monomer module.

Parameters

atom (schrodinger.structure._StructureAtom) – the atom

Return type

bool

Returns

True if a mark monomer grow atom

schrodinger.application.matsci.rxn_channel.get_grow_idxs(st, idxs=None)

Return a list of grow indices for the given structure.

Parameters
Return type

list

Returns

grow indices

schrodinger.application.matsci.rxn_channel.remove_grow_properties(st, idxs=None)

Remove the grow properties from atoms in the given structure.

Parameters
schrodinger.application.matsci.rxn_channel.serves_as_backbone_bond(st, idx, jdx)

Return True if the given bond serves as a backbone bond.

Parameters
Return type

bool

Returns

True if serves as a backbone bond

schrodinger.application.matsci.rxn_channel.serves_as_sidechain_bond(st, idx, jdx)

Return True if the given bond serves as a sidechain bond.

Parameters
Return type

bool

Returns

True if serves as a sidechain bond

schrodinger.application.matsci.rxn_channel.valid_polymer_monomer_double_displacement_rxn(st, idx, jdx, kdx, ldx, allow_backbone=True, allow_sidechain=True)

Return True if the given input is for a valid double displacement polymer monomer reaction.

Parameters
  • st (schrodinger.structure.Structure) – the structure containing two molecules

  • idx (int) – the first atom index of the bond in the first molecule

  • jdx (int) – the second atom index of the bond in the first molecule

  • kdx (int) – the first atom index of the bond in the second molecule

  • ldx (int) – the second atom index of the bond in the second molecule

  • allow_backbone (bool) – whether to allow backbone reactions

  • allow_sidechain (bool) – whether to allow sidechain reactions

Return type

bool

Returns

True if a valid reaction

schrodinger.application.matsci.rxn_channel.query_monomers(sts)

Return a list of bools indicating whether the given structures are monomers, i.e. have at least two grow indices.

Parameters

sts (list) – contains schrodinger.structure.Structure

Return type

list

Returns

contains bools indicating whether the given structures are monomers

schrodinger.application.matsci.rxn_channel.are_monomers(sts)

Return True if the given structures are monomers, i.e. have at least two grow indices.

Parameters

sts (list) – contains schrodinger.structure.Structure

Return type

bool

Returns

True if the given structures are monomers

schrodinger.application.matsci.rxn_channel.get_deduped_monomers(sts)

Return a list of smiles deduped monomers.

Parameters

sts (list) – contains schrodinger.structure.Structure

Return type

list, list

Returns

contains smiles deduped monomers, contains filtered titles

class schrodinger.application.matsci.rxn_channel.CacheInfo

Bases: object

Holds caches of computed data to reduce timings

__init__()

Create a CacheInfo instance

fillAdsCache(struct, matches)

Fill the adsorption site cache with atoms from struct

Parameters
  • struct (schrodinger.structure.Structure) – The structure with the atoms to check

  • matches (set) – Atom indexes that are automatically considered adsorption sites

class schrodinger.application.matsci.rxn_channel.ChannelDefinitions(logger=None)

Bases: object

Manage a collection of reaction channel definitions.

BLANK_PATTERN = re.compile('\\s*\\n$')
RANDOM_ALL_TO_ON_THE_FLY_THRESH = 50
MAX_NUM_UNPRODUCTIVE_CYCLES = 1000
DESCRIPTOR_DICT = {'association': 'Association: ', 'dissociation': 'Dissociation: ', 'double_displacement': 'Double Displacement: ', 'single_displacement': 'Single Displacement: '}
__init__(logger=None)

Create an instance.

Parameters

logger (logging.getLogger) – output logger

static flattenChannels(all_channel_defs)

Return a flattened list of channels.

Parameters

all_channel_defs (OrderedDict) – all possible channel definitions, keyed first by channel type and second by reaction type

Return type

list

Returns

a flattened list of channels

addDefinition(str_definition)

Add a reaction channel definition to the list of definitions.

Parameters

str_definition (str) – the string representation of the definition

Return type

bool

Returns

not_accepted, False for an accepted definition, True for a definition that was not accepted

addDefinitionsFromFile(channels_file)

Add reaction channel definitions from an input file to the list of definitions.

Parameters

channels_file (str) – input file containing the definitions of the reaction channels

buildChannelStrDef(atom_a_one, atom_b_one, atom_a_two=None, atom_b_two=None)

Build the string representation of a reaction channel from a sequence of integers.

Parameters
  • atom_a_one (int) – the first atom of the first part of the definition

  • atom_b_one (int) – the first atom of the second part of the definition

  • atom_a_two (int) – the second atom of the first part of the definition

  • atom_b_two (int) – the second atom of the second part of the definition

Return type

str

Returns

str_def, the string representation of the provided reaction channel

getDissociationChannels(reactants, no_reactive_h, caches=None)

Return an OrderedDict of dissociation channel string definitions keyed by type.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • caches (CacheInfo) – Data caches to speed up the calculation

Return type

OrderedDict

Returns

keys are type, values are dissociation channels

getAssociationChannels(reactants, caches=None)

Return an OrderedDict of association channel string definitions keyed by type.

Parameters
Return type

OrderedDict

Returns

keys are type, values are association channels

getSingleDisplacementChannels(reactants, no_reactive_h, unique, caches=None)

Return an OrderedDict of single displacement channel string definitions keyed by type.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • unique (bool) – provide only unique products

  • caches (CacheInfo) – Data caches to speed up the calculation

Return type

OrderedDict

Returns

keys are type, values are single displacement channels

getDoubleDisplacementChannels(reactants, no_reactive_h, unique, no_reactive_polymer_monomer_backbone=False, no_reactive_polymer_monomer_sidechain=False, caches=None)

Return an OrderedDict of double displacement channel string definitions keyed by type.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • unique (bool) – provide only unique products

  • no_reactive_polymer_monomer_backbone (bool) – specify that polymer monomer backbone bonds be considered inert

  • no_reactive_polymer_monomer_sidechain (bool) – specify that polymer monomer sidechain bonds be considered inert

  • caches (CacheInfo) – Data caches to speed up the calculation

Return type

OrderedDict

Returns

keys are type, values are double displacement channels

getAllChannels(reactants, random_types, no_reactive_h, unique, no_reactive_polymer_monomer_backbone=False, no_reactive_polymer_monomer_sidechain=False)

Return a nested OrderedDict of all channel string definitions keyed first by type of channel and second by type of reaction.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • random_types (list) – list of strings specifying which types of channels should be sampled when generating the random reaction channels

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • unique (bool) – provide only unique products

  • no_reactive_polymer_monomer_backbone (bool) – specify that polymer monomer backbone bonds be considered inert

  • no_reactive_polymer_monomer_sidechain (bool) – specify that polymer monomer sidechain bonds be considered inert

Return type

OrderedDict

Returns

all possible channel definitions, keyed first by channel type and second by reaction type

printAllChannels(all_channel_defs)

For each type of sampled channel log the total number of such channels.

Parameters

all_channel_defs (OrderedDict) – all possible channel definitions, keyed first by channel type and second by reaction type

addRandomChannelsFromAll(num_random_channels, random_seed, all_channel_defs, bin_rxn_types=False)

Add the specified number of random channels to the list of channels to be computed by picking a random sample of the size given from the list of all possible channels. If the number of random channels is ‘all’ or greater than or equal to the number of possible channels then pick all of them in order.

Parameters
  • num_random_channels (int or str 'all') – the desired number of random channels to generate

  • random_seed (None or int) – the seed for the random number generator

  • all_channel_defs (OrderedDict) – all possible channel definitions, keyed first by channel type and second by reaction type

  • bin_rxn_types (bool) – if True then when generating random channels first bin by reaction type followed by selecting a random type followed by a random instance, if False then just select a random instance from all instances

addRandomChannelsOnTheFly(reactants, num_random_channels, random_types, no_reactive_h, unique, bin_rxn_types=False, no_reactive_polymer_monomer_backbone=False, no_reactive_polymer_monomer_sidechain=False)

Generate the specified number of random reaction channels without ever precomputing the list of all possible channels.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • num_random_channels (int) – the desired number of random channels to generate

  • random_types (list) – list of strings specifying which types of channels should be sampled when generating the random reaction channels

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • unique (bool) – provide only unique products

  • bin_rxn_types (bool) – if True then when generating random channels first bin by reaction type followed by selecting a random type followed by a random instance, if False then just select a random instance from all instances

  • no_reactive_polymer_monomer_backbone (bool) – specify that polymer monomer backbone bonds be considered inert

  • no_reactive_polymer_monomer_sidechain (bool) – specify that polymer monomer sidechain bonds be considered inert

addRandomChannels(reactants, num_random_channels=0, random_types=['double_displacement'], random_seed=None, allow_adsorption_onto=None, no_reactive_h=False, unique=False, bin_rxn_types=False, no_reactive_polymer_monomer_backbone=False, no_reactive_polymer_monomer_sidechain=False)

Generate the specified number of random reaction channels.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • num_random_channels (int or str) – the desired number of random channels to generate or ‘all’

  • random_types (list) – list of strings specifying which types of channels should be sampled when generating the random reaction channels

  • random_seed (None or int) – the seed for the random number generator

  • allow_adsorption_onto (list) – SMARTS patterns of arbitrary adsorption sites to support

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • unique (bool) – provide only unique products

  • bin_rxn_types (bool) – if True then when generating random channels first bin by reaction type followed by selecting a random type followed by a random instance, if False then just select a random instance from all instances

  • no_reactive_polymer_monomer_backbone (bool) – specify that polymer monomer backbone bonds be considered inert

  • no_reactive_polymer_monomer_sidechain (bool) – specify that polymer monomer sidechain bonds be considered inert

class schrodinger.application.matsci.rxn_channel.ChannelDefinition(str_definition, logger=None)

Bases: object

Manage a reaction channel definition.

PATTERN = re.compile('\\s*(\\d+)\\s*(\\d+)?\\s*;\\s*(\\d+)\\s*(\\d+)?\\s*$')
FIRST_SEP = ';'
SECOND_SEP = ' '
__init__(str_definition, logger=None)

Create an instance.

Parameters
  • str_definition (str) – the string representation of the definition

  • logger (logging.getLogger) – output logger

setChannelAttrs(r_one_a_one, r_two_a_one, r_one_a_two=None, r_two_a_two=None)

Set up some attributes for this class.

Parameters
  • r_one_a_one (int) – the first atom of the first reactant

  • r_two_a_one (int) – the first atom of the second reactant

  • r_one_a_two (int) – the second atom of the first reactant

  • r_two_a_two (int) – the second atom of the second reactant

checkDefStrFormat()

Check the format of the string representation of the definition.

checkAtomUniqueness()

Check for unique atoms.

checkAtomZeroIndex()

Check for an atom index that is zero.

checkDefinition()

Check this reaction channel definition.

class schrodinger.application.matsci.rxn_channel.CheckInput

Bases: object

Manage checking user input.

TITLE_KEY = 's_m_title'
ENTRY_NAME_KEY = 's_m_entry_name'
REACTANT_NAME_BASE = 'reactant'
checkFileExists(infile, logger=None)

Check if the provided input file exists.

Parameters
  • infile (str) – the input file

  • logger (logging.getLogger) – output logger

checkInputFile(infile, logger=None)

Check user input file.

Parameters
  • infile (str) – the input file

  • logger (logging.getLogger) – output logger

checkReactants(reactants, logger=None)

Check the provided reactants structure.

Parameters
checkRandomChannelsInput(reactants, num_random_channels, random_types, random_seed, allow_adsorption_onto, logger=None)

Check parameters for generating random channels.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • num_random_channels (int or 'all') – the number of random channels to generate or ‘all’

  • random_types (list) – list of strings specifying which types of channels should be sampled when generating the random reaction channels

  • random_seed (None or int) – the seed for the random number generator

  • allow_adsorption_onto (list) – SMARTS patterns of arbitrary adsorption sites to support

  • logger (logging.getLogger) – output logger

Return type

int or ‘all’, list, list, set

Returns

num_random_channels, random_types, allow_adsorption_onto as defined above, and matches is a set of atom indicies matching the SMARTS present in allow_adsorption_onto

checkAndProcessAllowAdsorptionOnto(astructure, allow_adsorption_onto, logger=None)

Check and process the allow adsorption onto option.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure

  • allow_adsorption_onto (list) – SMARTS patterns of arbitrary adsorption sites to support

  • logger (logging.getLogger) – output logger

Return type

list, set

Returns

allow_adsorption_onto and matches, final list of SMARTS patterns on which to allow adsorption and a set of atom indicies matching the SMARTS present in allow_adsorption_onto

checkChannelDefs(channeldefs, logger=None)

Check properties of the supplied channel definitions.

Parameters
  • channeldefs (ChannelDefinitions) – list of ChannelDefinitions

  • logger (logging.getLogger) – output logger

checkIfNotAdsorbable(astructure, atom_index, matches)

Check if the provided atom can function as an adsorption site, i.e. check if the atom has any open bonding sites or if the atom belongs to the list of arbitary adsorption sites to allow.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure that contains the atom whose candidacy for adsorption will be checked

  • atom_index (int) – the index of the atom to check

  • matches (set) – a set of atom indicies matching the SMARTS present in the list of allowed adsorption sites

Return type

bool

Returns

False if atom can function as an adsorption site, True otherwise

checkIfNotSimpleBond(astructure, atom_one, atom_two, no_reactive_h, bond_cache=None)

Check if the provided two atoms do not form a simple bond, i.e. a single bond that is not in a ring and possibly does not involve a hydrogen atom.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure on which the simple bond will be checked

  • atom_one (int) – the first atom in the potential bond

  • atom_two (int) – the second atom in the potential bond

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • bond_cache (dict) – keys are (atom1 index, atom2 index), values are the data returned by this method for that bond. Used to speed up multiple calls to this method. This method will populate the dictionary as new bonds are checked.

Return type

list of boolean

Returns

Contains the bool values of whether (1) the two atoms are not bound, (2) the bond they form is not a single bond, (3) the bond they form is in a ring, and (4) if -no_reactive_h has been specified that the bond involves a hydrogen atom. If any of these is True then the bond is not a simple bond.

checkChannelUniqueness(astructure, bond1idx1, bond1idx2, bond2idx1, bond2idx2, smiles_cache=None)

For the provided structure use SMILES analysis to determine if the defined single or double displacement reaction channels, i.e. A + B-C –> A-B + C (1st type) or A-C + B (2nd type) or A-B + C-D –> A-C + B-D (1st type) or A-D + B-C (2nd type), respectively, lead to unique products.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure for which the channels will be checked for uniqueness

  • bond1idx1 (int) – the first atom index of the bond in the first molecule

  • bond1idx2 (int or None) – the second atom index of the bond in the first molecule or None if this is a single displacement channel and there is no bond

  • bond2idx1 (int) – the first atom index of the bond in the second molecule

  • bond2idx2 (int or None) – the second atom index of the bond in the second molecule or None if this is a single displacement channel and there is no bond

  • smiles_cache (dict) – keys are (atom1 index, atom2 index), values are (smiles1, smiles2) the SMILES patterns for the two fragments caused by breaking the atom1-atom2 bond. Used to speed up multiple calls to this method. This method will populate the dictionare as new bonds/SMILES strings are checked.

Return type

list

Returns

two booleans, (1) True if the 1st type should be computed, False otherwise and (2) True if the 2nd type should be computed, False otherwise

checkChannelDefsVsReactants(channeldefs, reactants, matches, no_reactive_h, unique, logger=None)

Check user defined channels against user defined reactants.

Parameters
  • channeldefs (list) – list of ChannelDefinitions

  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • matches (set) – a set of atom indicies matching the SMARTS present in the list of allowed adsorption sites

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • unique (bool) – provide only unique products

  • logger (logging.getLogger) – output logger

Return type

list

Returns

final_channeldefs, list of good ChannelDefinitions

checkDissociationBondLength(dissociation_bond_length, logger=None)

Check the specified dissociation bond length.

Parameters
  • dissociation_bond_length (float) – final bond length to use for dissociative reaction channels

  • logger (logging.getLogger) – output logger

Return type

float

Returns

dissociation_bond_length, final bond length to use for dissociative reaction channels

checkNumRandomChannels(num_random_channels, logger=None)

Check the specified number of random channels.

Parameters
  • num_random_channels (int or 'all') – the desired number of random channels to generate or ‘all’

  • logger (logging.getLogger) – output logger

Return type

int or ‘all’

Returns

num_random_channels, the desired number of random channels to generate or ‘all’

checkRandomTypes(random_types, logger=None)

Check the specified types of random channels.

Parameters
  • random_types (list of strs) – the desired types of random channels to generate

  • logger (logging.getLogger) – output logger

Return type

list of strs

Returns

random_types, the desired types of random channels to generate

checkRandomSeed(random_seed, logger=None)

Check the specified random seed.

Parameters
  • random_seed (None or int) – the seed for the random number generator

  • logger (logging.Logger) – output logger

schrodinger.application.matsci.rxn_channel.get_fragment_smiles(astructure, idx1, idx2)

Return two SMILES patterns of the two molecule fragments that would result from breaking the bond specified by the given two atoms or return the SMILES pattern of the molecule containing idx1 if idx2 is None.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure containing the molecule for which fragment SMILES are wanted

  • idx1 (int) – an atom index

  • idx2 (int) – the atom index for the target bond formed with idx1 or None

Return type

str, str or str, None

Returns

either two strings one for each of two fragments or a single string for the molecule containing idx1 and None

schrodinger.application.matsci.rxn_channel.indicies_from_bonds_deep(astructure, start_atom_index, exclude_atom_indicies=None, depth=None)

Return a list of atom indicies obtained by collecting all atoms that are connected, in the bond traversal sense, to the given start atom by a number of bonds that is less than or equal to that given by the provided depth parameter. The start atom is included in the returned list. One can set a direction for the traversal by specifying exclusion atoms that are bound to the given start atom; the traversal will be done away from these atoms. Useful for doing SMARTS analysis from a central atom and proceeding outwards from that atom, as in nearest-neighbor, next-nearest-neighbor, etc., i. e. shells. Also useful for splitting a molecule into fragments about a given bond.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure containing all atoms

  • start_atom_index (int) – the atom index from which to start the traversal

  • exclude_atom_indicies (list of int) – atom indicies to exclude from the bond traversal which basically sets the direction of the bond traversal, for example in the direction of a certain bond

  • depth (int) – the maximum depth that the traversal is allowed to traverse in terms of the number of bonds from the starting atom

Return type

list of ints

Returns

indicies, atom indicies connected to the start atom by up to the specified bond depth

schrodinger.application.matsci.rxn_channel.set_zob_to_sob(astructure, atom_one, atom_two)

If the given structure has a zero-order bond for the given atom indicies then make this bond a single-order bond.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure for which the bond order may be changed

  • atom_one (int) – the first atom index of the bond whose order needs changing

  • atom_two (int) – the second atom index of the bond whose order needs changing

schrodinger.application.matsci.rxn_channel.wrapper_build_attach_structure(mol_one_st, mol_one_from_atom, mol_one_to_atom, mol_two_st, mol_two_from_atom, mol_two_to_atom)

A wrapper that corrects the atom reorder map returned from build.attach_structure to account for deleted fragment atoms and wraps the case where the active bonds may be of zero-order.

Parameters
  • mol_one_st (schrodinger.structure.Structure) – the base structure to which the fragment will be added

  • mol_one_from_atom (int) – defines the point at which the fragment structure will be added to the base structure

  • mol_one_to_atom (int) – this atom defines the part of the base structure that will be replaced by the fragment

  • mol_two_st (schrodinger.structure.Structure) – the fragment structure to be added to the base structure

  • mol_two_from_atom (int) – defines the point at which the base structure will be added to the fragment structure

  • mol_two_to_atom (int) – this atom defines the part of the fragment structure that will be replaced by the base

Return type

dict, dict

Returns

two mapping dictionaries, (1) orig_to_new_map, a mapping of original indices of atoms in input structures to atom indices in the newly constructed structure. Indices for atoms from the second structure were offset by the number of atoms in the first structure, and (2) new_to_orig_map, the reverse of (1).

schrodinger.application.matsci.rxn_channel.dict_delete_and_decrement_keys(indict, key_to_delete)

Return the dictionary obtained from the input dictionary by deleting an entry with the specified key and then decrementing all keys larger than the specified key. Leave the values unchanged.

Parameters
  • indict (dict) – dictionary with integer keys and values from which to remove and decrement the specified key

  • key_to_delete (int) – the key to delete from the input dictionary

Return type

dict

Return outdict

the new dictionary without the specifed key and with decremented keys

schrodinger.application.matsci.rxn_channel.open_bonding_sites(astructure, atom_index)

Return the number of open bonding sites available for the provided atom in the given structure. This number is the same as the number of unpaired electrons for the atom in its current state in the given structure.

Parameters
  • astructure (schrodinger.structure.Structure) – the structure that contains the provided atom

  • atom_index (int) – the index of the atom for which the number of open bonding sites will be reported

Return type

int

Returns

atom_open_val, the number of open bonding sites for the provided atom

schrodinger.application.matsci.rxn_channel.minimize_geometry(astructure)

Perform a geometry minimization on the provided structure.

Parameters

astructure (schrodinger.structure.Structure) – the structure object needing minimization

Return type

bool

Returns

False if the minimization was successful, True otherwise

schrodinger.application.matsci.rxn_channel.get_bonds_in_molecule(amolecule)

This is a convenience function to get a list of bond objects from a molecule object, since no such function exists in our Python API.

Parameters

amolecule (schrodinger.structure._Molecule) – the molecule object from which bonds will be defined

Return type

list of schrodinger.structure._StructureBond

Returns

bonds, list of bond objects for bonds in the specified molecule

schrodinger.application.matsci.rxn_channel.get_sorted_atomic_smarts(st, all_idxs, outer_sort=False, smarts_cache=None)

Return a tuple of sorted atomic SMARTS for the given collection of indicies in the given structure.

Parameters
  • st (schrodinger.structure.Structure) – the structure

  • all_idxs (list) – contains tuples of atom indices

  • outer_sort (bool) – whether to sort the tuples in the returned list

Return type

list

Returns

contains tuples of sorted atomic SMARTS having the same structure as the input indicies

schrodinger.application.matsci.rxn_channel.get_atom_type_dict(st)

Return an atom type dictionary for the given structure.

Parameters

st (schrodinger.structure.Structure) – the structure

Return type

OrderedDict

Returns

atom type dict, keys are single tuples of SMARTS atom types, like (smarts,), values are lists of single tuples of atom indicies, like (1,)

schrodinger.application.matsci.rxn_channel.get_bond_type_dict(st)

Return a bond type dictionary for the given structure.

Parameters

st (schrodinger.structure.Structure) – the structure

Return type

OrderedDict

Returns

bond type dict, keys are pair tuples of SMARTS bond types, like (smarts, smarts), values are lists of pair tuples of atom indicies, like (1, 2)

schrodinger.application.matsci.rxn_channel.print_allow_adsorption_onto(allow_adsorption_onto, logger=None)

Log the list of allowed adsorption sites.

Parameters
  • allow_adsorption_onto (list) – SMARTS patterns of arbitrary adsorption sites to support

  • logger (logging.getLogger) – output logger

schrodinger.application.matsci.rxn_channel.get_structure_with_contiguous_molecules(molecules)

Return a single structure object containing the given molecules but such that the atom ordering per molecule is contiguous.

Parameters

molecules (list of schrodinger.structure._Molecule) – molecules that need to be contiguously assembled into a single structure

Return type

schrodinger.structure.Structure and two dicts

Returns

mols_st, single structure containing all molecules in contiguous form, and mols_new_to_old and mols_old_to_new, two reordering dictionaries

class schrodinger.application.matsci.rxn_channel.ReactantMolecule(molecule)

Bases: object

Manage a reactant molecule in the reactants structure object.

HYDROGEN_SYM = 'H'
HYDROGEN_BOND_ORDER = 1
__init__(molecule)

Create an instance.

Parameters

molecule (schrodinger.structure._Molecule) – reactant molecule to be extracted from the reactants structure

setReactiveInds(reactive_inds_orig)

Set the two lists of reactive indicies attributes using the provided list of original reactive indicies

Parameters

reactive_inds_orig (list) – original reactive indicies for this reactant molecule

combineMapWith(other_molecule)

Return the new to orig atom reordering map for this molecule extended by that of the other molecule by offsetting the keys of the map of the other molecule.

Parameters

other_molecule (schrodinger.structure._Molecule) – molecule whose new to orig atom reordering map will be combined with that of the current molecule

Return type

dict

Returns

final_map, the combined new to original atom reordering maps of this molecule and the other molecule

addTempHydrogens()

Add a temporary hydrogen to the reactive atom of this molecule to act as a bond handle for performing the reaction. All traces of this temporary hydrogen will be removed from this instance once the reactions are complete. Note that the family of functions that handles the temporary hydrogens are put in place so that all reaction channels can be handled just like the bond-bond double displacement type, i.e. the association and single displacement types then become nothing more than double displacement with a fake hydrogen.

delTempHydrogens()

Delete all traces of the previously added temporary hydrogen.

reactWith(other_molecule, reverse=False)

React this molecule with the provided other molecule according to their reactive indicies and return the product object.

Parameters
  • other_molecule (ReactantMolecule) – the input molecule that this molecule will react with

  • reverse (bool) – specifies to reverse the order of reactive indicies for the other molecule

Return type

Products

Return products

the products object containing the components that result from reacting this molecule with the input molecule

dissociate(dissociation_bond_length)

Dissociate this molecule according to its reactive indicies.

Parameters

dissociation_bond_length (float) – final bond length to use for dissociative reaction channels

Return type

Products

Return products

the products object containing the components that result from reacting this molecule with the input molecule

class schrodinger.application.matsci.rxn_channel.Products(prod_one_st, prod_one_map, prod_one_rev_map, prod_two_st=None, prod_two_map=None, prod_two_rev_map=None)

Bases: object

Manage the properties of the products that result from applying a reaction channel definition to the reactants.

RXN_REPRESENTATION_KEY = 's_matsci_RXN_representation'
PRODUCT_NAME_BASE = 'product'
__init__(prod_one_st, prod_one_map, prod_one_rev_map, prod_two_st=None, prod_two_map=None, prod_two_rev_map=None)

Create an instance.

deleteTmpHydrogens(mol_one, mol_two)

Remove any of the previously added temporary hydrogens from the product structures.

Parameters
buildReorderList(mol_one, mol_two)

Build the atom reorder list needed to make the product structure ordering consistent with that of the original reactants.

Parameters
combineAndReorder()

Assemble the final product structure for this reaction channel by combining the structure objects for each product molecule followed by reordering the product atoms to be consistent with the reactants.

extendWithSpectator(spectator_st, map_to_orig)

Extend the product structure object with the spectator structure object and reorder the atoms to be consistent with that of the reactants from which they came.

Parameters
  • spectator_st (schrodinger.structure.Structure) – the structure object containing all spectator molecules

  • map_to_orig (dict) – an atom reordering dictionary where the keys are the reactant atom indicies followed by the spectator atom indicies and the values are their values

updateProperties(index, channeldef, reverse=False)

Set some properties on this product structure.

Parameters
  • index (int) – index of this set of products

  • channeldef (ChannelDefinition) – the channel definition from which this product came

  • reverse (bool) – specifies that the order of the reactive indicies for the second molecule were reversed

handleMetalBonding(rxn_def, reverse)

Handle zero-order bonds for metals.

Parameters
  • rxn_def (list) – a list of two lists containing the reaction channel definitions in terms of atomic indicies

  • reverse (bool) – specifies that the order of the reactive indicies for the second molecule were reversed

isolateProducts(isolate_products, flatdef)

If requested isolate the individual products to their own structure objects.

Parameters
  • isolate_products (bool) – specifies that products should be returned individually rather than as a whole

  • flatdef (list) – list containing the original reactive atom indicies of the input structure

class schrodinger.application.matsci.rxn_channel.Reactants(allreactants, listdef)

Bases: object

Manage the properties of the reactants.

__init__(allreactants, listdef)

Create an instance.

Parameters
  • allreactants (schrodinger.structure.Structure) – the structure object of the input reactants

  • listdef (list) – a list of two lists containing the reaction channel definitions

splitIntoComponents()

Split the input set of all reactants into reactive molecules and a set of spectator molecules.

updateDefParts()

Update the indicies in the reaction channel definition parts to be consistent with the new reactive molecule ordering.

setReactiveMolecules()

Set the reactive molecule attributes.

class schrodinger.application.matsci.rxn_channel.Channels(reactants, channeldefs, allow_adsorption_onto=None, dissociation_bond_length=10.0, no_minimization=False, isolate_products=False, no_reactive_h=False, unique=False, mae_out_file=None, logger=None)

Bases: object

Manage the enumeration of reaction channels.

OPLS_VERSION = 14
OPLS_ENERGY_KEY = 'r_ff_Potential_Energy'
__init__(reactants, channeldefs, allow_adsorption_onto=None, dissociation_bond_length=10.0, no_minimization=False, isolate_products=False, no_reactive_h=False, unique=False, mae_out_file=None, logger=None)

Create an instance.

Parameters
  • reactants (schrodinger.structure.Structure) – the reactants from which channels will be enumerated

  • channeldefs (ChannelDefinitions) – list of ChannelDefinitions

  • allow_adsorption_onto (None or list) – SMARTS patterns of arbitrary adsorption sites to support

  • dissociation_bond_length (float) – final bond length to use for dissociative reaction channels

  • no_minimization (bool) – specifies that product geometries should not be minimized

  • isolate_products (bool) – specifies that products should be returned individually rather than as a whole

  • no_reactive_h (bool) – specify that R-H bonds be considered inert

  • unique (bool) – provide only unique products, firstly do not calculate redundant products and secondly filter out duplicate final structures using SMILES

  • mae_out_file (str) – the full path, including filename, that will be used to write the output *mae file that will contain the final set of structures, i.e. reactants plus all sets of products

  • logger (logging.getLogger) – output logger

setUpFast3D()

Set up the fast 3D object.

checkInputParams()

Check all input parameters.

updateChannelDefReprs()

Update the representations of the reaction channel definitions.

printChannelDefs()

Provide a formatted log of the final reaction channel definitions.

initMaestroWriter()

Initialize the Maestro writer for the output *mae file and put the reactants structure in there.

termMaestroWriter()

Terminate the Maestro writer for the output *mae file.

processProducts(product_sts)

Process the product structures.

Parameters

product_sts (list of schrodinger.structure.Structure) – contains all product structures for a given reaction channel

enumerateChannels()

Main function to enumerate reaction channels.

checkOutputFile()

Check the output file.

printRxnReprs()

Log a formatted print of all reaction channels in their reaction representation.

printFiltered()

Log the structures that were filtered by SMILES.

printNotMinimized()

Log the structures that were not minimized.

orchestrate()

Orchestrate all of the components of this main class.