epam / ketcher

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

Macro: When inserted structure is under mouse cursor, some monomers are highlighted and if you click on canvas, abbreviations are expanded #3928

Open Zhirnoff opened 9 months ago

Zhirnoff commented 9 months ago

Steps to Reproduce

  1. Open Ketcher Micro mode
  2. Paste this structure on canvas by CTRL+V
  3. You must click when structures are highlighted. Only in this case bug is reproduced

2024-01-18_15h56_07

{
    "root": {
        "nodes": [
            {
                "$ref": "monomer3"
            },
            {
                "$ref": "monomer4"
            },
            {
                "$ref": "monomer6"
            },
            {
                "$ref": "monomer11"
            },
            {
                "$ref": "monomer12"
            },
            {
                "$ref": "monomer14"
            },
            {
                "$ref": "monomer19"
            },
            {
                "$ref": "monomer20"
            },
            {
                "$ref": "monomer22"
            }
        ],
        "connections": [
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer3",
                    "attachmentPointId": "R1"
                },
                "endpoint2": {
                    "monomerId": "monomer4",
                    "attachmentPointId": "R3"
                }
            },
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer4",
                    "attachmentPointId": "R2"
                },
                "endpoint2": {
                    "monomerId": "monomer6",
                    "attachmentPointId": "R1"
                }
            },
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer11",
                    "attachmentPointId": "R1"
                },
                "endpoint2": {
                    "monomerId": "monomer12",
                    "attachmentPointId": "R3"
                }
            },
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer12",
                    "attachmentPointId": "R2"
                },
                "endpoint2": {
                    "monomerId": "monomer14",
                    "attachmentPointId": "R1"
                }
            },
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer19",
                    "attachmentPointId": "R1"
                },
                "endpoint2": {
                    "monomerId": "monomer20",
                    "attachmentPointId": "R3"
                }
            },
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer20",
                    "attachmentPointId": "R2"
                },
                "endpoint2": {
                    "monomerId": "monomer22",
                    "attachmentPointId": "R1"
                }
            },
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer6",
                    "attachmentPointId": "R2"
                },
                "endpoint2": {
                    "monomerId": "monomer12",
                    "attachmentPointId": "R1"
                }
            },
            {
                "connectionType": "single",
                "endpoint1": {
                    "monomerId": "monomer14",
                    "attachmentPointId": "R2"
                },
                "endpoint2": {
                    "monomerId": "monomer20",
                    "attachmentPointId": "R1"
                }
            }
        ],
        "templates": [
            {
                "$ref": "monomerTemplate-A___Adenine"
            },
            {
                "$ref": "monomerTemplate-R___Ribose"
            },
            {
                "$ref": "monomerTemplate-P___Phosphate"
            },
            {
                "$ref": "monomerTemplate-C___Cytosine"
            },
            {
                "$ref": "monomerTemplate-G___Guanine"
            }
        ]
    },
    "monomer3": {
        "type": "monomer",
        "id": "3",
        "position": {
            "x": 0.6133333333333334,
            "y": -2.1933333333333334
        },
        "alias": "A",
        "templateId": "A___Adenine"
    },
    "monomerTemplate-A___Adenine": {
        "type": "monomerTemplate",
        "atoms": [
            {
                "label": "C",
                "location": [
                    1.0354,
                    0.2498,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -0.0792,
                    -0.754,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -1.5057,
                    -0.2906,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -1.8177,
                    1.1766,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -0.7031,
                    2.1804,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    0.7235,
                    1.717,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -2.3871,
                    -1.5034,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -1.5053,
                    -2.7168,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -0.0787,
                    -2.2532,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    2.1768,
                    -0.1209,
                    0
                ]
            },
            {
                "label": "H",
                "location": [
                    -3.5871,
                    -1.5034,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    0,
                    9
                ]
            },
            {
                "type": 2,
                "atoms": [
                    0,
                    5
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 1,
                "atoms": [
                    8,
                    1
                ]
            },
            {
                "type": 2,
                "atoms": [
                    1,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    6,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    2,
                    3
                ]
            },
            {
                "type": 2,
                "atoms": [
                    3,
                    4
                ]
            },
            {
                "type": 1,
                "atoms": [
                    4,
                    5
                ]
            },
            {
                "type": 1,
                "atoms": [
                    6,
                    7
                ]
            },
            {
                "type": 1,
                "atoms": [
                    6,
                    10
                ]
            },
            {
                "type": 2,
                "atoms": [
                    7,
                    8
                ]
            }
        ],
        "classHELM": "RNA",
        "id": "A___Adenine",
        "fullName": "Adenine",
        "alias": "A",
        "attachmentPoints": [
            {
                "attachmentAtom": 6,
                "leavingGroup": {
                    "atoms": [
                        10
                    ]
                },
                "type": "left"
            }
        ],
        "naturalAnalogShort": "A"
    },
    "monomer4": {
        "type": "monomer",
        "id": "4",
        "position": {
            "x": 0.6133333333333334,
            "y": -1.5133333333333334
        },
        "alias": "R",
        "templateId": "R___Ribose"
    },
    "monomerTemplate-R___Ribose": {
        "type": "monomerTemplate",
        "atoms": [
            {
                "label": "O",
                "location": [
                    -0.7870668737745955,
                    -0.7617767155358548,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -0.4212883139374412,
                    0.2454717053907153,
                    0
                ],
                "stereoLabel": "abs"
            },
            {
                "label": "C",
                "location": [
                    0.05779587009926911,
                    -1.4208925344924144,
                    0
                ],
                "stereoLabel": "abs"
            },
            {
                "label": "C",
                "location": [
                    0.6497570315857263,
                    0.20889384940699984,
                    0
                ],
                "stereoLabel": "abs"
            },
            {
                "label": "C",
                "location": [
                    0.9458090534539231,
                    -0.821072849259456,
                    0
                ],
                "stereoLabel": "abs"
            },
            {
                "label": "O",
                "location": [
                    1.306300970043431,
                    1.0541137989057054,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    1.7515935019701854,
                    -1.1136956971291794,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -1.022322498294859,
                    1.131198772746387,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    0.028505008862309486,
                    -2.2776145051109995,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    -2.091724697943758,
                    1.0541137989057054,
                    0
                ]
            },
            {
                "label": "H",
                "location": [
                    -2.573094997979451,
                    1.7634527287149055,
                    0
                ]
            },
            {
                "label": "H",
                "location": [
                    2.1556645047902916,
                    0.9376647652075489,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    1,
                    3
                ]
            },
            {
                "type": 1,
                "atoms": [
                    1,
                    7
                ],
                "stereo": 6
            },
            {
                "type": 1,
                "atoms": [
                    2,
                    4
                ]
            },
            {
                "type": 1,
                "atoms": [
                    2,
                    8
                ],
                "stereo": 6
            },
            {
                "type": 1,
                "atoms": [
                    3,
                    4
                ]
            },
            {
                "type": 1,
                "atoms": [
                    3,
                    5
                ],
                "stereo": 1
            },
            {
                "type": 1,
                "atoms": [
                    4,
                    6
                ],
                "stereo": 1
            },
            {
                "type": 1,
                "atoms": [
                    5,
                    11
                ]
            },
            {
                "type": 1,
                "atoms": [
                    7,
                    9
                ]
            },
            {
                "type": 1,
                "atoms": [
                    9,
                    10
                ]
            }
        ],
        "classHELM": "RNA",
        "id": "R___Ribose",
        "fullName": "Ribose",
        "alias": "R",
        "attachmentPoints": [
            {
                "attachmentAtom": 9,
                "leavingGroup": {
                    "atoms": [
                        10
                    ]
                },
                "type": "left"
            },
            {
                "attachmentAtom": 5,
                "leavingGroup": {
                    "atoms": [
                        11
                    ]
                },
                "type": "right"
            },
            {
                "attachmentAtom": 2,
                "leavingGroup": {
                    "atoms": [
                        8
                    ]
                },
                "type": "side"
            }
        ],
        "naturalAnalogShort": "R"
    },
    "monomer6": {
        "type": "monomer",
        "id": "6",
        "position": {
            "x": 1.2933333333333334,
            "y": -1.5133333333333334
        },
        "alias": "P",
        "templateId": "P___Phosphate"
    },
    "monomerTemplate-P___Phosphate": {
        "type": "monomerTemplate",
        "atoms": [
            {
                "label": "P",
                "location": [
                    -0.2399,
                    0,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    -1.4399,
                    0,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    0.3598,
                    -1.0394,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    0.9601,
                    0,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    0.3598,
                    1.0394,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 2,
                "atoms": [
                    0,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    3
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    4
                ]
            }
        ],
        "classHELM": "RNA",
        "id": "P___Phosphate",
        "fullName": "Phosphate",
        "alias": "P",
        "attachmentPoints": [
            {
                "attachmentAtom": 0,
                "leavingGroup": {
                    "atoms": [
                        1
                    ]
                },
                "type": "left"
            },
            {
                "attachmentAtom": 0,
                "leavingGroup": {
                    "atoms": [
                        3
                    ]
                },
                "type": "right"
            }
        ],
        "naturalAnalogShort": "P"
    },
    "monomer11": {
        "type": "monomer",
        "id": "11",
        "position": {
            "x": 1.9066666666666667,
            "y": -2.3000000000000003
        },
        "alias": "C",
        "templateId": "C___Cytosine"
    },
    "monomerTemplate-C___Cytosine": {
        "type": "monomerTemplate",
        "atoms": [
            {
                "label": "C",
                "location": [
                    1.8617,
                    1.3499,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    1.1117,
                    2.6489,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -0.3882,
                    2.649,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -1.1382,
                    1.35,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -0.3883,
                    0.0509,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    1.1117,
                    0.0509,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    5.0618,
                    1.3499,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    -0.9884,
                    -0.9883,
                    0
                ]
            },
            {
                "label": "H",
                "location": [
                    -2.3383,
                    1.35,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 2,
                "atoms": [
                    0,
                    5
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    6
                ]
            },
            {
                "type": 2,
                "atoms": [
                    1,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    2,
                    3
                ]
            },
            {
                "type": 1,
                "atoms": [
                    3,
                    4
                ]
            },
            {
                "type": 1,
                "atoms": [
                    3,
                    8
                ]
            },
            {
                "type": 1,
                "atoms": [
                    4,
                    5
                ]
            },
            {
                "type": 2,
                "atoms": [
                    4,
                    7
                ]
            }
        ],
        "classHELM": "RNA",
        "id": "C___Cytosine",
        "fullName": "Cytosine",
        "alias": "C",
        "attachmentPoints": [
            {
                "attachmentAtom": 3,
                "leavingGroup": {
                    "atoms": [
                        8
                    ]
                },
                "type": "left"
            }
        ],
        "naturalAnalogShort": "C"
    },
    "monomer12": {
        "type": "monomer",
        "id": "12",
        "position": {
            "x": 1.9066666666666667,
            "y": -1.62
        },
        "alias": "R",
        "templateId": "R___Ribose"
    },
    "monomer14": {
        "type": "monomer",
        "id": "14",
        "position": {
            "x": 2.586666666666667,
            "y": -1.62
        },
        "alias": "P",
        "templateId": "P___Phosphate"
    },
    "monomer19": {
        "type": "monomer",
        "id": "19",
        "position": {
            "x": 3.5333333333333337,
            "y": -2.5133333333333336
        },
        "alias": "G",
        "templateId": "G___Guanine"
    },
    "monomerTemplate-G___Guanine": {
        "type": "monomerTemplate",
        "atoms": [
            {
                "label": "C",
                "location": [
                    1.0354,
                    0.2498,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -0.0792,
                    -0.754,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -1.5057,
                    -0.2906,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -1.8177,
                    1.1766,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -0.7031,
                    2.1804,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    0.7235,
                    1.717,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -2.3871,
                    -1.5034,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    -1.5053,
                    -2.7168,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -0.0787,
                    -2.2532,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    2.1768,
                    -0.1209,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -0.9527,
                    3.3542,
                    0
                ]
            },
            {
                "label": "H",
                "location": [
                    -3.5871,
                    -1.5034,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 2,
                "atoms": [
                    0,
                    9
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    5
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 1,
                "atoms": [
                    8,
                    1
                ]
            },
            {
                "type": 2,
                "atoms": [
                    1,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    6,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    2,
                    3
                ]
            },
            {
                "type": 2,
                "atoms": [
                    3,
                    4
                ]
            },
            {
                "type": 1,
                "atoms": [
                    4,
                    5
                ]
            },
            {
                "type": 1,
                "atoms": [
                    4,
                    10
                ]
            },
            {
                "type": 1,
                "atoms": [
                    6,
                    7
                ]
            },
            {
                "type": 1,
                "atoms": [
                    6,
                    11
                ]
            },
            {
                "type": 2,
                "atoms": [
                    7,
                    8
                ]
            }
        ],
        "classHELM": "RNA",
        "id": "G___Guanine",
        "fullName": "Guanine",
        "alias": "G",
        "attachmentPoints": [
            {
                "attachmentAtom": 6,
                "leavingGroup": {
                    "atoms": [
                        11
                    ]
                },
                "type": "left"
            }
        ],
        "naturalAnalogShort": "G"
    },
    "monomer20": {
        "type": "monomer",
        "id": "20",
        "position": {
            "x": 3.5333333333333337,
            "y": -1.8333333333333335
        },
        "alias": "R",
        "templateId": "R___Ribose"
    },
    "monomer22": {
        "type": "monomer",
        "id": "22",
        "position": {
            "x": 4.213333333333334,
            "y": -1.8333333333333335
        },
        "alias": "P",
        "templateId": "P___Phosphate"
    }
}

Actual behavior When inserted structure is under mouse cursor, some monomers are highlighted and if you click on canvas, abbreviations are expanded. Lots of errors in DevTool console

Expected behavior Structure inserted without expand and errors in DevTools console.

Screenshots

https://github.com/epam/ketcher/assets/62464241/d6ad9c83-523b-4ce3-8ed0-348fc6002521

Desktop (please complete the following information):

Ketcher version [Version 2.18.0-rc.2]

Zhirnoff commented 7 months ago

Tests added to the automation table.

AlexeyGirin commented 6 months ago

Moved to Refined Backlog since no fix over 3 versions