Source code for schrodinger.application.desmond.smarts

"""
SMARTS matching utility using MMPATTY. This utility is used in Desmond setup
and should not be modified to use canvaslib due to the lack of support for
zeor-order-bond patterns.
"""

from schrodinger.structutils.analyze import evaluate_multiple_smarts


[docs]def evaluate_matched_list(matched_list): """ Function to flatten and de-duplicate atoms matched in multiple SMARTS pattern. Atom indices are sorted in ascending values. :type matched_list: list :param matched_list: List of atom sets each matches a SMARTS pattern :rtype: list :return: A list of non-duplicate atom indices representing the union of multiple SMARTS pattern. """ flattened_set = set() for matches in matched_list: flattened_set.update(set(matches)) return sorted(flattened_set)
[docs]def evaluate_net_smarts(structure, smarts_list, excl_smarts_list, verbose=False): """ Search for substructures in `Structure` `structure` matching the SMARTS pattern `smarts_expression`. Returns a list of lists of ints. Each list of ints is a list of atom indices matching the SMARTS pattern while not in the exclusion SMARTS pattern :type structure: `Structure` :param structure: Structure to search for matching substructures. :type smarts_list: list :param smarts_list: List of SMARTS strinsg used to match substructures. :type excl_smarts_list: list :param excl_smarts_list: List of SMARTS strings whose matched atoms will be excluded from the returned match. :type verbose: bool :param verbose: If True, print additional progress reports from the C implementation. :rtype: list :return: A list of atom indices matching the SMARTS pattern and not in the exclusion SMARTS pattern. """ incl_list = evaluate_multiple_smarts(structure, smarts_list, verbose, unique_sets=True) excl_list = evaluate_multiple_smarts(structure, excl_smarts_list, verbose, unique_sets=True) incl_list = evaluate_matched_list(incl_list) excl_list = evaluate_matched_list(excl_list) return_list = list(set(incl_list) - set(excl_list)) return return_list