Esempio n. 1
0
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()
Esempio n. 2
0
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)
Esempio n. 3
0
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
Esempio n. 4
0
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()