schrodinger.application.canvas.r_group module

Detect r-groups from CanvasMCS, CombiGlide, or SMARTS

Description: A module that contains function to detect r-groups. The core is determined either from CombiGlide results, a user-submitted SMARTS pattern, or a Canvas Maximum Common Substructure.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.canvas.r_group.Data[source]

Bases: object

Class to store intermediary and finals data structures for R-group analysis. Methods starting with add append information on a CT by CT basis to data structures.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

set_prop_list(proplist)[source]

Create list (self.property_list) of every non string property in a ct Checks for existing properties and prevents duplicates

get_prop_list()[source]
add_property_value(prop, value)[source]

Add property value to self.property_values dict Done in order of cts

get_prop_values()[source]
add_bonds_in_rings(lol, index)[source]
get_bonds_in_rings()[source]
add_core_ct(ct)[source]
add_rg_ct(position, ct)[source]
get_rg_ct()[source]
get_attachment_points()[source]
add_attachment_points(ct_data, index)[source]
print_attachment_points()[source]
print_attachment_points_ct(ct_index)[source]
add_rings(rings, i)[source]
get_rings()[source]
add_functional_rings(rings, ct_index)[source]
get_functional_rings()[source]
add_core(core, i)[source]
get_core(index)[source]
get_cores()[source]
add_core_bonds(bonds, i)[source]
get_core_bonds(index)[source]
add_ct_offset(file_offset)[source]
get_ct_offsets()[source]
add_position()[source]
add_r_group(position_number, smiles, ct_index)[source]
get_r_groups()[source]
add_r_groups_to_atom(atom_index, value)[source]
get_r_group_for_atom(atom)[source]
get_r_groups_per_atom()[source]
schrodinger.application.canvas.r_group.add_methyl_ring(ct, principal_bond, bond_list, attachment_positions, output, grow=True)[source]

Add capping methyls to ring like r_groups

Parameters
  • ct (schrodinger.structure.Structure object) – structure that you are adding a capping group to

  • principal_bond (list) – [ _StructureAtom of to_atom, _StructureAtom of from_atom, bond_order ]

  • bond_list (list) – This contains an outer list of all bonds (specified in in the same way as principal_bond) which contain rings that will need to be capped

  • attachment_positions (list) – list of the index of bonds (from the data.r_group_attachment_bonds ), which need to be capped with rings

Returns

Returns a tuple of structure of the fragment, to_atom index and from-atom index

class schrodinger.application.canvas.r_group.TempAtom(x, y, z, index, atomtype, attach='')[source]

Bases: object

__init__(x, y, z, index, atomtype, attach='')[source]

Initialize self. See help(type(self)) for accurate signature.

get_index()[source]
get_x()[source]
get_y()[source]
get_z()[source]
get_type()[source]
set_from_atom()[source]
is_from_atom()[source]
get_attach()[source]
schrodinger.application.canvas.r_group.add_methyl_standard(ct, core_atom, side_atom, output, grow=True)[source]

Breaks bond between core and side atom Grows Carbon off of side-atom, maintaining bond order of core_atom - side_atom bond

Parameters
  • ct (schrodinger.structure.Structure object) – structure that you are adding a capping group to

  • core_atom (int) – index of the core atom

  • side_atom (int) – index of the attachment atom

Returns

Returns a tuple of structure of the fragment, to_atom index and from-atom index

schrodinger.application.canvas.r_group.add_to_data(data, fragment, from_atom, to_atom, to_atom_chirality, j, ct_index)[source]
schrodinger.application.canvas.r_group.checkMultipleMappings(fragment, smiles, from_atom, to_atom)[source]

This function checks whether a given fragment may match SMILES string multiple times. In that case a ‘canonical’ match is selected. In no mapping is found we return (-1, -1) as in previous version of add_to_data function. We assume that calling functions know how to deal with this case.

Parameters
  • fragment (structure.Structure) – r-group structure

  • from_atom (int) – atom index of ‘from’ atom in fragment. This is a core atom that was replaced with a cap group.

  • to_atom (int) – atom index of ‘to’ atom in fragment. This is atom in r-group attached to core.

Parame smiles

SMILES string

