rdkit.Chem.rdChemReactions.EnumerateLibrary

Package rdkit :: Package Chem :: Module rdChemReactions :: Class EnumerateLibrary |
[hide private]
[frames] | no frames]

# Class EnumerateLibrary

          object --+
                   |
         ??.instance --+
                       |
    EnumerateLibraryBase --+
                           |
                          EnumerateLibrary

    EnumerateLibrary
    This class allows easy enumeration of reactions.  Simply provide a reaction
    and a set of reagents and you are off the the races.

    Note that this functionality should be considered beta and that the API may
    change in a future release.

    EnumerateLibrary follows the python enumerator protocol, for example:

    library = EnumerateLibrary(rxn, bbs)
    for products in library:
       ... do something with the product

    It is useful to sanitize reactions before hand:

    SanitizeRxn(rxn)
    library = EnumerateLibrary(rxn, bbs)

    If ChemDraw style reaction semantics are prefereed, you can apply
    the ChemDraw parameters:

    SanitizeRxn(rxn, params=GetChemDrawRxnAdjustParams())

    For one, this enforces only matching RGroups and assumes all atoms
    have fully satisfied valences.

    Each product has the same output as applying a set of reagents to
    the libraries reaction.

    This can be a bit confusing as each product can have multiple molecules
    generated.  The returned data structure is as follows:

       [ [products1], [products2],... ]
    Where products1 are the molecule products for the reactions first product
    template and products2 are the molecule products for the second product
    template.  Since each reactant can match more than once, there may be
    multiple product molecules for each template.

    for result in library:
        for results_for_product_template in products:
            for mol in results_for_product_template:
                Chem.MolToSmiles(mol) # finally have a molecule!

    For sufficiently large libraries, using this iteration strategy is not
    recommended as the library may contain more products than atoms in the
    universe.  To help with this, you can supply an enumeration strategy.
    The default strategy is a CartesianProductStrategy which enumerates
    everything.  RandomSampleStrategy randomly samples the products but
    this strategy never terminates, however, python supplies itertools:

    import itertools
    library = EnumerateLibrary(rxn, bbs, rdChemReactions.RandomSampleStrategy())
    for result in itertools.islice(libary, 1000):
        # do something with the first 1000 samples

    for result in itertools.islice(libary, 1000):
        # do something with the next 1000 samples

    Libraries are also serializable, including their current state:

    s = library.Serialize()
    library2 = EnumerateLibrary()
    library2.InitFromString(s)
    for result in itertools.islice(libary2, 1000):
        # do something with the next 1000 samples

Instance Methods | [hide private]
GetReagents(...) GetReagents( (EnumerateLibrary)arg1) -> VectMolVect : Return the reagents used in this library. |
__init__(...) __init__( (object)arg1) -> None : |
Inherited from `EnumerateLibraryBase`: `GetEnumerator`, `GetPosition`, `GetReaction`, `GetState`, `InitFromString`, `ResetState`, `Serialize`, `SetState`, `__bool__`, `__iter__`, `__next__`, `__nonzero__`, `__reduce__`, `next`, `nextSmiles` Inherited from `unreachable.instance`: `__new__` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Variables | [hide private]
| __instance_size__ = `24`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### GetReagents(...) |
    GetReagents( (EnumerateLibrary)arg1) -> VectMolVect :
        Return the reagents used in this library.

        C++ signature :
            std::vector<std::vector<boost::shared_ptr<RDKit::ROMol>, std::allocator<boost::shared_ptr<RDKit::ROMol> > >, std::allocator<std::vector<boost::shared_ptr<RDKit::ROMol>, std::allocator<boost::shared_ptr<RDKit::ROMol> > > > > GetReagents(RDKit::EnumerateLibraryWrap {lvalue})

### __init__(...) (Constructor) |
    __init__( (object)arg1) -> None :

        C++ signature :
            void __init__(_object*)

    __init__( (object)arg1, (ChemicalReaction)rxn, (list)reagents [, (EnumerationParams)params]) -> None :

        C++ signature :
            void __init__(_object*,RDKit::ChemicalReaction,boost::python::list [,RDKit::EnumerationParams])

    __init__( (object)arg1, (ChemicalReaction)rxn, (tuple)reagents [, (EnumerationParams)params]) -> None :

        C++ signature :
            void __init__(_object*,RDKit::ChemicalReaction,boost::python::tuple [,RDKit::EnumerationParams])

    __init__( (object)arg1, (ChemicalReaction)rxn, (list)reagents, (EnumerationStrategyBase)enumerator [, (EnumerationParams)params]) -> None :

        C++ signature :
            void __init__(_object*,RDKit::ChemicalReaction,boost::python::list,RDKit::EnumerationStrategyBase [,RDKit::EnumerationParams])

    __init__( (object)arg1, (ChemicalReaction)rxn, (tuple)reagents, (EnumerationStrategyBase)enumerator [, (EnumerationParams)params]) -> None :

        C++ signature :
            void __init__(_object*,RDKit::ChemicalReaction,boost::python::tuple,RDKit::EnumerationStrategyBase [,RDKit::EnumerationParams])
Overrides: object.__init__