From ef5dd99ad6cdc957e4d23dea19d3d346aba870e7 Mon Sep 17 00:00:00 2001 From: even1024 Date: Thu, 4 Jan 2024 15:14:17 +0100 Subject: [PATCH] #1465 Unable to load specific mol-file (#1479) --- .github/workflows/indigo-ci.yaml | 4 +- .../integration/ref/formats/mol_to_ket.py.out | 1 + .../integration/tests/formats/mol_to_ket.py | 1 + .../tests/formats/molecules/1465-lr_sugar.mol | 69 +++++ .../tests/formats/ref/1465-lr_sugar.ket | 274 ++++++++++++++++++ core/indigo-core/molecule/molfile_loader.h | 1 + .../molecule/src/molfile_loader.cpp | 11 + 7 files changed, 359 insertions(+), 2 deletions(-) create mode 100644 api/tests/integration/tests/formats/molecules/1465-lr_sugar.mol create mode 100644 api/tests/integration/tests/formats/ref/1465-lr_sugar.ket diff --git a/.github/workflows/indigo-ci.yaml b/.github/workflows/indigo-ci.yaml index 1a8c5adc20..bbe1ed3771 100644 --- a/.github/workflows/indigo-ci.yaml +++ b/.github/workflows/indigo-ci.yaml @@ -1001,8 +1001,8 @@ jobs: /bin/sh -c " set -eux && yum install -y -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm yum-utils && - curl -OL https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG && - rpm --import RPM-GPG-KEY-PGDG && + curl -OL https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL && + rpm --import PGDG-RPM-GPG-KEY-RHEL && yumdownloader -y postgresql${{ matrix.postgres_major_version }}-devel && rpm -i --nodeps postgresql${{ matrix.postgres_major_version }}*.rpm && ls -alh /usr && diff --git a/api/tests/integration/ref/formats/mol_to_ket.py.out b/api/tests/integration/ref/formats/mol_to_ket.py.out index cf2b2b19ed..025747268b 100644 --- a/api/tests/integration/ref/formats/mol_to_ket.py.out +++ b/api/tests/integration/ref/formats/mol_to_ket.py.out @@ -1,6 +1,7 @@ *** MOL to KET *** 1032-quadra.ket:SUCCEED 1046-imp_hydrogen.ket:SUCCEED +1465-lr_sugar.ket:SUCCEED SgroupDifferent.ket:SUCCEED acgt_1412.ket:SUCCEED anacyclamide.ket:SUCCEED diff --git a/api/tests/integration/tests/formats/mol_to_ket.py b/api/tests/integration/tests/formats/mol_to_ket.py index c278efb94b..f74a36cfd0 100644 --- a/api/tests/integration/tests/formats/mol_to_ket.py +++ b/api/tests/integration/tests/formats/mol_to_ket.py @@ -44,6 +44,7 @@ def find_diff(a, b): "anacyclamide", "acgt_1412", "apamine", + "1465-lr_sugar", ] files.sort() diff --git a/api/tests/integration/tests/formats/molecules/1465-lr_sugar.mol b/api/tests/integration/tests/formats/molecules/1465-lr_sugar.mol new file mode 100644 index 0000000000..8d26749b1f --- /dev/null +++ b/api/tests/integration/tests/formats/molecules/1465-lr_sugar.mol @@ -0,0 +1,69 @@ + + -INDIGO-01042412382D + + 0 0 0 0 0 0 0 0 0 0 0 V3000 +M V30 BEGIN CTAB +M V30 COUNTS 1 0 0 0 0 +M V30 BEGIN ATOM +M V30 1 LR 10.125 6.675 0.0 0 CLASS=RNA +M V30 END ATOM +M V30 BEGIN BOND +M V30 END BOND +M V30 END CTAB +M V30 BEGIN TEMPLATE +M V30 TEMPLATE 1 RNA/LR/LR NATREPLACE=RNA/R +M V30 BEGIN CTAB +M V30 COUNTS 13 14 4 0 0 +M V30 BEGIN ATOM +M V30 1 O -0.9702 0.0384 0.0 0 +M V30 2 C 0.5413 -0.5559 0.0 0 CFG=1 +M V30 3 C -1.5602 -1.0669 0.0 0 CFG=2 +M V30 4 C 1.9236 0.0726 0.0 0 CFG=2 +M V30 5 C -0.2063 -1.7187 0.0 0 CFG=1 +M V30 6 O 1.5616 1.5445 0.0 0 +M V30 7 C 0.3744 0.9413 0.0 0 +M V30 8 O -2.6751 -0.6231 0.0 0 +M V30 9 O -0.9999 1.5445 0.0 0 +M V30 10 H -1.1323 2.7372 0.0 0 +M V30 11 H 2.4387 2.3633 0.0 0 +M V30 12 C 0.6245 -2.0152 0.0 0 +M V30 13 O 0.0798 -3.2622 0.0 0 +M V30 END ATOM +M V30 BEGIN BOND +M V30 1 1 1 2 +M V30 2 1 1 3 +M V30 3 1 2 4 +M V30 4 1 2 7 CFG=1 +M V30 5 1 3 5 +M V30 6 1 3 8 CFG=3 +M V30 7 1 4 5 +M V30 8 1 6 11 +M V30 9 1 7 9 +M V30 10 1 9 10 +M V30 11 1 2 12 CFG=3 +M V30 12 1 12 13 +M V30 13 1 5 13 CFG=1 +M V30 14 1 4 6 CFG=1 +M V30 END BOND +M V30 BEGIN COLLECTION +M V30 MDLV30/STEABS ATOMS=(4 2 3 4 5) +M V30 END COLLECTION +M V30 BEGIN SGROUP +M V30 1 SUP 1 ATOMS=(1 10) XBONDS=(1 10) BRKXYZ=(9 0.066200 -0.596350 0.0000- +M V30 00 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLAS- +M V30 S=LGRP +M V30 2 SUP 2 ATOMS=(1 11) XBONDS=(1 8) BRKXYZ=(9 -0.438550 -0.409400 0.0000- +M V30 00 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLAS- +M V30 S=LGRP +M V30 3 SUP 3 ATOMS=(1 8) XBONDS=(1 6) BRKXYZ=(9 0.557450 -0.221900 0.000000- +M V30 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=OH CLASS- +M V30 =LGRP +M V30 4 SUP 4 ATOMS=(10 1 2 3 4 5 6 7 9 12 13) XBONDS=(3 6 8 10) BRKXYZ=(9 -- +M V30 0.557450 0.221900 0.000000 0.438550 0.409400 0.000000 0.000000 0.00000- +M V30 0 0.000000) BRKXYZ=(9 -0.066200 0.596350 0.000000 0.000000 0.000000 0.- +M V30 000000 0.000000 0.000000 0.000000) LABEL=LR CLASS=RNA SAP=(3 9 10 Al) - +M V30 SAP=(3 6 11 Br) SAP=(3 3 8 Cx) NATREPLACE=RNA/R +M V30 END SGROUP +M V30 END CTAB +M V30 END TEMPLATE +M END diff --git a/api/tests/integration/tests/formats/ref/1465-lr_sugar.ket b/api/tests/integration/tests/formats/ref/1465-lr_sugar.ket new file mode 100644 index 0000000000..395ccb1184 --- /dev/null +++ b/api/tests/integration/tests/formats/ref/1465-lr_sugar.ket @@ -0,0 +1,274 @@ +{ + "root": { + "nodes": [ + { + "$ref": "monomer0" + } + ], + "connections": [], + "templates": [ + { + "$ref": "monomerTemplate-LR_1" + } + ] + }, + "monomer0": { + "type": "monomer", + "id": "0", + "position": { + "x": 10.125, + "y": 6.675000190734863 + }, + "alias": "LR", + "templateId": "LR_1" + }, + "monomerTemplate-LR_1": { + "type": "monomerTemplate", + "id": "LR_1", + "class": "RNA", + "classHELM": "RNA", + "alias": "LR", + "name": "LR", + "naturalAnalogShort": "R", + "attachmentPoints": [ + { + "attachmentAtom": 8, + "leavingGroup": { + "atoms": [ + 9 + ] + } + }, + { + "attachmentAtom": 5, + "leavingGroup": { + "atoms": [ + 10 + ] + } + }, + { + "attachmentAtom": 2, + "leavingGroup": { + "atoms": [ + 7 + ] + } + } + ], + "atoms": [ + { + "label": "O", + "location": [ + -0.9702000021934509, + 0.03840000182390213, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 0.5412999987602234, + -0.555899977684021, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.5601999759674073, + -1.0669000148773194, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.9235999584197999, + 0.07259999960660935, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + -0.20630000531673432, + -1.7187000513076783, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "O", + "location": [ + 1.5615999698638917, + 1.5444999933242798, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 0.37439998984336855, + 0.9412999749183655, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -2.675100088119507, + -0.6230999827384949, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -0.9998999834060669, + 1.5444999933242798, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -1.1323000192642213, + 2.7372000217437746, + 0.0 + ] + }, + { + "label": "H", + "location": [ + 2.438699960708618, + 2.363300085067749, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 0.6244999766349793, + -2.015199899673462, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.07980000227689743, + -3.262200117111206, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 6 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 2, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 7 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 5, + 10 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 8 + ] + }, + { + "type": 1, + "atoms": [ + 8, + 9 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 11 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 11, + 12 + ] + }, + { + "type": 1, + "atoms": [ + 4, + 12 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 3, + 5 + ], + "stereo": 1 + } + ] + } +} \ No newline at end of file diff --git a/core/indigo-core/molecule/molfile_loader.h b/core/indigo-core/molecule/molfile_loader.h index 880a7e74cb..d9a997e40f 100644 --- a/core/indigo-core/molecule/molfile_loader.h +++ b/core/indigo-core/molecule/molfile_loader.h @@ -49,6 +49,7 @@ namespace indigo void loadMolecule(Molecule& mol); void loadQueryMolecule(QueryMolecule& mol); + void copyProperties(const MolfileLoader& loader); // for Rxnfiles v3000 void loadCtab3000(Molecule& mol); diff --git a/core/indigo-core/molecule/src/molfile_loader.cpp b/core/indigo-core/molecule/src/molfile_loader.cpp index 0973cb09b0..91d7f408ea 100644 --- a/core/indigo-core/molecule/src/molfile_loader.cpp +++ b/core/indigo-core/molecule/src/molfile_loader.cpp @@ -66,6 +66,16 @@ void MolfileLoader::loadMolecule(Molecule& mol) mol.buildFrom3dCoordinatesStereocenters(stereochemistry_options); } +void MolfileLoader::copyProperties(const MolfileLoader& loader) +{ + stereochemistry_options = loader.stereochemistry_options; + ignore_bad_valence = loader.ignore_bad_valence; + ignore_no_chiral_flag = loader.ignore_no_chiral_flag; + skip_3d_chirality = loader.skip_3d_chirality; + treat_stereo_as = loader.treat_stereo_as; + treat_x_as_pseudoatom = loader.treat_x_as_pseudoatom; +} + void MolfileLoader::loadQueryMolecule(QueryMolecule& mol) { mol.clear(); @@ -3869,6 +3879,7 @@ void MolfileLoader::_readTGroups3000() // tgroup.fragment = _bmol->neu(); MolfileLoader loader(_scanner); + loader.copyProperties(*this); loader._bmol = tgroup.fragment.get(); if (_bmol->isQueryMolecule()) {