Returns

tuple that contains positions of ‘from’ and ‘to’ atoms in SMILES mapping. These values are 0-indexed. If no mapping is found we return (-1, -1).

Return type

tuple

schrodinger.application.canvas.r_group.determine_attachments(core, ct, ct_index, data)[source]
schrodinger.application.canvas.r_group.get_atom_chirality(ct, atom)[source]
schrodinger.application.canvas.r_group.determine_rings_in_attachments(functional_rings, r_group_attachment_bonds)[source]
schrodinger.application.canvas.r_group.determine_attachment_bonds(ct, core, r_groups_per_atom)[source]
:return list of lists. Inner element is the

[core_atom, bonded_atom, bond_order ] of each attachment point

schrodinger.application.canvas.r_group.conglomerate_rings(rings, core)[source]

This function takes the mmssr and combines rings if they are entirely part of the core structure. Since we know in RGA we are never breaking the core structure, this is a safe operation.

Parameters
  • rings – output from a mmsssr calculation on the entire output structure

  • core – list of atoms in the core structure

schrodinger.application.canvas.r_group.bond_in_ring(ring, bond)[source]
schrodinger.application.canvas.r_group.get_connected_ring_bonds(ct_rings, ring)[source]

This function returns any other rings that are also connected to any attachment bonds that are part of the ring fed to the function.

Parameters
  • ct_rings (list) – Outer list is a list of each ring that is stored in the data class. Inner list is an index of the attachment bond that is present in that ring

  • ring (list) – List of attachment bonds that are present in the ring

exception schrodinger.application.canvas.r_group.RGroupException[source]

Bases: Exception

This is a special exception, which is thrown when for some reason r-group calculation can not be completed. When this exception is caught remaining function calls in calculate() function are not made.

classmethod fromSmartsError(err)[source]

This function checks whether an exception err was due to invalid SMARTS pattern.

Parameters

err (Exception) – exception

Returns

exception with specific message

Return type

RGroupException

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class schrodinger.application.canvas.r_group.RGroupFinder(input_file, smarts, temp_dir=None, thread=None, use_mm=1, use_fp_sim=False, sa_seed=None, t_factor=None, tmax_mult=None)[source]

Bases: object

This class is used to find optimal core alignments and determines r-groups for input structures. This is a base class that uses ‘original’ algorithm that tries to minimize the number of r-groups.

__init__(input_file, smarts, temp_dir=None, thread=None, use_mm=1, use_fp_sim=False, sa_seed=None, t_factor=None, tmax_mult=None)[source]

This function creates an instance of RGroupFinder object.

Parameters
  • input_file (str) – name of the input structure file

  • smarts (list) – list of cores SMARTS patterns

  • temp_dir (str) – name of temporary directory

  • thread (calculation_thread) – calculation thread (optional)

  • use_mm (int) – type of multiple matching algorithm (1-SA and 2-DEE)

  • use_fp_sim (bool) – True to use fingerprint similarity between pairs of ‘states’

  • sa_seed (int) – SimualtedAnnealing random generator seed

  • t_factor – SimulatedAnnealing temperature factor

  • tmax_mult (float) – SimualtedAnnealing parameter to set starting temperature

calculate()[source]

This function is called to compute optimal molecule alignment and determine attached r-groups. It defines the order of calls that need to be made as in ‘Template Method’ design pattern. When calculation is done here self.data object can be retrieved to get results.

schrodinger.application.canvas.r_group.get_rgroup_DEE(input_file, SMARTS, temp_dir=None, thread=None, use_mm=1, use_fp_sim=False, sa_seed=None, t_factor=None, tmax_mult=None)[source]
schrodinger.application.canvas.r_group.get_rgroup_SMARTS(input_file, SMARTS, temp_dir=None, thread=None)[source]

Takes input_file and SMARTS_pattern and defines r-groups input_file - input .mae file SMARTS_pattern defining core

schrodinger.application.canvas.r_group.get_rgroup_MCS(input_file, MCS_index, temp_dir=None, thread=None, use_mm=0, use_fp_sim=False, sa_seed=None, t_factor=None, tmax_mult=None)[source]

Determines the core and r-groups using the canvasMCS method.

