epam / ketcher

Web-based molecule sketcher
https://lifescience.opensource.epam.com/ketcher/demo.html
Apache License 2.0
474 stars 164 forks source link

Add ability to define attachment points for molecules #4530

Closed rrodionov91 closed 4 months ago

rrodionov91 commented 5 months ago

Background Currently there is no way to define attachment points for molecules, so it is not possible to connect them in macromolecules mode with monomer.

Solution New items should be added to atom context menu: Add attachment point, Remove attachment point. It should appear only for atoms which are NOT part of s-group.

When add attachment point, system should create new superatom s-group for whole structure implicitly without label. System should draw label(R1/.../R8) depends on next free attachment point number and single bond from atom to that label. If all 8 attachment points exist in structure system should NOT create attachment point.

System should NOT allow to show brackets and collapse superatoms without labels.

When remove attachment point system should delete label and corresponding bond. When last attachment point deleted system should delete s-group superatom.

Such attachment points should be converted into monomer attachment points during the switching to macromolecules mode and vice versa.

System should save such attachment points to sgroup.attachmentPoints field during the serialization to ket format and should set leavingGroup new atom H.

Extra info:

  1. What happens if I apply R-Group on AP label? No, since AP is not an atom - its a label connected to atom by bond (we can do that with atom AP label connected to)

  2. Can I wrap atom/molecule with AP to R-Group fragment tool? No, since AP is not an atom - its a label connected to atom by bond (we can do that with atom AP label connected to)

  3. Can I attach "old" AP to new AP? No, since AP is not an atom - its a label connected to atom by bond (we can do that with atom AP label connected to)

  4. Can I charge (A+/A-) AP? No, since AP is not an atom - its a label connected to atom by bond (we can do that with atom AP label connected to)

  5. Can I bond AP with bond? (i.e. attach bond to AP) No, since AP is not an atom - its a label connected to atom by bond (we can do that with atom AP label connected to)

  6. Erase logic (since system enumerate AP automatically). What if we have R1, R2, R3 and I delete R2 and add NEW AP? What if we have R1-R8 in place and I delete R2 and try to add new AP? Gaps should start be filled if we rich the R8 (later this will be changed to let user choose AP name himself)

  7. Selection logic? Partial selection? Should selection be saved in KET? Selection should work the same as for atoms but without saving selection state in KET file Extra work over selection login is needed here. Will be done separatedy

  8. Items in context menu? Context menu if selected together with bond and atom? Only Delete item should be remain in the context menu for now

  9. Open from IMAGE? Load from image is not supported

  10. Should we support save to: We support all formats that support s-groups and attachment points If no - just got it lost in save file + warning in save dialog

    • MOL 2000 - YES
    • MOL 3000 - YES
    • SDF 2000 - YES
    • SDF 3000 - YES
    • SMARTS - NO
    • SMILES - NO
    • Extended SMILES - YES C[C@H](n)C(*)=O |$;;;_AP1;;_AP2;$|
    • CML - YES (?)
    • InChl - NO
    • InChl Auxinfo - NO
    • InChlKey - NO
    • PNG IMAGE - YES
    • CDXML - YES
    • Base64 CDX - YES
    • CDX - YES
  11. Copy/Cut/Paste logic? Should work if at least one atom is selected for copy, if only AP label - than NO

  12. Undo/Redo logic since we have two Undo/Redo sequences in Micro and Macro - how to resolve conflicts? Invalidate? Switching between Micro and Macro should invalidated Undo-Redo sequence

  13. Aromatize/Dearomatize should work Yes.

  14. Layout should work Yes. (AP label behave as atom)

  15. Clean Up should work Yes.

  16. Calculate CIPs should work Yes.

  17. Structure Check should work Yes.

  18. Calculate values should work (? - doesn't work for R-Groups now) Yes. (probably will require to to correct indigo - leaving group should disappear

  19. 3D view should work No, should be hydrogen in there. Should not crash

  20. Bond between micro and macro - can we edit it and change its type? Set query properties? No. We shouldn't allow that

  21. Connect molecule over AP? Should we allow? Yes. But no extra dialogs (such as Remove abbreviation) should appear. Connection should be established but AP info should remain virtually in memory and should appear back if we delete bond. Should remain even after save/load to ket/mol3000. Should be visual indication on the canvas in the same manner as if it done in Marvin

  22. Since AP is s-group - should we allow Remove Abbreviation? No. Never. it is not an s-group

  23. Stand alone connection point since it is s-group? No. it is not.

  24. Is it possible to connect AP to single atom? Yes we can

Open questions

  1. Label numbering - allow users to set
  2. Label/living group operations
  3. Undo/Redo - inclusion of mode switching in it - is this a bug? Valentin sees that yes, but Roman claims that this is what they wanted. It looks like a crutch. Sasha was always against it.
Zhirnoff commented 5 months ago

Tests added to the automation table.

AlexeyGirin commented 4 months ago

Verified.

rrodionov91 commented 4 months ago

Reopened due to requirements change.