Package rdkit :: Package SimDivFilters :: Module SimilarityPickers :: Class SpreadPicker

[hide private]
[frames] | no frames]

# Class SpreadPicker

source code

       object --+
                |
    GenericPicker --+
                    |
                   SpreadPicker

    A class for picking the best matches across a library

    Connect to a database:
    >>> from rdkit import Chem
    >>> import os.path
    >>> from rdkit.Dbase.DbConnection import DbConnect
    >>> dbName = RDConfig.RDTestDatabase
    >>> conn = DbConnect(dbName,'simple_mols1')
    >>> [x.upper() for x in conn.GetColumnNames()]
    ['SMILES', 'ID']
    >>> mols = []
    >>> for smi,id in conn.GetData():
    ...   mol = Chem.MolFromSmiles(str(smi))
    ...   mol.SetProp('_Name',str(id))
    ...   mols.append(mol)
    >>> len(mols)
    12

    Calculate fingerprints:
    >>> probefps = []
    >>> for mol in mols:
    ...   fp = Chem.RDKFingerprint(mol)
    ...   fp._id = mol.GetProp('_Name')
    ...   probefps.append(fp)

    Start by finding the top matches for a single probe.  This ether should pull
    other ethers from the db:
    >>> mol = Chem.MolFromSmiles('COC')
    >>> probeFp = Chem.RDKFingerprint(mol)
    >>> picker = SpreadPicker(numToPick=2,probeFps=[probeFp],dataSet=probefps)
    >>> len(picker)
    2
    >>> fp,score = picker[0]
    >>> id = fp._id
    >>> str(id)
    'ether-1'
    >>> score
    1.0

    The results come back in order:
    >>> fp,score = picker[1]
    >>> id = fp._id
    >>> str(id)
    'ether-2'

    Now find the top matches for 2 probes.  We'll get one ether and one acid:
    >>> fps = []
    >>> fps.append(Chem.RDKFingerprint(Chem.MolFromSmiles('COC')))
    >>> fps.append(Chem.RDKFingerprint(Chem.MolFromSmiles('CC(=O)O')))
    >>> picker = SpreadPicker(numToPick=3,probeFps=fps,dataSet=probefps)
    >>> len(picker)
    3
    >>> fp,score = picker[0]
    >>> id = fp._id
    >>> str(id)
    'ether-1'
    >>> score
    1.0
    >>> fp,score = picker[1]
    >>> id = fp._id
    >>> str(id)
    'acid-1'
    >>> score
    1.0
    >>> fp,score = picker[2]
    >>> id = fp._id
    >>> str(id)
    'ether-2'

Instance Methods | [hide private]

__init__(self, numToPick=10, probeFps=None, dataSet=None, simMetric=DataStructs.TanimotoSimilarity, expectPickles=True, onlyNames=False) | source code

MakePicks(self, force=0, silent=True) | source code

Inherited from `GenericPicker`: `__getitem__`, `__len__` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Variables | [hide private]

Inherited from `GenericPicker` (private): `_picks`

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, numToPick=10, probeFps=None, dataSet=None, simMetric=DataStructs.TanimotoSimilarity, expectPickles=True, onlyNames=False)
(Constructor)

source code

    dataSet should be a sequence of BitVectors or, if expectPickles
    is False, a set of strings that can be converted to bit vectors

Overrides: object.__init__

### MakePicks(self, force=0, silent=True)

source code

Overrides: GenericPicker.MakePicks