epam / Indigo

Universal cheminformatics toolkit, utilities and database search tools
http://lifescience.opensource.epam.com
Apache License 2.0
292 stars 100 forks source link

The structure saved in CML format does not open #1878

Closed Zhirnoff closed 2 months ago

Zhirnoff commented 3 months ago

Steps to Reproduce

  1. Open from file as New Project: The structure saved in CML format does not open.zip
  2. Save canvas as CML
  3. Open saved CML file ( For example, I provide the file that I received when saving ketcher (22).zip ) image

Actual behavior The structure saved in CML format does not open. System throws exception: Convert error! Given string could not be loaded as (query or plain) molecule or reaction, see the error messages: 'CML loader: 'query features' are allowed only for queries', 'RXN loader: bad header <?xml version="1.0" encoding="UTF-8"?>', 'RXN loader: bad header <?xml version="1.0" encoding="UTF-8"?>', 'CML loader: atom id a-1 cannot be found' image

Expected behavior The structure saved in CML format opens image

Desktop (please complete the following information):

Indigo version [Version 1.19.0-rc.2]

Attachments Error in Standalone mode: 2024-03-25_20h36_52

Error in Remote mode: 2024-03-25_20h37_59 2024-03-25_20h38_14

nainaksh commented 2 months ago

I am working on the issue. Find below analysis. Structure

The structure we want to create is trigonal. But in the code, it is considered as Tetrahydral because of below parameter is by default set to true.

image

Due to this, the CML conversion trying to add atomRefs4 attributes, but this trigonal structure has only 2 atoms present and tetrahydral requires at least 3 atoms. The 3rd atom id is set to -1 and that is why the exception occurs.

I tried to make the default variable is_tetrahydral(false) After this change the CML conversion is successful but the ABS is not handled in this case. I am currently looking into this.

nainaksh commented 2 months ago

Because of the stereolabel, the stereocenter is constructed. stereo_centers.size=1 addStereocentersIgnoreBad method inserts neighbor vertices into the pyramid array.

image

image

A stereocenter is an atom, typically carbon, that has four attachments. As per this statement, this case is incorrect.

nainaksh commented 2 months ago

The solution could be- Add a virtual atom to the molecule to make it tetrahedral structure. While setting atomParity, use virtual atomId to set atomref4 attribute.

AlexeyGirin commented 1 month ago

Verified. Windows 10 Chrome Version 125.0.6422.113 (Official Build) (64-bit) Ketcher Version 2.21.0-rc.2 Build at 2024-05-31; 10:48:44 Indigo Toolkit Version 1.21.0-dev.5.2-g994bdab98-x86_64-linux-gnu-11.2.1

image