Parameters
  • input_file (string) – Absolute path to mae file to run the canvasMCS utility on

  • MCS_index (int/str) – atomtyping scheme to use in canvasMCS

  • temp_dir (str) – name of temporary directory

  • thread (calculation_thread) – calculation thread (optional)

  • use_mm (int) – type of multiple matching algorithm (0-Original method, 1-SA and 2-DEE)

  • use_fp_sim (bool) – True to use fingerprint similarity between pairs of ‘states’

  • sa_seed (int) – SimulatedAnnealing random number generator seed. ‘None’ will use the SimulatedAnnealing defaults.

  • t_factor – SimulatedAnnealing temperature factor. ‘None’ will use the SimulatedAnnealing defaults.

  • tmax_mult (float) – SimulatedAnnealing parameter to set starting temperature. ‘None’ will use the SimulatedAnnealing defaults.

schrodinger.application.canvas.r_group.getMCSMatches(input_file, MCS_index, temp_dir=None, thread=None)[source]

This function is used to setup and run MCS calculation on a given input file. It returns a list of matching SMARTS patterns.

Parameters
  • input_file (string) – Absolute path to mae file to run the canvasMCS utility on

  • MCS_index (int/str) – atomtyping scheme to use in canvasMCS

  • temp_dir (str) – name of temporary directory

  • thread (calculation_thread) – calculation thread (optional)

Returns

list of matching SMARTS patterns

Return type

list

schrodinger.application.canvas.r_group.find_best_core_match(ct, cores, ref_ct=None, ref_core=None)[source]
schrodinger.application.canvas.r_group.write_core_only(structure, attachment_points, core_indexes, core_bonds, temp_dir=None)[source]
schrodinger.application.canvas.r_group.add_ct_data(data, core, ct, ct_index)[source]

Add to the determine the rings and r-groups per atom for each ct and add the following data structures: data.add_functional_rings data.add_rings data.add_r_groups_to_atom

Parameters
  • core (list) – list of atoms belonging to the core

  • ct (schrodinger.structure.Structure object) – structure object corresponding to the core atoms

schrodinger.application.canvas.r_group.write_output(data, input_file, smarts, cli=False, temp_dir=None, thread=None, settings=None)[source]

This function writes RGA results to output files.

Parameters
  • data (Data) – data object that contains calculation results

  • input_file (str) – name of input file used in calculation

  • smarts (bool) – True when MCS/SMARTS method was used and False otherwise

  • cli (bool) – True if RGA was run from CL without GUI (this is a guess!)

  • temp_dir (str) – name of temporary directory

  • thread (calculation_thread) – thread used to run RGA calculation

Return type

Settings

Returns

Settings data object, which is used in RGA GUI

schrodinger.application.canvas.r_group.determine_rgroup_indexes(ct, number_of_groups)[source]
schrodinger.application.canvas.r_group.evaluate_smarts_ex(structure, smarts, stereo='annotation_and_geom', start_index=1, uniqueFilter=False, allowRelativeStereo=False, rigorousValidationOfSource=False, hydrogensInterchangeable=True)[source]

Evaluate SMARTS patterns using the Canvas libraries.

Returns a list of lists of ints. Each list of ints is a list of atom indices matching the SMARTS pattern.

Parameters
  • structure (Structure or schrodinger.application.canvas.base.ChmMol) – Structure to search for matching substructures.

  • smarts (str) – SMARTS string used to match substructures.

  • stereo (enum) – Specify how to determine the stereochemistry of a ChmMol from a Structure. Can be STEREO_FROM_GEOMETRY, STEREO_FROM_ANNOTATION, STEREO_FROM_ANNOTATION_AND_GEOM, or NO_STEREO. See schrodinger.structutils.smiles.SmilesGenerator.__init__ for descriptions of these options.

  • start_index (int) – Specify the start index of the atom indices returned. Defaults to Structure mode, which is 1-based. Pass in 0 for 0-based indices.

Return type

list

Returns

Each value is a list of atom indices matching the SMARTS pattern.

schrodinger.application.canvas.r_group.import_canvas()[source]

Perform a lazy import of canvas libraries to speed up loading time.