Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getKet duplicates items when macro molucules are used #5181

Closed
doktordirk opened this issue Jul 26, 2024 · 3 comments
Closed

getKet duplicates items when macro molucules are used #5181

doktordirk opened this issue Jul 26, 2024 · 3 comments

Comments

@doktordirk
Copy link

Steps to Reproduce

  1. Add item in micro mode
  2. Switch to macro mode
  3. Add item in macro mode
  4. Switch to micro mode
  5. Get result from ketcher.getKet()

Actual behavior
All items in the ket data are duplicated

Expected behavior
No item duplicated. Output should be identical to using "Save as..." -> ket file

Screenshots

output of "Save as..." -> ket file
{
    "root": {
        "nodes": [
            {
                "$ref": "monomer19"
            },
            {
                "$ref": "mol0"
            }
        ],
        "connections": [],
        "templates": [
            {
                "$ref": "monomerTemplate-Cya___3-sulfoalanine"
            }
        ]
    },
    "mol0": {
        "type": "molecule",
        "atoms": [
            {
                "label": "C",
                "location": [
                    10.208987298340658,
                    -8.74999266647844,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    10.208987298340658,
                    -9.750007333521562,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    11.075000000000001,
                    -10.250014667043123,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    11.941012701659346,
                    -9.750007333521562,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    11.941012701659346,
                    -8.74999266647844,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    11.075000000000001,
                    -8.249985332956879,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    5,
                    0
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 1,
                "atoms": [
                    1,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    2,
                    3
                ]
            },
            {
                "type": 1,
                "atoms": [
                    3,
                    4
                ]
            },
            {
                "type": 1,
                "atoms": [
                    4,
                    5
                ]
            }
        ]
    },
    "monomer19": {
        "type": "monomer",
        "id": "19",
        "position": {
            "x": 13.5,
            "y": -6.775
        },
        "alias": "Cya",
        "templateId": "Cya___3-sulfoalanine"
    },
    "monomerTemplate-Cya___3-sulfoalanine": {
        "type": "monomerTemplate",
        "atoms": [
            {
                "label": "C",
                "location": [
                    0.5437,
                    0.778,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    0.5429,
                    -0.7228,
                    0
                ],
                "stereoLabel": "abs"
            },
            {
                "label": "C",
                "location": [
                    1.8417,
                    -1.4748,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    1.841,
                    -2.6748,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    2.8815,
                    -0.8757,
                    0
                ]
            },
            {
                "label": "N",
                "location": [
                    -0.756,
                    -1.4748,
                    0
                ]
            },
            {
                "label": "H",
                "location": [
                    -1.7964,
                    -0.8767,
                    0
                ]
            },
            {
                "label": "S",
                "location": [
                    -0.7551,
                    1.53,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    -0.7544,
                    2.73,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    -1.7949,
                    0.9309,
                    0
                ]
            },
            {
                "label": "O",
                "location": [
                    -1.794,
                    2.1307,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    1,
                    0
                ],
                "stereo": 1
            },
            {
                "type": 1,
                "atoms": [
                    1,
                    2
                ]
            },
            {
                "type": 2,
                "atoms": [
                    2,
                    3
                ]
            },
            {
                "type": 1,
                "atoms": [
                    2,
                    4
                ]
            },
            {
                "type": 1,
                "atoms": [
                    1,
                    5
                ]
            },
            {
                "type": 1,
                "atoms": [
                    5,
                    6
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    7
                ]
            },
            {
                "type": 2,
                "atoms": [
                    7,
                    8
                ]
            },
            {
                "type": 2,
                "atoms": [
                    7,
                    9
                ]
            },
            {
                "type": 1,
                "atoms": [
                    7,
                    10
                ]
            }
        ],
        "class": "AminoAcid",
        "classHELM": "PEPTIDE",
        "id": "Cya___3-sulfoalanine",
        "fullName": "3-sulfoalanine",
        "alias": "Cya",
        "attachmentPoints": [
            {
                "attachmentAtom": 5,
                "leavingGroup": {
                    "atoms": [
                        6
                    ]
                },
                "type": "left"
            },
            {
                "attachmentAtom": 2,
                "leavingGroup": {
                    "atoms": [
                        4
                    ]
                },
                "type": "right"
            }
        ],
        "naturalAnalogShort": "A"
    }
}
output of ketcher.getKet()

{
"root": {
"nodes": [
{
"$ref": "monomer11"
},
{
"$ref": "monomer21"
},
{
"$ref": "mol0"
},
{
"$ref": "mol1"
}
],
"connections": [],
"templates": [
{
"$ref": "monomerTemplate-Cya___3-sulfoalanine"
}
]
},
"mol0": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
10.208987298340658,
-8.74999266647844,
0
]
},
{
"label": "C",
"location": [
10.208987298340658,
-9.750007333521562,
0
]
},
{
"label": "C",
"location": [
11.075000000000001,
-10.250014667043123,
0
]
},
{
"label": "C",
"location": [
11.941012701659346,
-9.750007333521562,
0
]
},
{
"label": "C",
"location": [
11.941012701659346,
-8.74999266647844,
0
]
},
{
"label": "C",
"location": [
11.075000000000001,
-8.249985332956879,
0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
5,
0
]
},
{
"type": 1,
"atoms": [
0,
1
]
},
{
"type": 1,
"atoms": [
1,
2
]
},
{
"type": 1,
"atoms": [
2,
3
]
},
{
"type": 1,
"atoms": [
3,
4
]
},
{
"type": 1,
"atoms": [
4,
5
]
}
]
},
"mol1": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
10.208987298340658,
-8.74999266647844,
0
]
},
{
"label": "C",
"location": [
10.208987298340658,
-9.750007333521562,
0
]
},
{
"label": "C",
"location": [
11.075000000000001,
-10.250014667043123,
0
]
},
{
"label": "C",
"location": [
11.941012701659346,
-9.750007333521562,
0
]
},
{
"label": "C",
"location": [
11.941012701659346,
-8.74999266647844,
0
]
},
{
"label": "C",
"location": [
11.075000000000001,
-8.249985332956879,
0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
5,
0
]
},
{
"type": 1,
"atoms": [
0,
1
]
},
{
"type": 1,
"atoms": [
1,
2
]
},
{
"type": 1,
"atoms": [
2,
3
]
},
{
"type": 1,
"atoms": [
3,
4
]
},
{
"type": 1,
"atoms": [
4,
5
]
}
]
},
"monomer11": {
"type": "monomer",
"id": "11",
"position": {
"x": 13.5,
"y": -6.775
},
"alias": "Cya",
"templateId": "Cya___3-sulfoalanine"
},
"monomerTemplate-Cya___3-sulfoalanine": {
"type": "monomerTemplate",
"atoms": [
{
"label": "C",
"location": [
0.5437,
0.778,
0
]
},
{
"label": "C",
"location": [
0.5429,
-0.7228,
0
],
"stereoLabel": "abs"
},
{
"label": "C",
"location": [
1.8417,
-1.4748,
0
]
},
{
"label": "O",
"location": [
1.841,
-2.6748,
0
]
},
{
"label": "O",
"location": [
2.8815,
-0.8757,
0
]
},
{
"label": "N",
"location": [
-0.756,
-1.4748,
0
]
},
{
"label": "H",
"location": [
-1.7964,
-0.8767,
0
]
},
{
"label": "S",
"location": [
-0.7551,
1.53,
0
]
},
{
"label": "O",
"location": [
-0.7544,
2.73,
0
]
},
{
"label": "O",
"location": [
-1.7949,
0.9309,
0
]
},
{
"label": "O",
"location": [
-1.794,
2.1307,
0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
1,
0
],
"stereo": 1
},
{
"type": 1,
"atoms": [
1,
2
]
},
{
"type": 2,
"atoms": [
2,
3
]
},
{
"type": 1,
"atoms": [
2,
4
]
},
{
"type": 1,
"atoms": [
1,
5
]
},
{
"type": 1,
"atoms": [
5,
6
]
},
{
"type": 1,
"atoms": [
0,
7
]
},
{
"type": 2,
"atoms": [
7,
8
]
},
{
"type": 2,
"atoms": [
7,
9
]
},
{
"type": 1,
"atoms": [
7,
10
]
}
],
"class": "AminoAcid",
"classHELM": "PEPTIDE",
"id": "Cya___3-sulfoalanine",
"fullName": "3-sulfoalanine",
"alias": "Cya",
"attachmentPoints": [
{
"attachmentAtom": 5,
"leavingGroup": {
"atoms": [
6
]
},
"type": "left"
},
{
"attachmentAtom": 2,
"leavingGroup": {
"atoms": [
4
]
},
"type": "right"
}
],
"naturalAnalogShort": "A"
},
"monomer21": {
"type": "monomer",
"id": "21",
"position": {
"x": 13.5,
"y": -6.775
},
"alias": "Cya",
"templateId": "Cya___3-sulfoalanine"
}
}

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser: chrome
  • Version : 127.0.6533.72 (Official Build) (64-bit)

Ketcher version
2.22.0-rc.9

Additional context
using

const structOrString = await window.ketcher.editor.struct();
const { struct } = await window.ketcher.indigo.convert(structOrString, {
        outputFormat: chemical/x-indigo-ket',
      });

gives the correct ket data (but has other issues since converting (basically) ket to ket flattes arrows

@rrodionov91
Copy link
Collaborator

Hi @doktordirk
Thank you for highlighting the issue. We reproduced it. Will plan the fix.

@NataliaLoginova
Copy link
Collaborator

This issue was solved in PR #5181 - getKet duplicates items when macro molucules are use

@Zhirnoff
Copy link
Collaborator

Zhirnoff commented Nov 8, 2024

Tested. Bug fixed.
2024-11-08_10h47_28

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 128.0.6613.120 (Official Build) (64-bit)

Ketcher version
[Version 2.27.0-rc.1]
Indigo version
[Version 1.26.0-rc.1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants