def test_remove_atom_mapping(): mol = Molecule(smiles="C[C:5]CCO") assert mol.has_atom_mapping() mol.remove_atom_mapping() assert not mol.has_atom_mapping()
def reactants_to_fingerprint(args, config): """ Convert a SMILES string of reactants to a fingerprint :param args: the SMILES in the first element :type args: tuple :param config: the settings :type config: Config :return: the fingerprint :rtype: numpy.ndarray """ reactants_smiles = args[0] fingerprints = [] for smiles in reactants_smiles.split("."): try: mol = Molecule(smiles=smiles, sanitize=True) except MoleculeException: pass else: if mol.has_atom_mapping(): fingerprints.append( mol.fingerprint( config["fingerprint_radius"], config["fingerprint_len"] ) ) return sum(fingerprints)
def create_reactants_molecules(reactants_str: str) -> List[Molecule]: """ Create Molecule objects from a SMILE string of reactants. Only molecules with atom mapping is kept. :param reactants_str: the SMILES string of the reactants :return: the Molecule objects """ mols = [] for smiles in reactants_str.split("."): try: mol = Molecule(smiles=smiles, sanitize=True) except MoleculeException: pass else: if mol.has_atom_mapping(): mols.append(mol) return mols
def test_has_atom_mapping(): mol1 = Molecule(smiles="CCCCO") mol2 = Molecule(smiles="C[C:5]CCO") assert not mol1.has_atom_mapping() assert mol2.has_atom_mapping()