# CDK SMARTS fragments counter

**URL:** <https://forum.knime.com/t/cdk-smarts-fragments-counter/8064>\
**Category:** Community Extensions\
**Tags:** cdk\
**Created:** [June 2, 2015, 12:40pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064 "2015-06-02T12:40:15Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcincilla](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gcincilla/32/41083_2.png) [@gcincilla](https://forum.knime.com/u/gcincilla)\
**Post date:** [June 2, 2015, 12:40pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/1 "2015-06-02T12:40:15Z")

</div>

Hi CDK-KNIME lovers,

I would like to count how many time a certain fragment, codified with a SMARTS query, appears in a molecule database. Using the CDK-KNIME _SMARTS Query_ node, is it possible to easily distinguish and split molecules matching a certain SMARTS query and molecules that do not. Anyway it is not currently possible to count how many times&nbsp;the SMARTS query (or queries) matches with&nbsp;molecules in databases.

Do you know if it would be possible (and easy) to include such a function in the next releases of the SMARTS query node? Or also if there are alternatives to do this using CDK?

Thanks in advance,

Gio

---

<div class="post-metadata">

**Author:** ![Stephan](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@Stephan](https://forum.knime.com/u/Stephan)\
**Post date:** [June 5, 2015, 11:15pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/2 "2015-06-05T23:15:59Z")

</div>

Hi Gio,

I'm not aware of any alternatives in KNIME-CDK but it was fairly straight forward to modify the existing node to accommodate that function.

You can now choose to append a column that contains the number of unique matches of a SMARTS query in the target molecule. If multiple SMARTS are provided, the sum total is calculated.

Please update your nightly build to make use of the new function. I would be grateful if you could test the node and feedback whether it works correctly and does what you need.

Kind regards,

Stephan

---

<div class="post-metadata">

**Author:** ![gcincilla](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gcincilla/32/41083_2.png) [@gcincilla](https://forum.knime.com/u/gcincilla)\
**Post date:** [June 7, 2015, 4:07pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/3 "2015-06-07T16:07:56Z")

</div>

Dear Stefan,

Thank you so much for your effort in enhancing CDK. I love this tool and I think it is getting better and better.

Currently I installed the new nightly build (1.5.3.201506052109) and I made some tests.

In general it seems that the new function is working properly, anyway I would like to discuss 2 points:

1. It would be great if in the output _matching molecules_ table instead of (or additionally to) the new total _unique count_ column, it would be placed a new unique count column for each of the input SMARTS. In that way the user would have a much richer information about the SMARTS fragments appearing on the molecules. Obviously I don't know if including this feature would require a major revision of the current node and hence a much greater effort, anyway in my opinion it would be good to take this into account for future versions.

2. I found a problem with a SMARTS but this is not related to the modification done on the nightly build. The same problem appears with the trusted repository version of the node. As you can see from the workflow I uploaded, if you try to match and count the ring bridge atoms in the molecules using the SMARTS "[r;!R1]" a problem appears. With the RDKit SMARTS node you obtain the count as expected while with the CDK one it seems that no molecule match that SMARTS. Anybody knows why this happens? Probably it would be good to open up a new forum thread with this problem.

Regards,

Gio

- [ring\_bridge\_atoms\_test.zip](https://www.knime.com/sites/default/files/ring_bridge_atoms_test.zip)

---

<div class="post-metadata">

**Author:** ![Stephan](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@Stephan](https://forum.knime.com/u/Stephan)\
**Post date:** [June 14, 2015, 12:03pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/4 "2015-06-14T12:03:05Z")

</div>

Hi Gio,

thanks for testing the update. Regarding your two points:

1) That's a great idea. I have modified the node to output a collection cell. The query SMARTS order is preserved, i.e. you can match the rownames of the SMARTS table to the column headers of the output table or vice versa.

2) I could reproduce your result. I will file a bug report with the CDK.

Kind regards,

Stephan

---

<div class="post-metadata">

**Author:** ![gcincilla](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gcincilla/32/41083_2.png) [@gcincilla](https://forum.knime.com/u/gcincilla)\
**Post date:** [June 15, 2015, 7:56pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/5 "2015-06-15T19:56:11Z")

</div>

Hi Stephan,

Thanks to you for the contribution to that CDK node!&nbsp;I test it and it seems to work well.

Thanks also to file for me the bug report with the CDK. Just one more question: is there a way (mailing list or something) to stay aware about the bug resolution and other CDK related activities?

Gio

---

<div class="post-metadata">

**Author:** ![Stephan](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@Stephan](https://forum.knime.com/u/Stephan)\
**Post date:** [June 18, 2015, 12:24am UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/6 "2015-06-18T00:24:08Z")

</div>

Hi Gio,

you can find the mailing lists on the SourceForge website:

https://sourceforge.net/p/cdk/mailman/

The opened ticket can be found here:

https://sourceforge.net/p/cdk/bugs/1364/

You can subscribe to individual tickets to stay updated.

Stephan

---

<div class="post-metadata">

**Author:** ![gcincilla](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gcincilla/32/41083_2.png) [@gcincilla](https://forum.knime.com/u/gcincilla)\
**Post date:** [June 18, 2015, 10:30am UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/7 "2015-06-18T10:30:32Z")

</div>

OK, thank you&nbsp;Stephan!

---

<div class="post-metadata">

**Author:** ![gcincilla](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gcincilla/32/41083_2.png) [@gcincilla](https://forum.knime.com/u/gcincilla)\
**Post date:** [September 30, 2015, 3:30pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/8 "2015-09-30T15:30:11Z")

</div>

Dear Stephan,

I see that the CDK bug tracked in this thread was solved and closed ([https://sourceforge.net/p/cdk/bugs/1364/](https://sourceforge.net/p/cdk/bugs/1364/ "https://sourceforge.net/p/cdk/bugs/1364/")), particularly on date 2015-06-18. This is a great news! Congratulation.

Nevertheless it seems that the patch was still not applied in the current CDK-KNIME nightly build (version cdk.knime\_1.5.3.201509071430).

Please, I would like to know if it would be possible to include that in the next nightly build or if some other related problem has to be fixed beforehand?

Thanks in advance for the information.

Best regards,

Gio

---

<div class="post-metadata">

**Author:** ![Stephan](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@Stephan](https://forum.knime.com/u/Stephan)\
**Post date:** [October 19, 2015, 11:25pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/9 "2015-10-19T23:25:51Z")

</div>

Hi Gio,

I'll update the code base over the next few days. The latest CDK release will be 1.5.11 or 1.5.12.

I'll update the thread once done.

All best,

Stephan

---

<div class="post-metadata">

**Author:** ![gcincilla](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gcincilla/32/41083_2.png) [@gcincilla](https://forum.knime.com/u/gcincilla)\
**Post date:** [October 20, 2015, 9:46am UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/10 "2015-10-20T09:46:34Z")

</div>

Hi Stephan,

That sounds great! Keeping this thread updated on this issue will be useful for the community.

Thanks for your effort,

Gio

---

<div class="post-metadata">

**Author:** ![Stephan](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@Stephan](https://forum.knime.com/u/Stephan)\
**Post date:** [October 25, 2015, 5:02pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/11 "2015-10-25T17:02:37Z")

</div>

Hi Gio,

I have updated the nightly build to CDK 1.5.12 for KNIME 2.x.

Kind regards,

Stephan

---

<div class="post-metadata">

**Author:** ![gcincilla](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gcincilla/32/41083_2.png) [@gcincilla](https://forum.knime.com/u/gcincilla)\
**Post date:** [October 28, 2015, 8:11pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/12 "2015-10-28T20:11:01Z")

</div>

This is very good news!

Soon I will test the new build with the problem I was having.

Thanks a lot Stephan

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [April 21, 2023, 9:42pm UTC](https://forum.knime.com/t/cdk-smarts-fragments-counter/8064/13 "2023-04-21T21:42:13Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
