Hello Kai, If you are very concerned about the large cdk dependency, you can also include only the CDK parts you need. This requires some code compiling on the user side, but can be done pretty easily. To do this, download the source code, extract it and run the command
ant dist-all in the cdk directory (the one where there's a file called "build.xml"). This will generate a lot of smaller .jar's in the dist/jar subfolder. These jars are just the large cdk.jar split out into smaller subunits. From these you can cherry-pick the jars you will need for your project, leaving out the others. You may get a few "ClassNotFoundException"s in the beginning when you try to run your program, this means you missed a jar file that needs to be included, such as cdk-core.jar and cdk-standard.jar. For your application you will need, at least: cdk-core.jar cdk-interfaces.jar cdk-standard.jar cdk-data.jar cdk-io.jar cdk-ioformats.jar cdk-smarts.jar cdk-smiles.jar vecmath1.2-1.14.jar (found in <cdkdir>/jar/) jgrapht-0.6.0.jar (found in <cdkdir>/jar/) and one of: cdk-isomorphism.jar (the cdk 1.2.x standard substructure searcher, the UniversalIsomorphismTester) cdk-smsd.jar (the cdk 1.3.x. improved substructure searcher, to use the SMSD substructure matcher) This is the set that works for my quick-n-dirty commandline substructure matcher, your application may need an extra one or two, depending on what additional things you want to do. Kind regards, Jules On 28 July 2010 19:17, <[email protected]> wrote: > Your code works properly, thank you very much for the fast answer! > > A look in the SMARTSQueryTool#matches method shows the problem: The > molecule have to be initialized before searching. SMARTSQueryTool does > this implicit. > > Kai > > > Quoting Rajarshi Guha <[email protected]>: > >> You should be using the SMARTSQueryTool >> >> SMARTSQueryTool sqt = new SMARTSQueryTool("[a]") >> if (sqt.matches(mol)) { >> // do stuff >> } >> >> Do you still get this error with the above code? >> >> On Wed, Jul 28, 2010 at 12:20 PM, <[email protected]> wrote: >>> Hi, >>> >>> I'm trying to search a substructure in a molecule by a given SMART >>> pattern. So I searched for a java library which supports SMART >>> patterns. CDK looks like a very professional framework, although I >>> wish I could find a smaller library which just support SMART and not >>> hundred features more ^^ >>> >>> Nevertheless, I include the cdk jar file and try following code: >>> >>> Mol2Reader mr = new Mol2Reader(new FileReader(new File(filename))); >>> final IMolecule molecule = (IMolecule)mr.read(new Molecule()); >>> final QueryAtomContainer query = SMARTSParser.parse("[#8]"); >>> final boolean b = UniversalIsomorphismTester.isSubgraph(molecule, query); >>> System.out.println(b); // true >>> >>> It works. Next I changed the pattern into "[#8D2]". Now following >>> error message occurs: >>> >>> Exception in thread "main" java.lang.NullPointerException >>> at >>> org.openscience.cdk.isomorphism.matchers.smarts.ExplicitConnectionAtom.matches(ExplicitConnectionAtom.java:60) >>> at >>> org.openscience.cdk.isomorphism.matchers.smarts.LogicalOperatorAtom.matches(LogicalOperatorAtom.java:82) >>> at >>> org.openscience.cdk.isomorphism.UniversalIsomorphismTester.isSubgraph(UniversalIsomorphismTester.java:337) >>> at TestMol2.main(TestMol2.java:33) >>> >>> I looked in the source code and find following: >>> atom.getProperty(CDKConstants.TOTAL_CONNECTIONS) >>> >>> This property isn't defined in my atoms. In fact, there are no >>> properties defined in my atoms. So how can I load atoms which full >>> property sets so that substructure search works properly? >>> >>> I thank you very much in advance, >>> Kai >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> The Palm PDK Hot Apps Program offers developers who use the >>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share >>> of $1 Million in cash or HP Products. Visit us here for more details: >>> http://p.sf.net/sfu/dev2dev-palm >>> _______________________________________________ >>> Cdk-user mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/cdk-user >>> >> >> >> >> -- >> Rajarshi Guha >> NIH Chemical Genomics Center >> > > > > > > ------------------------------------------------------------------------------ > The Palm PDK Hot Apps Program offers developers who use the > Plug-In Development Kit to bring their C/C++ apps to Palm for a share > of $1 Million in cash or HP Products. Visit us here for more details: > http://p.sf.net/sfu/dev2dev-palm > _______________________________________________ > Cdk-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/cdk-user > ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ Cdk-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cdk-user

