schrodinger.application.matsci.smartsutils module¶
Utilities for working with SMARTS patterns
Copyright Schrodinger, LLC. All rights reserved.
- class schrodinger.application.matsci.smartsutils.SMARTSGroupData(number, name, pattern, indexes)¶
Bases:
tuple
- __contains__(key, /)¶
Return key in self.
- __len__()¶
Return len(self).
- count(value, /)¶
Return number of occurrences of value.
- index(value, start=0, stop=9223372036854775807, /)¶
Return first index of value.
Raises ValueError if the value is not present.
- indexes¶
Alias for field number 3
- name¶
Alias for field number 1
- number¶
Alias for field number 0
- pattern¶
Alias for field number 2
- schrodinger.application.matsci.smartsutils.defines_integer_atom_props(st)[source]¶
Return True if the given structure has SMARTS-related integer atom properties defined. These properties were originally used when each atom was forced to belong to a single SMARTS group. That condition has been relaxed but these properties are kept for backwards compatibility.
- Parameters
st (schrodinger.structure.Structure) – the structure
- Return type
bool
- Returns
True if such properties are defined
- schrodinger.application.matsci.smartsutils.get_group_names(atom)[source]¶
Return a list of group names for the given atom.
- Parameters
atom (schrodinger.structure._StructureAtom) – the atom
- Return type
list
- Returns
group names
- schrodinger.application.matsci.smartsutils.get_group_atom_indices(atom)[source]¶
Return a list of group atom indices for the given atom.
- Parameters
atom (schrodinger.structure._StructureAtom) – the atom
- Return type
list
- Returns
group atom indices
- schrodinger.application.matsci.smartsutils.get_group_numbers(atom)[source]¶
Return a list of group numbers for the given atom.
- Parameters
atom (schrodinger.structure._StructureAtom) – the atom
- Return type
list
- Returns
group numbers
- schrodinger.application.matsci.smartsutils.append_property(atom, key, value)[source]¶
Append the given property to the atom.
- Parameters
atom (schrodinger.structure._StructureAtom) – the atom
key (str) – the property key
value (str) – the property value
- schrodinger.application.matsci.smartsutils.validate_name(name)[source]¶
Make sure name has the correct set of characters
- Parameters
name (str) – The string to check
- Return type
bool
- Returns
True if name has no invalid characters, False if any characters are invalid
- exception schrodinger.application.matsci.smartsutils.SMARTSGroupError[source]¶
Bases:
Exception
Class for exceptions related to SMARTS group finding
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- schrodinger.application.matsci.smartsutils.delete_group_properties(struct)[source]¶
Delete all SMARTS group properties (structure and atom) from the structure
- Parameters
struct (
schrodinger.structure.Structure
) – The structure to delete properties from
- schrodinger.application.matsci.smartsutils.find_group_data(struct)[source]¶
Find an SMARTS group data on the structure
- Parameters
struct (
schrodinger.structure.Structure
) – The structure to find groups on- Return type
dict
- Returns
A dictionary. Keys are smarts group numbers, values are
SMARTSGroupData
named tuples for the SMARTS group with that number- Raises
SMARTSGroupError – If something in the data is not consistent
- schrodinger.application.matsci.smartsutils.get_rdkit_atoms(smarts)[source]¶
Return a collection of rdkit atoms for the given SMARTS. The return value has the length of a potential match group, for example for ‘cc’ this length is 2, for ‘[$([NH]([CH2])[CH2])]C’ it is 2, for [n-0X2].[n-0X2] it is 2, etc., even though there might be any number of matches if the pattern was matched.
- Parameters
smarts (str) – the SMARTS pattern
- Raises
RuntimeError – if rdkit has a problem with the SMARTS
- Return type
rdkit.Chem.rdchem._ROAtomSeq
- Returns
the rdkit atoms
- schrodinger.application.matsci.smartsutils.is_smarts_bonding_pair(smarts)[source]¶
Return True if the given SMARTS would match a bonding pair, False otherwise.
- Parameters
smarts (str) – the SMARTS pattern
- Return type
bool
- Returns
True if the SMARTS would match a bonding pair, False otherwise
- class schrodinger.application.matsci.smartsutils.SMARTSGroup(name, pattern, logger=None)[source]¶
Bases:
object
Handles matching and record-keeping for a SMARTS patter
- __init__(name, pattern, logger=None)[source]¶
Create a SMARTSGroup object
- Parameters
name (str) – The name of this SMARTS group
pattern (str) – The SMARTS pattern for this group
- Raises
ValueError – If name has invalid characters
ValueError – If the SMARTS is invalid
- nextNumber(numbers_used)[source]¶
Get the next unused group number
- Parameters
numbers_used (set) – Each member is a number that has already been used for a group and is unavailable. The number returned by this function is added to the numbers_used set.
- Return type
int
- Returns
The lowest available number. This number will have been added to the numbers_used set.
- orderedMatches(struct, backbone_atoms)[source]¶
Evaluate the smarts pattern matches, where matches are ordered to follow network sequence. Consider backbone atoms matches first in the sequence and the side chian matches are then ordered according to atom index.
- Parameters
struct (schrodinger.structure.Structure) – The structure to delete properties from
backbone_atoms (dict) – dictionary with key as molecule number and backbone atoms index ordered in a list
- Return list(list)
List of list containing the smart pattern matches
- match(struct, numbers_used, backbone_atoms, allow_partial_overlap=False)[source]¶
Find all the SMARTS groups matching the SMARTS pattern and mark them with the appropriate properties
- Parameters
struct (schrodinger.structure.Structure) – The structure to delete properties from
numbers_used (set) – A set of all the group numbers that have been used and are unavailable
backbone_atoms (dict) – dictionary with key as molecule number and backbone atoms index ordered in a list
allow_partial_overlap (bool) – whether atoms can belong to multiple groups