Tuesday, 9 March 2010

Hack MACCS into Pybel

Due to a clerical oversight (originally pointed out by Fredrik Wallner over at Cinfony), the current release of Pybel doesn't support the MACCS fingerprint (although OpenBabel does). It's not pretty but we can hack it in as follows:

import pybel

pybel.fps.append("MACCS")
pybel._fingerprinters = pybel._getplugins(
  pybel.ob.OBFingerprint.FindFingerprint, pybel.fps)

mol = pybel.readstring("smi", "CCCC(=O)Cl")
print mol.calcfp("MACCS").bits
# [103, 107, 114, 115, 132, 134, 147, 154, 155, 160, 164]

The next release of Pybel.py will automatically use the available fingerprints.

No comments: