besmarts.core.primitives module¶
besmarts.core.primitives
Standard definitions of SMARTS primitives.
- class besmarts.core.primitives.primitive_codec(implements, smarts_prefix)[source]¶
Bases:
object- decode_int(x: int) int[source]¶
Transform a decoded integer into its value for SMARTS/SMILES. The default behavior is a passthrough and works for most primitives, such as element and hydrogen. Special behavior for certain primitives e.g. formal charge, must be handled by subclassing.
- Parameters:
x (int) – The integer to decode
- Returns:
The decoded integer
- Return type:
int
- decode_smarts(dtype, obj) bitvec[source]¶
Parse and decode a SMARTS atom or bond for a primitive.
- Parameters:
dtype (array) – The class used to store the decoded values
obj (str) – The atom or bond string to parse and decode
- Returns:
The decoded SMARTS as an array of bits
- Return type:
- encode_int(x: int) int[source]¶
Transform an integer parsed from a SMILES or SMARTS representation to a valid value for storing in a bit array. The default behavior is a passthrough and works for most primitives, such as element and hydrogen. Special behavior for certain primitives e.g. formal charge, must be handled by subclassing.
- Parameters:
x (int) – The integer to encode
- Returns:
The encoded integer
- Return type:
int
- encode_smarts(arr: bitvec) str[source]¶
Transform a primitive as a bit array to a SMARTS string.
- Parameters:
arr (array) – The primitive in the form of a bit array
- Returns:
The SMARTS string represented the array. Note that if the primitive has no values set, it is not a valid SMARTS string and “_” will be returned
- Return type:
str
- class besmarts.core.primitives.primitive_key(*args, **kwds)[source]¶
Bases:
object- AROMATIC = 'aromatic'¶
- BOND_ORDER = 'bond_order'¶
- BOND_RING = 'bond_ring'¶
- CHIRALITY = 'chirality'¶
- CONNECTIVITY_RING = 'connectivity_ring'¶
- CONNECTIVITY_TOTAL = 'connectivity_total'¶
- ELEMENT = 'element'¶
- FORMAL_CHARGE = 'formal_charge'¶
- HYDROGEN = 'hydrogen'¶
- LINK_DST = 'link_dst'¶
- LINK_SRC = 'link_src'¶
- RING_SMALLEST = 'ring_smallest'¶
- UNIT = 'unit'¶
- UNIT_INDEX = 'unit_index'¶
- VALENCE = 'valence'¶
- VARIABLE = 'variable'¶