besmarts.core.chem module

besmarts.core.chem

The standard definition of a binary encoded SMARTS component of a graph. All nodes and edges have a bechem object embedded within. These define the molecular information contained in the graph.

class besmarts.core.chem.bechem(primitives, select)[source]

Bases: object

Represents a group of atom or bond SMARTS primitives in a graph

all()[source]
any()[source]
bits(maxbits=False) int[source]
bits_max() int[source]
clear()[source]
copy()[source]
disable(field)[source]
enable(field)[source]
fill()[source]
is_null()[source]
is_valid()[source]
primitives: Dict[primitive_key, bitvec]
select: Sequence[primitive_key]
to_fragments()[source]
besmarts.core.chem.bechem_add(a: bechem, b: bechem) bechem[source]
besmarts.core.chem.bechem_align_score(bc: bechem, o: bechem) int[source]

Return the number of overlapping bits

besmarts.core.chem.bechem_all(bc: bechem) bool[source]

Return whether all primitives are full

besmarts.core.chem.bechem_and(a: bechem, b: bechem)[source]
besmarts.core.chem.bechem_and_conditional(a: bechem, b: bechem)[source]
besmarts.core.chem.bechem_any(bc: bechem) bool[source]

Return whether any primitive is not null

besmarts.core.chem.bechem_bits(bc: bechem, maxbits=False, return_all=False) int[source]

Return the number of bits across all selected primitives

besmarts.core.chem.bechem_bits_max(bc: bechem, return_all=False) int[source]

Return the number of bits across all selected primitives

besmarts.core.chem.bechem_check_sane_compare(bc: bechem, o: bechem) bool[source]

Check if it is sane to perform an operation against another object

Raises:

Exception

besmarts.core.chem.bechem_clear(bc: bechem) None[source]

Clear all values in selected primitives

besmarts.core.chem.bechem_copy(bc: bechem) bechem[source]

Return a copy of bc. :returns: cls – The new chem_type object :rtype: type(cls)

besmarts.core.chem.bechem_disable(bc: bechem, field: primitive_key) bool[source]

Deselect a currently enabled primitive

Parameters:
  • field (primitive_key)

  • The primitive to disable

Returns:

Whether the operation was successful

Return type:

bool

besmarts.core.chem.bechem_dispatch_op(bc: bechem, o: bechem, fn) bechem[source]

Broadcast an operation across primitives.

besmarts.core.chem.bechem_enable(bc: bechem, field: primitive_key) bool[source]

Select a currently disabled primitive

Parameters:
  • field (primitive_key)

  • The primitive to enable

Returns:

Whether the primitive was successfully enabled and the selection has been modified

Return type:

bool

besmarts.core.chem.bechem_fill(bc: bechem) None[source]

Fill all selected primitives

besmarts.core.chem.bechem_get(bc: bechem, name: primitive_key, default: bitvec) bitvec[source]
besmarts.core.chem.bechem_iadd(a: bechem, b: bechem) bechem[source]
besmarts.core.chem.bechem_iand(a: bechem, b: bechem)[source]
besmarts.core.chem.bechem_identity(a: bechem, b: bechem = None)[source]
besmarts.core.chem.bechem_ior(a: bechem, b: bechem)[source]
besmarts.core.chem.bechem_is_fragment(bc: bechem) bool[source]

Returns whether the SMARTS has exclusively single values per primitive.

besmarts.core.chem.bechem_is_null(bc: bechem) bool[source]

Returns whether any primitive has no values set.

Return type:

bool

besmarts.core.chem.bechem_is_valid(bc: bechem) bool[source]

Returns whether all primitives have at least one value set, i.e. it can be encoded into valid SMARTS

Return type:

bool

besmarts.core.chem.bechem_isubtract(a: bechem, b: bechem)[source]
besmarts.core.chem.bechem_iter(bc: bechem, skip_ones=False, iter_inverse=False, primitives=None) Generator[bechem, None, None][source]

Generate a copy for every bit across all selected primitives

besmarts.core.chem.bechem_ixor(a: bechem, b: bechem)[source]
besmarts.core.chem.bechem_neg(a: bechem, b: bechem = None)[source]
besmarts.core.chem.bechem_or(a: bechem, b: bechem)[source]
besmarts.core.chem.bechem_recurse_fields(bc: bechem, fields: dict, pos=None) Generator[Dict, None, None][source]

Generate all fragments given the set primitives

besmarts.core.chem.bechem_reduce(bc: bechem) int[source]

Get the sum/number of bits across all selected primitives

besmarts.core.chem.bechem_reduce_longest(bc: bechem, o: bechem) Tuple[int, int][source]

Get the number of bits using another instance to pad if necessary

besmarts.core.chem.bechem_subtract(a: bechem, b: bechem) bechem[source]
besmarts.core.chem.bechem_subtract_conditional(a: bechem, b: bechem) bechem[source]
besmarts.core.chem.bechem_to_fragments(bc: bechem) Sequence[bechem][source]

Return all fragments of that can be generated from the selected primitives

besmarts.core.chem.bechem_xor(a: bechem, b: bechem)[source]