fingerprintの由来を知りたい

openbabelのFP4フィンガープリントは部分構造由来のビット列なので、どのパターンに由来するビットが立っているのか知りたいときがよくあります。(MACCSなんかも同様に)

pybelを使えば簡単にサーチできるようです。

import pybel

def readsmartsfile(filename="/usr/local/share/openbabel/2.2.0/SMARTS_InteLigand.txt"):
    patterns = []
    inputfile = open(filename, "r")
    for line in inputfile:
        line = line.strip()
        if line and line[0]!="#":
            colon = line.find(":")
            name = line[:colon]
            smarts = line[colon+1:].strip()
            patterns.append([pybel.Smarts(smarts), name])
    return patterns
        
if __name__=="__main__":
    import sys
    patterns = readsmartsfile()
    file = sys.argv[1]
    
    for molecule in pybel.readfile("sdf", file):
        print "Looking at molecule %s" % molecule.title
        print "It has the following functional groups:",
        for smarts, name in patterns:
            if smarts.findall(molecule):
                print name,
        print "\n"

出典:Problem when using Fingerprint 4