User d1c1a30031
27-04-2016 17:47:39
tried to find if a substructure (CH) occurs in Benzene.The substructure was imported as SMARTS: [cH1;a]. no matter I use findAllHits() or getMatchCount(), it returns 0 match. Why? apply aromatize() or not it still fails. Any help is highly appreciated.
int substructureSearch(Molecule toSearch, String smartsQuery) {
MolSearch s = new MolSearch();
try {
MolHandler mh = new MolHandler(smartsQuery, true);
s.setQuery(mh.getMolecule());
toSearch.aromatize(true); //apply or not it fails to match!!!
s.setTarget(toSearch);
SearchHit[] hits = s.findAllHits();
if (hits == null) {
return 0;
} else {
return hits.length;
}
} catch (MolFormatException
| SearchException e) {
IOUtils.INSTANCE.showException("MolFormatException or
SearchException", "For '" + smartsQuery + "', got the error " + e.getMessage(), e);
}
return 0;
}