#748 Pattern for SMARTS

Accepted
closed
nobody
None
master
1
2014-04-06
2014-02-26
John May
No

Adds an implementation of Pattern that can be created for a SMARTS query. The SMARTSQueryTool (SQT) still has a use but when we are matching a single query against multiple targets there are some optimisation. The SQT can't use them due to mutability of query (i.e. setSmarts(String)).

Still need to pass the building unfortunately but it's quite clean and returns the same Mappings API used by substructure searches.

https://github.com/johnmay/cdk/compare/cdk:master...feature%2Fsmarts-pattern?expand=1

IChemObject bldr = SilentChemObjectBuilder.getInstance();
Pattern     ptrn = SmartsPattern.create("[OH1]-[C,c]=,:[C,c]-,:[C,c]=,:[N,n]", bldr);

int n = 0;
for (IAtomContainer ac : acs) {
    n += ptrn.matchAll(ac)
             .countUnique();    
}

Discussion

  • John May

    John May - 2014-02-26

    *building = builder

     
  • Egon Willighagen

    Nice API. Thanks! Looks good: applied and pushed.

     
  • Egon Willighagen

    • status: open --> closed
    • Group: Needs_Review --> Accepted
     

Log in to post a comment.