MolecularDiffusion.modules.models.syncogen.api.rdkit.assembly

Attributes

Classes

FragmentInstance

A class to represent an instance of a fragment in our fragment set.

RDKitMoleculeAssembly

A class to represent a molecule assembly. Has both an underlying fragment graph and an underlying atom graph.

Module Contents

class MolecularDiffusion.modules.models.syncogen.api.rdkit.assembly.FragmentInstance(smiles: str, frag_order: int, global_frag_id: int)

A class to represent an instance of a fragment in our fragment set.

atom_graph
frag_order
global_frag_id
smiles
class MolecularDiffusion.modules.models.syncogen.api.rdkit.assembly.RDKitMoleculeAssembly(fragment_graph: networkx.Graph = None, atom_graph: networkx.Graph = None)

A class to represent a molecule assembly. Has both an underlying fragment graph and an underlying atom graph. Fragment node ids are just the order in which they are added. Each fragment knows about its reaction center occupation statuses.

add_edge(node_a: FragmentInstance, node_b: FragmentInstance)
add_fragment(new_frag_global_id: int, reaction_id: int | None = None, self_frag_order: int | None = None, self_reaction_center_idx: int | None = None, other_reaction_center_idx: int | None = None)

Add a new fragment to the molecule fragment graph.

Parameters:
  • new_frag_global_id (int) – The global id of the new fragment as indexed by our vocabulary.

  • reaction_id (int) – The reaction id of the reaction used to add the new fragment.

  • self_frag_order (int) – The fragment order in order of addition (0, 1, 2, 3) of the fragment in our graph that the new fragment is being added to.

  • self_reaction_center_idx (int) – The index of the reaction center we want to occupy on the fragment in our graph.

  • other_reaction_center_idx (int) – The index of the reaction center we want to occupy on the other fragment.

Returns:

The updated fragment and atom graphs.

add_node(node: FragmentInstance, global_frag_id: int, rxn_center_available: List[bool])
all_open_reaction_centers()

Returns a list of all open reaction centers in the molecule fragment graph.

copy()

Return a deep copy of the molecule fragment graph, including both the fragment graph and atom graph.

frag_idx_to_atom_graph(frag_order: int)
num_fragments()
to_mol(sanitize: bool = True)

Converts the atom graph representation back to an RDKit molecule. Reconstructs an RDKit molecule by mapping graph nodes to atoms while preserving stereochemistry and formal charges.

to_smiles()

Converts the atom graph representation back to a SMILES string.

update_atom_graph(new_fragment_instance: FragmentInstance, reaction: str, self_frag_order: int, new_frag_order: int, self_reaction_center_idx: int, other_reaction_center_idx: int)

Update the atom graph to add a new fragment.

atom_graph
fragment_graph
MolecularDiffusion.modules.models.syncogen.api.rdkit.assembly.BOND_TYPE_MAP