Esempio n. 1
0
def test_enumerating_stereoisomers_poor_input(toolkit):
    """
    Test stereoisomer enumeration with an impossible stereochemistry.
    """

    toolkit_name, toolkit_class = toolkit
    if toolkit_class.is_available():
        molecule = Molecule.from_smiles("C=CCn1c([C@@H]2C[C@@H]3CC[C@@H]2O3)nnc1N1CCN(c2ccccc2)CC1")
        enumerate_stereo = workflow_components.EnumerateStereoisomers()
        # the molecule should fail conformer generation
        enumerate_stereo.toolkit = toolkit_name
        enumerate_stereo.undefined_only = True
        enumerate_stereo.rationalise = True

        result = enumerate_stereo.apply(molecules=[molecule, ], processors=1)
        assert result.n_molecules == 0
        assert result.n_filtered == 1

        # now turn of rationalise
        enumerate_stereo.rationalise = False
        result = enumerate_stereo.apply([molecule, ], processors=1)
        assert molecule in result.molecules
        assert result.n_molecules == 1

        # now enumerate all stereo and rationalise
        enumerate_stereo.rationalise = True
        enumerate_stereo.undefined_only = False
        # make sure the input is missing and new isomers are found

        result = enumerate_stereo.apply([molecule, ], processors=1)
        assert molecule not in result.molecules
        assert molecule in result.filtered

    else:
        pytest.skip(f"Toolkit {toolkit_name} is not available.")
Esempio n. 2
0
def test_enumerating_stereoisomers_apply(toolkit):
    """
    Test the stereoisomer enumeration.
    """

    toolkit_name, toolkit_class = toolkit
    if toolkit_class.is_available():

        enumerate_stereo = workflow_components.EnumerateStereoisomers()
        # set the options
        enumerate_stereo.toolkit = toolkit_name
        enumerate_stereo.undefined_only = True
        enumerate_stereo.rationalise = True

        mols = get_stereoisomers()

        result = enumerate_stereo.apply(mols, processors=1)
        for mol in mols:
            assert mol in result.molecules

        # make sure no molecules have undefined stereo
        for molecule in result.molecules:
            assert Molecule.from_smiles(molecule.to_smiles(), toolkit_registry=RDKitToolkitWrapper()) == molecule
            assert molecule.n_conformers >= 1

    else:
        pytest.skip(f"Toolkit {toolkit_name} is not available.")
def test_enumerating_stereoisomers_validator():
    """
    Test the validators in enumerating stereoisomers.
    """
    enumerate_stereo = workflow_components.EnumerateStereoisomers()

    enumerate_stereo.undefined_only = "y"
    assert enumerate_stereo.undefined_only is True

    enumerate_stereo.max_isomers = 1.1
    assert enumerate_stereo.max_isomers == 1
def test_enumerating_stereoisomers_poor_input():
    """
    Test stereoisomer enumeration with an impossible stereochemistry.
    """

    molecule = Molecule.from_smiles(
        "C=CCn1c([C@@H]2C[C@@H]3CC[C@@H]2O3)nnc1N1CCN(c2ccccc2)CC1")
    enumerate_stereo = workflow_components.EnumerateStereoisomers()
    # the molecule should fail conformer generation
    enumerate_stereo.undefined_only = True
    enumerate_stereo.rationalise = True

    result = enumerate_stereo.apply(molecules=[
        molecule,
    ],
                                    processors=1,
                                    toolkit_registry=GLOBAL_TOOLKIT_REGISTRY)
    assert result.n_molecules == 0
    assert result.n_filtered == 1

    # now turn of rationalise
    enumerate_stereo.rationalise = False
    result = enumerate_stereo.apply([
        molecule,
    ],
                                    processors=1,
                                    toolkit_registry=GLOBAL_TOOLKIT_REGISTRY)
    assert molecule in result.molecules
    assert result.n_molecules == 1

    # now enumerate all stereo and rationalise
    enumerate_stereo.rationalise = True
    enumerate_stereo.undefined_only = False
    # make sure the input is missing and new isomers are found

    result = enumerate_stereo.apply([
        molecule,
    ],
                                    processors=1,
                                    toolkit_registry=GLOBAL_TOOLKIT_REGISTRY)
    assert molecule not in result.molecules
    assert molecule in result.filtered
Esempio n. 5
0
def test_enumerating_stereoisomers_validator(toolkit):
    """
    Test the validators in enumerating stereoisomers.
    """

    toolkit_name, toolkit_class = toolkit
    if toolkit_class.is_available():

        enumerate_stereo = workflow_components.EnumerateStereoisomers()
        with pytest.raises(ValueError):
            enumerate_stereo.toolkit = "ambertools"

        enumerate_stereo.toolkit = toolkit_name
        assert toolkit_name in enumerate_stereo.provenance()

        enumerate_stereo.undefined_only = "y"
        assert enumerate_stereo.undefined_only is True

        enumerate_stereo.max_isomers = 1.1
        assert enumerate_stereo.max_isomers == 1

    else:
        pytest.skip(f"Toolkit {toolkit_name} is not available.")
def test_enumerating_stereoisomers_apply():
    """
    Test the stereoisomer enumeration.
    """

    enumerate_stereo = workflow_components.EnumerateStereoisomers()
    # set the options
    enumerate_stereo.undefined_only = True
    enumerate_stereo.rationalise = True

    mols = get_stereoisomers()

    result = enumerate_stereo.apply(mols,
                                    processors=1,
                                    toolkit_registry=GLOBAL_TOOLKIT_REGISTRY)
    for mol in mols:
        assert mol in result.molecules

    # make sure no molecules have undefined stereo
    for molecule in result.molecules:
        assert Molecule.from_smiles(
            molecule.to_smiles(),
            toolkit_registry=RDKitToolkitWrapper()) == molecule
        assert molecule.n_conformers >= 1