utils#

class konnektor.utils.toy_data.EmptyMapper#

Bases: AtomMapper

Build a Mapper that only has use for dummy mappings. Generates empty mappings.

suggest_mappings(molA, molB) AtomMapping#

Suggests possible mappings between two Components

Suggests zero or more AtomMapping objects, which are possible atom mappings between two Component objects.

class konnektor.utils.toy_data.RandomScorer(n: int, rand_seed: int | None = None)#

Bases: object

Builds a scorer that contains a predefined matrix scores of size n x n, where each score is assigned from a uniform random distribution between 1 and 0 upon initialization. The use of this class is currently envisioned for toy data and testing.

Parameters:
  • n (int) – number of scores to build

  • rand_seed (int) – random number seed for the random scores.

get_score(mapping: AtomMapping) float#

Retrieve the score from the score matrix at index corresponding to the integer names of componentA and componentB in the mapping.

Parameters:

mapping (AtomMapping) – The mapping to retrieve the score for - names must be integers within (0, n)

Returns:

Score corresponding the given AtomMapping

Return type:

float

konnektor.utils.toy_data.build_n_random_mst_network(n_compounds=30, rand_seed=42, sub_networks: int = 2, overlap: int = 1, uni_score: bool = False) tuple[LigandNetwork, LigandNetwork]#

This function returns a randomized toy mst graph.

Parameters:
  • n_compounds (int) – number of artificial compounds

  • rand_seed (int) – random seed number

  • uni_score

  • mapping (whether to use always the score of 1 for an atom)

Returns:

the toy mst network

Return type:

LigandNetwork

konnektor.utils.toy_data.build_random_dataset(n_compounds: int = 20, rand_seed: int | None = None)#

This function builds a random dataset of n_compounds artificial molecules. Additionally the generic scorer and mapper matching the compounds is returned.

Parameters:
  • n_compounds (int) – number of artificial molecules to build

  • rand_seed (int) – random number seed.

Returns:

compounds, mapper, scorer

Return type:

(Iterable[SmallMoleculeComponent], AtomMapper, AtomMappingScorer)

konnektor.utils.toy_data.build_random_fully_connected_network(n_compounds=30, rand_seed=42, uni_score: bool = False) LigandNetwork#

This function returns a randomized toy fully connected graph.

Parameters:
  • n_compounds (int) – number of artificial compounds

  • rand_seed (int) – random seed number

  • uni_score – whether to use always the score of 1 for an atom mapping

Returns:

the toy fully connected network

Return type:

LigandNetwork

konnektor.utils.toy_data.build_random_mst_network(n_compounds=30, rand_seed=42, uni_score: bool = False) LigandNetwork#

This function returns a randomized toy mst graph.

Parameters:
  • n_compounds (int) – number of artificial compounds

  • rand_seed (int) – random seed number

  • uni_score

  • mapping (whether to use always the score of 1 for an atom)

Returns:

the toy mst network

Return type:

LigandNetwork