k-ujihara / NCDK

The Chemistry Development Kit ported to .NET
https://kazuyaujihara.github.io/NCDK/
GNU Lesser General Public License v2.1
35 stars 11 forks source link

Isomorphism match fail #12

Closed ghost closed 5 years ago

ghost commented 5 years ago

Using Nuget NCDK package 1.5.2 on .Net Core 2.1 Several fingerprint methods (eg KlekotaRoth, SubStructure, MACCS, Pubchem) failing with error "Specified method is not supported."

at NCDK.Silent.Atom.get_Bonds()\n at NCDK.Isomorphisms.Matchers.Expr.Matches(ExprType type, IAtom atom, Int32 stereo)\n at NCDK.Isomorphisms.Matchers.Expr.Matches(ExprType type, IAtom atom, Int32 stereo)\n at NCDK.Isomorphisms.Matchers.Expr.Matches(ExprType type, IAtom atom, Int32 stereo)\n at NCDK.Isomorphisms.VFSubState.Feasible(Int32 n, Int32 m)\n at NCDK.Isomorphisms.AbstractVFState.Add(Int32 n, Int32 m)\n at NCDK.Isomorphisms.StateStream.Map()\n at NCDK.Isomorphisms.StateStream.FindNext()\n at NCDK.Isomorphisms.StateStream.GetEnumerator()+MoveNext()\n at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)\n at NCDK.SMARTS.SmartsPattern.Match(IAtomContainer container)\n at NCDK.Isomorphisms.Pattern.Matches(IAtomContainer target)\n at NCDK.Fingerprints.SubstructureFingerprinter.GetBitFingerprint(IAtomContainer atomContainer)\n

k-ujihara commented 5 years ago

Please let me know the compound that throws the above exception.

ghost commented 5 years ago

These 4 fingerprinter's all fail with the same error, for all structures randomly selected from Chembl. I pulled out one example "O=C(C1=C(C=2C=CC(Cl)=C(Cl)C2)CCC1)N3CCOCC3", which fails with the Pubchem fp. The same process also uses the Lingo, Hybridization, EState, Distance Moment, Signature and Circular fp's which succeed for all the same randomly selected structures Is the common element to the failing fp methods Smarts pattern matching ?

k-ujihara commented 5 years ago

I could not reproduce it using the following code with NCDK-1.5.2 from NeGet. Could you post a code to repro.

using NCDK;
using NCDK.Fingerprints;

class Program
{
    static void Main(string[] args)
    {
        var printer = new PubchemFingerprinter(CDK.Builder);
        var mol = CDK.SmilesParser.ParseSmiles("O=C(C1=C(C=2C=CC(Cl)=C(Cl)C2)CCC1)N3CCOCC3");
        var bfp = printer.GetBitFingerprint(mol);
    }
}
ghost commented 5 years ago

Has ChemObjectBuilder been replaced?

I use

var mol = new SmilesParser(ChemObjectBuilder.Instance).ParseSmiles(m.smiles);

where m.smiles is an example smiles string

k-ujihara commented 5 years ago

CDK.Builder equals NCDK.Silent.ChemObjectBuilder and the following code also worked fine.

using NCDK.Default; // Silent also works fine
using NCDK.Fingerprints;
using NCDK.Smiles;

class Program
{
    static void Main(string[] args)
    {
        var printer = new PubchemFingerprinter();
        var mol = new SmilesParser(ChemObjectBuilder.Instance).ParseSmiles("O=C(C1=C(C=2C=CC(Cl)=C(Cl)C2)CCC1)N3CCOCC3");
        var bfp = printer.GetBitFingerprint(mol);
    }
}
ghost commented 5 years ago

Thanks for checking. Leave it with me and I will investigate further.

ghost commented 5 years ago

Found the problem which is not an NCDK issue.