scine_chemoton.reaction_rules.distance_rules¶
Classes
|
Makes each given index unreactive. |
|
Makes each given index reactive. |
|
A rule that decides for each atom index if it is reactive or not according to the defined rule. |
|
An array of logically 'and' connected rules. |
|
An array of logically 'or' connected rules. |
|
A dictionary holding elements as keys and a respective DistanceBasedRule for it. |
|
The functional group is encoded in terms of a central atom type, a dictionary of bonding atoms to the central atom and how often they are bound to the central atom, and the minimum and maximum number of bonds to the central atom. |
|
Allows to define a rule simply based on a distance to another specified element. |
- class scine_chemoton.reaction_rules.distance_rules.AlwaysFalse(*args, **kwargs)[source]¶
Makes each given index unreactive.
- filter_by_rule(*args, **kwargs)[source]¶
Method to be implemented for each rule, giving back whether atom_index is reactive or not.
- Return type:
- Parameters:
- moleculesList[masm.Molecule]
A list of molassembler molecules representing the total system
- idx_mapList[Tuple[int, int]]
An index map generated by molassembler that allows to map the atom_index to the atom in the molecules
- elementsList[str]
A list of all elements
- atom_indexint
The index we rule out or not
- Returns:
- reactivebool
- class scine_chemoton.reaction_rules.distance_rules.AlwaysTrue(*args, **kwargs)[source]¶
Makes each given index reactive.
- filter_by_rule(*args, **kwargs)[source]¶
Method to be implemented for each rule, giving back whether atom_index is reactive or not.
- Return type:
- Parameters:
- moleculesList[masm.Molecule]
A list of molassembler molecules representing the total system
- idx_mapList[Tuple[int, int]]
An index map generated by molassembler that allows to map the atom_index to the atom in the molecules
- elementsList[str]
A list of all elements
- atom_indexint
The index we rule out or not
- Returns:
- reactivebool
- class scine_chemoton.reaction_rules.distance_rules.DistanceBaseRule(*args, **kwargs)[source]¶
A rule that decides for each atom index if it is reactive or not according to the defined rule. The rules are all based on graph distances.
- abstract filter_by_rule(molecules, idx_map, elements, atom_index)[source]¶
Method to be implemented for each rule, giving back whether atom_index is reactive or not.
- Return type:
- Parameters:
- moleculesList[masm.Molecule]
A list of molassembler molecules representing the total system
- idx_mapList[Tuple[int, int]]
An index map generated by molassembler that allows to map the atom_index to the atom in the molecules
- elementsList[str]
A list of all elements
- atom_indexint
The index we rule out or not
- Returns:
- reactivebool
- class scine_chemoton.reaction_rules.distance_rules.DistanceRuleAndArray(rules=None)[source]¶
An array of logically ‘and’ connected rules.
- Parameters:
- rulesOptional[List[DistanceBaseRule]]
A list of bond distance based rules that have all to be fulfilled.
- filter_by_rule(*args, **kwargs)[source]¶
Method to be implemented for each rule, giving back whether atom_index is reactive or not.
- Return type:
- Parameters:
- moleculesList[masm.Molecule]
A list of molassembler molecules representing the total system
- idx_mapList[Tuple[int, int]]
An index map generated by molassembler that allows to map the atom_index to the atom in the molecules
- elementsList[str]
A list of all elements
- atom_indexint
The index we rule out or not
- Returns:
- reactivebool
- class scine_chemoton.reaction_rules.distance_rules.DistanceRuleOrArray(rules=None)[source]¶
An array of logically ‘or’ connected rules.
- Parameters:
- rulesOptional[List[DistanceBaseRule]]
A list of bond distance based rules of which at least one has to be fulfilled.
- filter_by_rule(*args, **kwargs)[source]¶
Method to be implemented for each rule, giving back whether atom_index is reactive or not.
- Return type:
- Parameters:
- moleculesList[masm.Molecule]
A list of molassembler molecules representing the total system
- idx_mapList[Tuple[int, int]]
An index map generated by molassembler that allows to map the atom_index to the atom in the molecules
- elementsList[str]
A list of all elements
- atom_indexint
The index we rule out or not
- Returns:
- reactivebool
- class scine_chemoton.reaction_rules.distance_rules.DistanceRuleSet(kwargs)[source]¶
A dictionary holding elements as keys and a respective DistanceBasedRule for it. All keys are checked for valid element types. Lists as values are automatically transformed to a DistanceRuleAndArray. Booleans as values are automatically transformed to AlwaysTrue or AlwaysFalse
- clear() None. Remove all items from D. ¶
- copy()¶
- classmethod fromkeys(iterable, value=None)¶
- get(k[, d]) D[k] if k in D, else d. d defaults to None. ¶
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- pop(k[, d]) v, remove specified key and return the corresponding value. ¶
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair ¶
as a 2-tuple; but raise KeyError if D is empty.
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D ¶
- update([E, ]**F) None. Update D from mapping/iterable E and F. ¶
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values ¶
- class scine_chemoton.reaction_rules.distance_rules.FunctionalGroupRule(distance, central_atom, n_bonds, specified_bond_partners=None, strict_counts=False)[source]¶
The functional group is encoded in terms of a central atom type, a dictionary of bonding atoms to the central atom and how often they are bound to the central atom, and the minimum and maximum number of bonds to the central atom.
An atom is then termed reactive, if the specified distance in this rule, is the distance between the atom and the central atom. E.g. a hydroxyl group can be specified with an O as a central atom with exactly 2 bonds, one to H and one to C. Based on the distance then different atoms in relation to any found hydroxyl group are termed reactive.
0 makes the O of all hydroxyl groups reactive, 1 makes the C and H of all hydroxyl groups reactive and 2 makes the bonding partners of the C and H of all hydroxyl groups reactive etc.
hydroxyl_d0 = FunctionalGroupRule(0, ‘O’, (2, 2), {‘H’: 1, ‘C’: 1}, True) carbonyl_group_d2 = FunctionalGroupRule(2, ‘C’, (3, 3), {‘O’: 1}, True) imine_group_d0 = FunctionalGroupRule(0, ‘C’, (3, 3), {‘N’: 1}, True) acetal_group_d1 = FunctionalGroupRule(0, ‘C’, (4, 4), {‘O’: 2, ‘H’: 1, ‘C’: 1}, True) acetal_like_group_d1 = FunctionalGroupRule(0, ‘C’, (4, 4), {‘O’: 1, ‘N’: 1, ‘C’: 1, ‘H’: 1}, True) four_or_five_bonded_fe = FunctionalGroupRule(0, ‘Fe’, (4, 5)) acetonitrile_d1 = FunctionalGroupRule(1, ‘C’, (2, 2), {‘N’: 1, ‘C’: 1}, True)
chaining definitions with or is also possible for general bonding pattern with different bonding atoms:
general_acetal_like_d1 = DistanceRuleOrArray([ FunctionalGroupRule(1, 'C', (4, 4), {'O': 2, 'H': 1, 'C': 1}, True), FunctionalGroupRule(1, 'C', (4, 4), {'O': 1, 'N': 1, 'H': 1, 'C': 1}, True), FunctionalGroupRule(1, 'C', (4, 4), {'N': 2, 'H': 1, 'C': 1}, True), FunctionalGroupRule(1, 'C', (4, 4), {'S': 1, 'N': 1, 'H': 1, 'C': 1}, True), FunctionalGroupRule(1, 'C', (4, 4), {'S': 2, 'H': 1, 'C': 1}, True), ])
- Parameters:
- distanceint
The bond distance to the functional group that must be matched.
- central_atomstr
The central atom element symbol.
- n_bondsTuple[int, int]
The minimum and maximum number of bonds to the central atom.
- specified_bond_partnersDict[str, int]
An optional dictionary specifying the elements that further specify the reactive group by being directly bonded to the central atom together with how often they are bonded to the central atom. E.g. a carbonyl can be specified with the central atom O that has exactly 1 bond partner being C, while an ether group can be specified with the central atom O that has exactly 2 bond partner being C. In general, the choice of the central atom is arbitrary, i.e. both groups could also be specified with C being the central atom, see class description.
- strict_countsbool
A flag specifying whether the specified bond partner counts must hold strictly (True) or constitute a minimum number (False). Default: False.
- filter_by_rule(molecules, idx_map, elements, atom_index)[source]¶
Method to be implemented for each rule, giving back whether atom_index is reactive or not.
- Return type:
- Parameters:
- moleculesList[masm.Molecule]
A list of molassembler molecules representing the total system
- idx_mapList[Tuple[int, int]]
An index map generated by molassembler that allows to map the atom_index to the atom in the molecules
- elementsList[str]
A list of all elements
- atom_indexint
The index we rule out or not
- Returns:
- reactivebool
- class scine_chemoton.reaction_rules.distance_rules.SimpleDistanceRule(element, distance)[source]¶
Allows to define a rule simply based on a distance to another specified element. SimpleDistanceRule(‘O’, 1) defines each atom that is directly bonded to an oxygen as reactive.
- Parameters:
- elementstr
Another element defining if the given index is reactive or not
- distanceint
The distance to the other element that defines the rule
- filter_by_rule(molecules, idx_map, elements, atom_index)[source]¶
Method to be implemented for each rule, giving back whether atom_index is reactive or not.
- Parameters:
- moleculesList[masm.Molecule]
A list of molassembler molecules representing the total system
- idx_mapList[Tuple[int, int]]
An index map generated by molassembler that allows to map the atom_index to the atom in the molecules
- elementsList[str]
A list of all elements
- atom_indexint
The index we rule out or not
- Returns:
- reactivebool