def get_asa_fragments(qd: Molecule) -> Tuple[List[Molecule], Molecule]: """Construct the fragments for an activation strain analyses. Parameters ---------- qd : |plams.Molecule| A Molecule whose atoms' properties should be marked with `pdb_info.ResidueName`. Atoms in the core should herein be marked with ``"COR"``. Returns ------- :class:`list` [|plams.Molecule|] and |plams.Molecule| A list of ligands and the core. Fragments are defined based on connectivity patterns (or lack thereof). """ # Delete all atoms within the core mol_complete = qd.copy() core = Molecule() core.properties = mol_complete.properties.copy() core_atoms = [at for at in mol_complete if at.properties.pdb_info.ResidueName == 'COR'] for atom in core_atoms: mol_complete.delete_atom(atom) atom.mol = core core.atoms = core_atoms mol_complete.properties.name += '_frags' core.properties.name += '_core' # Fragment the molecule ligand_list = mol_complete.separate() # Set atomic properties for at1, at2 in zip(chain(*ligand_list), mol_complete): at1.properties.symbol = at2.properties.symbol at1.properties.charge_float = at2.properties.charge_float for at1, at2 in zip(core, qd): at1.properties.symbol = at2.properties.symbol at1.properties.charge_float = at2.properties.charge_float # Set the prm parameter which points to the created .prm file name = mol_complete.properties.name[:-1] path = mol_complete.properties.path prm = mol_complete.properties.prm for mol in ligand_list: mol.properties.name = name mol.properties.path = path mol.properties.prm = prm return ligand_list, core
def separate_mod(self) -> Tuple[Molecule]: """Modified PLAMS function: creates new molecules out of this instance rather than a copy of this instance. Atoms, bonds and properties are *not* copied. Separate the molecule into connected components. Returns is a list of new Molecule instrances (all atoms and bonds are disjoint with the original molecule). Each element of this list is identical to one connected component of the base molecule. A connected component is a subset of atoms such that there exists a path (along one or more bonds) between any two atoms. Returns ------- |tuple|_ [|plams.Molecule|_] A list of molecules with atoms and bonds from **self**. """ # noqa: E501 frags = () for at in self: at._visited = False def dfs(v, mol): v._visited = True v.mol = mol for e in v.bonds: e.mol = mol u = e.other_end(v) if not u._visited: dfs(u, mol) for src in self.atoms: if not src._visited: m = Molecule() dfs(src, m) frags += (m, ) m.properties = self.properties.copy() for at in self.atoms: del at._visited at.mol.atoms.append(at) for b in self.bonds: b.mol.bonds.append(b) return frags