Dear Rdkit Community,

I am trying to generate 2D Pharmacophore Fingerprints, for now I using the 
settings described in this example 
https://www.rdkit.org/docs/GettingStartedInPython.html#d-pharmacophore-fingerprints
 but with the feature definitions file being BaseFeatures.fdef.

I am able to generate the fingerprints for some of the molecules I am 
interested in, but it fails for other molecules raising a IndexError.

Is it possible to fix this? Or is it the case that for some molecules it is not 
possible to generate 2D pharmacophore fingerprints with this RDKit method?

Thank you in advance!
Best regards,
Fábio

Example:

.. code:: ipython3

    from rdkit import Chem
    from rdkit.Chem import AllChem
    from rdkit.Chem import ChemicalFeatures
    from rdkit.RDPaths import RDDataDir
    import os
    import rdkit
    rdkit.__version__

.. parsed-literal::

    '2020.03.3'

.. code:: ipython3

    fdefFile = os.path.join(RDDataDir,'BaseFeatures.fdef')
    featFactory = ChemicalFeatures.BuildFeatureFactory(fdefFile)

.. code:: ipython3

    from rdkit.Chem.Pharm2D.SigFactory import SigFactory
    # I am using the settings used in the example below:
    # 
https://www.rdkit.org/docs/GettingStartedInPython.html#d-pharmacophore-fingerprints
    sigFactory = SigFactory(featFactory,minPointCount=2,maxPointCount=3)
    sigFactory.SetBins([(0,2),(2,5),(5,8)])
    sigFactory.Init()
    sigFactory.GetSigSize()

.. parsed-literal::

    2988

**1st example:**

.. code:: ipython3

    smiles_6ZU = 'Cc1c(Cc2ccccc2)c(=O)oc2cc(OS(C)(=O)=O)ccc12'
    mol_6ZU = Chem.MolFromSmiles(smiles_6ZU)
    mol_6ZU

.. code:: ipython3

    from rdkit.Chem.Pharm2D import Generate
    Generate.Gen2DFingerprint(mol_6ZU,sigFactory)

::

    ---------------------------------------------------------------------------

    ValueError                                Traceback (most recent call last)

    ~/anaconda3/lib/python3.7/site-packages/rdkit/Chem/Pharm2D/SigFactory.py in 
GetBitIdx(self, featIndices, dists, sortIndices)
        248                 print('\tbins:', repr(self._bins), type(self._bins))
    --> 249             bin_ = self._findBinIdx(dists, self._bins, 
self._scaffolds[len(dists)])
        250         except ValueError:


    ~/anaconda3/lib/python3.7/site-packages/rdkit/Chem/Pharm2D/SigFactory.py in 
_findBinIdx(self, dists, bins, scaffolds)
        167             whichBins[i] = where
    --> 168         res = scaffolds.index(tuple(whichBins))
        169         if _verbose:


    ValueError: (0, 2, 0) is not in list


    During handling of the above exception, another exception occurred:


    IndexError                                Traceback (most recent call last)

    <ipython-input-6-faf364adc252> in <module>
          1 from rdkit.Chem.Pharm2D import Generate
    ----> 2 Generate.Gen2DFingerprint(mol_6ZU,sigFactory)


    ~/anaconda3/lib/python3.7/site-packages/rdkit/Chem/Pharm2D/Generate.py in 
Gen2DFingerprint(mol, sigFactory, perms, dMat, bitInfo)
        160     for match in matchesToMap:
        161       if sigFactory.shortestPathsOnly:
    --> 162         idx = _ShortestPathsMatch(match, perm, sig, dMat, 
sigFactory)
        163         if idx is not None and bitInfo is not None:
        164           l = bitInfo.get(idx, [])


    ~/anaconda3/lib/python3.7/site-packages/rdkit/Chem/Pharm2D/Generate.py in 
_ShortestPathsMatch(match, featureSet, sig, dMat, sigFactory)
         71     dist[i] = d
         72
    ---> 73   idx = sigFactory.GetBitIdx(featureSet, dist, sortIndices=False)
         74   if _verbose:
         75     print('\t', dist, minD, maxD, idx)


    ~/anaconda3/lib/python3.7/site-packages/rdkit/Chem/Pharm2D/SigFactory.py in 
GetBitIdx(self, featIndices, dists, sortIndices)
        252             fams = [fams[x] for x in featIndices]
        253             raise IndexError('distance bin not found: feats: %s; 
dists=%s; bins=%s; scaffolds: %s' %
    --> 254                              (fams, dists, self._bins, 
self._scaffolds))
        255
        256         return startIdx + offset + bin_


    IndexError: distance bin not found: feats: ['Acceptor', 'Aromatic', 
'Hydrophobe']; dists=[1, 5, 1]; bins=[(0, 2), (2, 5), (5, 8)]; scaffolds: [0, 
[(0,), (1,), (2,)], 0, [(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (0, 1, 2), 
(0, 2, 1), (0, 2, 2), (1, 0, 0), (1, 0, 1), (1, 0, 2), (1, 1, 0), (1, 1, 1), 
(1, 1, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2), (2, 0, 1), (2, 0, 2), (2, 1, 0), 
(2, 1, 1), (2, 1, 2), (2, 2, 0), (2, 2, 1), (2, 2, 2)], 0]




_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to