Large-scale molecule editing

A collection of functions to ease larger-scale molecule editing, since it can be difficult to get anywhere with the miniscule alteration functions defined in the Molecule interface.

class scine_molassembler.editing.Cleaved

Return type of a cleave operation along a haptic site.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

property component_map
property first
property second
scine_molassembler.editing.add_ligand(a: scine_molassembler.Molecule, ligand: scine_molassembler.Molecule, complexating_atom: int, ligand_binding_atoms: List[int])scine_molassembler.Molecule

Connect two molecules by connecting multiple atoms from one to a single atom of the other via single bonds.

Parameters
  • a – The molecule the ligand is being connected to

  • ligand – The ligand molecule being bound

  • complexating_atom – The atom in a to bind ligand to

  • ligand_binding_atoms – Atoms in ligand to bind to complexating_atom to.

scine_molassembler.editing.cleave(*args, **kwargs)

Overloaded function.

  1. cleave(molecule: scine_molassembler.Molecule, bridge: scine_molassembler.BondIndex) -> scine_molassembler.editing.Cleaved

    Cleave a molecule in two along a bridge bond.

    Bridge bonds are edges in the graph whose removal splits the graph into two connected components. Any bonds in a cycle, for instance, are not bridge bonds.

    param molecule

    Molecule to cleave

    param bridge

    Bond index of bridge bond to cleave.

    return

    A pair of molecules and a component map.

    example

    >>> import scine_utilities as utils
    >>> a = Molecule() # Makes H2
    >>> new_atom = a.add_atom(utils.ElementType.H, 0) # Make linear H3
    >>> cleaved = editing.cleave(a, BondIndex(0, new_atom)) # Split back
    
  2. cleave(molecule: scine_molassembler.Molecule, haptic_site: Tuple[int, int]) -> scine_molassembler.editing.Cleaved

    Cleave a molecule in two along a haptic site.

    Bridge bonds are edges in the graph that whose removal splits the graph into two connected components. Any bonds in a cycle, for instance, are not bridge bonds.

    param molecule

    Molecule to cleave

    param haptic_site

    Atom and site index pair indicating the haptic site to cleave

    return

    A pair of molecules and a component map. The first molecule always contains the atom indicated by haptic_site.

scine_molassembler.editing.connect(left: scine_molassembler.Molecule, right: scine_molassembler.Molecule, left_atom: int, right_atom: int, bond_type: scine_molassembler.BondType)scine_molassembler.Molecule

Connect two molecules by creating a new bond between two atoms from separate molecules

Parameters
  • left – The first molecule

  • right – The second molecule

  • left_atom – The atom from left to connect

  • right_atom – The atom from right to connect

  • bond_type – The bond type with which to connect left_atom and right_atom

scine_molassembler.editing.insert(log: scine_molassembler.Molecule, wedge: scine_molassembler.Molecule, log_bond: scine_molassembler.BondIndex, first_wedge_atom: int, second_wedge_atom: int)scine_molassembler.Molecule

Insert a molecule into a bond of another molecule. Splits log at log_bond, then inserts wedge at the split atoms, connecting the first atom of log_bond with first_wedge_atom and the second log_bond atom with second_wedge_atom.

The bond type of the log_bond is reused in the new bonds formed to the wedge atoms.

Parameters
  • log – The molecule being inserted into

  • wedge – The molecule being inserted into the log

  • log_bond – Log’s bond that wedge should be inserted into

  • first_wedge_atom – The atom of wedge to bond to the first atom in log_bond

  • second_wedge_atom – The atom of wedge to bond to the second atom in log_bond

Returns

The result of the insert operation

scine_molassembler.editing.substitute(*args, **kwargs)

Overloaded function.

  1. substitute(left: scine_molassembler.Molecule, right: scine_molassembler.Molecule, left_bridge: scine_molassembler.BondIndex, right_bridge: scine_molassembler.BondIndex) -> scine_molassembler.Molecule

    Connect two molecules by substituting away the lighter side of a pair of bonds of separate molecules.

    The heavy side is chosen by number of atoms first, then molecular weight if the number of atoms is equal. Should both sides be equal in both, which side is picked is undefined.

    param left

    The first molecule

    param right

    The second molecule

    param left_bridge

    Left’s bridge bond from which to substitute the lighter part away.

    param right_bridge

    Right’s bridge bond from which to substitute the lighter part away.

  2. substitute(left: scine_molassembler.Molecule, right: scine_molassembler.Molecule, left_bridge: scine_molassembler.BondIndex, right_bridge: scine_molassembler.BondIndex, left_substitute_index: int, right_substitute_index: int) -> scine_molassembler.Molecule

    Connect two molecules by substituting away the lighter side of a pair of bonds of separate molecules.

    The heavy side is chosen by number of atoms first, then molecular weight if the number of atoms is equal. Should both sides be equal in both, which side is picked is undefined.

    param left

    The first molecule

    param right

    The second molecule

    param left_bridge

    Left’s bridge bond from which to substitute the lighter part away.

    param right_bridge

    Right’s bridge bond from which to substitute the lighter part away.

    param left_substitute_index

    Left’s atom index to substitute away

    param right_substitute_index

    Right’s atom index to substitute away

scine_molassembler.editing.superpose(top: scine_molassembler.Molecule, bottom: scine_molassembler.Molecule, top_overlay_atom: int, bottom_overlay_atom: int)scine_molassembler.Molecule

Fuse two molecules, adding all adjacencies of one Molecule’s atoms to another

Adds all adjacent atoms and continuations of bottom_overlay_atom in bottom to top_overlay_atom in top. top_overlay_atom’s element type is unchanged as it is the ‘top’ of the superimposition / overlay.

Parameters
  • top – The molecule at the “top” of the superposition.

  • bottom – The molecule at the “bottom” of the superposition.

  • top_overlay_atom – The atom of top that is placed “onto” bottom’s bottom_overlay_atom

  • bottom_overlay_atom – The atom of bottom to place “beneath” top’s top_overlay_atom