#!/usr/bin/env python
# (C) 2017 OpenEye Scientific Software Inc. All rights reserved.
#
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of OpenEye products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from openeye import oechem
from openeye import oegraphsim

# @ <SNIPPET-FPOVERLAP>
pmol = oechem.OEGraphMol()
oechem.OESmilesToMol(pmol, "c1cnc2c(c1)CC(CC2O)CF")

tmol = oechem.OEGraphMol()
oechem.OESmilesToMol(tmol, "c1cc2c(cc1)CC(CCl)CC2N")

fptype = oegraphsim.OEGetFPType("Tree,ver=2.0.0,size=4096,bonds=5-5,"
                                "atype=AtmNum|HvyDeg|EqHalo,btype=Order")

for idx, match in enumerate(oegraphsim.OEGetFPOverlap(pmol, tmol, fptype)):
    ostring = "match %2d: " % (idx + 1)
    for mpair in match.GetAtoms():
        p = mpair.pattern
        t = mpair.target
        ostring += "%d%s-%d%s " % (p.GetIdx(), oechem.OEGetAtomicSymbol(p.GetAtomicNum()),
                                   t.GetIdx(), oechem.OEGetAtomicSymbol(t.GetAtomicNum()))
    print(ostring)
# @ </SNIPPET-FPOVERLAP>
