Skip to content

Commit

Permalink
#1033 CDXML: expanded abbreviation opens as contracted from .cdxm fil…
Browse files Browse the repository at this point in the history
…es (#1209)
  • Loading branch information
Dmitry Malysh authored Aug 7, 2023
1 parent 8bf2fcd commit 94f3e54
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/tests/integration/ref/formats/cdx.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,25 @@ M STY 4 1 SUP 2 SUP 3 SUP 4 SUP
M SLB 4 1 1 2 2 3 3 4 4
M SAL 1 5 1 2 3 4 5
M SMT 1 bAla
M SDS EXP 1 1
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SAL 2 8 6 7 8 9 10 11 12 13
M SAL 2 6 14 15 16 17 18 19
M SMT 2 D-Trp
M SDS EXP 1 2
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M SAL 3 8 20 21 22 23 24 25 26 27
M SAL 3 6 28 29 30 31 32 33
M SMT 3 Trp
M SDS EXP 1 3
M SDI 3 4 0.0000 0.0000 0.0000 0.0000
M SDI 3 4 0.0000 0.0000 0.0000 0.0000
M SAL 4 8 34 35 36 37 38 39 40 41
M SAL 4 8 42 43 44 45 46 47 48 49
M SMT 4 PAThr
M SDS EXP 1 4
M SDI 4 4 0.0000 0.0000 0.0000 0.0000
M SDI 4 4 0.0000 0.0000 0.0000 0.0000
M END
Expand Down
127 changes: 127 additions & 0 deletions api/tests/integration/ref/formats/cdxml_ket_expanded.py.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
*** CDXML to KET ***
{
"root": {
"nodes": [
{
"$ref": "mol0"
},
{
"$ref": "mol1"
}
]
},
"mol0": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
1.8660635948181153,
-2.6999735832214357,
0.0
]
},
{
"label": "C",
"location": [
1.0,
-3.199960231781006,
0.0
]
},
{
"label": "O",
"location": [
1.8660635948181153,
-1.700000286102295,
0.0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
1,
0
]
},
{
"type": 2,
"atoms": [
0,
2
]
}
],
"sgroups": [
{
"type": "SUP",
"atoms": [
0,
1,
2
],
"name": "Ac",
"expanded": true
}
]
},
"mol1": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
6.266063213348389,
-1.9999737739562989,
0.0
]
},
{
"label": "C",
"location": [
5.400000095367432,
-2.499960422515869,
0.0
]
},
{
"label": "O",
"location": [
6.266063213348389,
-1.0,
0.0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
1,
0
]
},
{
"type": 2,
"atoms": [
0,
2
]
}
],
"sgroups": [
{
"type": "SUP",
"atoms": [
0,
1,
2
],
"name": "Ac",
"expanded": true
}
]
}
}
12 changes: 12 additions & 0 deletions api/tests/integration/ref/formats/cdxml_to_mol.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,28 @@ M STY 5 1 SUP 2 SUP 3 SUP 4 SUP 5 SUP
M SLB 5 1 1 2 2 3 3 4 4 5 5
M SAL 1 8 13 14 15 16 17 18 19 20
M SMT 1 OBn
M SDS EXP 1 1
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SAL 2 1 28
M SMT 2 OR
M SDS EXP 1 2
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M SAL 3 2 31 32
M SMT 3 OCH3
M SDS EXP 1 3
M SDI 3 4 0.0000 0.0000 0.0000 0.0000
M SDI 3 4 0.0000 0.0000 0.0000 0.0000
M SAL 4 2 35 36
M SMT 4 OCH3
M SDS EXP 1 4
M SDI 4 4 0.0000 0.0000 0.0000 0.0000
M SDI 4 4 0.0000 0.0000 0.0000 0.0000
M SAL 5 8 37 38 39 40 41 42 43 44
M SAL 5 1 45
M SMT 5 O2SPh
M SDS EXP 1 5
M SDI 5 4 0.0000 0.0000 0.0000 0.0000
M SDI 5 4 0.0000 0.0000 0.0000 0.0000
M END
Expand Down Expand Up @@ -317,10 +322,12 @@ M STY 2 1 SUP 2 SUP
M SLB 2 1 1 2 2
M SAL 1 2 9 10
M SMT 1 HATU
M SDS EXP 1 1
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SAL 2 2 19 20
M SMT 2 DCM
M SDS EXP 1 2
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M END
Expand Down Expand Up @@ -411,6 +418,7 @@ M SLB 4 1 1 2 2 3 3 4 4
M SCN 1 4 HT
M SAL 1 4 1 2 3 4
M SMT 1 test
M SDS EXP 1 1
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SAL 2 4 11 12 13 14
Expand Down Expand Up @@ -849,21 +857,25 @@ M STY 4 1 SUP 2 SUP 3 SUP 4 SUP
M SLB 4 1 1 2 2 3 3 4 4
M SAL 1 5 1 2 3 4 5
M SMT 1 bAla
M SDS EXP 1 1
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SDI 1 4 0.0000 0.0000 0.0000 0.0000
M SAL 2 8 6 7 8 9 10 11 12 13
M SAL 2 6 14 15 16 17 18 19
M SMT 2 D-Trp
M SDS EXP 1 2
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M SDI 2 4 0.0000 0.0000 0.0000 0.0000
M SAL 3 8 20 21 22 23 24 25 26 27
M SAL 3 6 28 29 30 31 32 33
M SMT 3 Trp
M SDS EXP 1 3
M SDI 3 4 0.0000 0.0000 0.0000 0.0000
M SDI 3 4 0.0000 0.0000 0.0000 0.0000
M SAL 4 8 34 35 36 37 38 39 40 41
M SAL 4 8 42 43 44 45 46 47 48 49
M SMT 4 PAThr
M SDS EXP 1 4
M SDI 4 4 0.0000 0.0000 0.0000 0.0000
M SDI 4 4 0.0000 0.0000 0.0000 0.0000
M END
Expand Down
21 changes: 21 additions & 0 deletions api/tests/integration/tests/formats/cdxml_ket_expanded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
import sys

sys.path.append(
os.path.normpath(
os.path.join(os.path.abspath(__file__), "..", "..", "..", "common")
)
)

from env_indigo import * # noqa

indigo = Indigo()

indigo.setOption("json-saving-pretty", True)
print("*** CDXML to KET ***")
ref_path = joinPathPy("ref/", __file__)
mol = indigo.loadMoleculeFromFile(
joinPathPy("ref/cdxml_ket_expanded.cdxml", __file__)
)

print(mol.json())
55 changes: 55 additions & 0 deletions api/tests/integration/tests/formats/ref/cdxml_ket_expanded.cdxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CDXML SYSTEM "http://www.cambridgesoft.com/xml/cdxml.dtd">
<CDXML BondLength="30.000000" LabelFont="3" CaptionFont="4">
<fonttable id="1">
<font id="2" charset="utf-8" name="Arial"/>
<font id="3" charset="utf-8" name="Times New Roman"/>
</fonttable>
<colortable>
<color r="1" g="1" b="1"/>
<color r="0" g="0" b="0"/>
<color r="1" g="0" b="0"/>
<color r="1" g="1" b="0"/>
<color r="0" g="1" b="0"/>
<color r="0" g="1" b="1"/>
<color r="0" g="0" b="1"/>
<color r="1" g="0" b="1"/>
<color r="0.5" g="0.5" b="0.5"/>
</colortable>
<page HeightPages="1" WidthPages="1">
<fragment id="4">
<n id="15" NodeType="Fragment">
<fragment id="16">
<n id="5" p="55.981907 80.999207"/>
<n id="6" p="30.000000 95.998810"/>
<n id="7" Element="8" NumHydrogens="0" p="55.981907 51.000008">
<t p="55.981907 51.000008" LabelJustification="Left">
<s font="3" size="10" face="96">O</s>
</t>
</n>
<b id="11" B="6" E="5"/>
<b id="12" B="5" E="7" Order="2"/>
</fragment>
<t LabelJustification="Left" LabelAlignment="Above">
<s>Ac</s>
</t>
</n>
<n id="17" NodeType="Fragment">
<fragment id="18">
<n id="8" p="187.981903 59.999214"/>
<n id="9" p="162.000000 74.998810"/>
<n id="10" Element="8" NumHydrogens="0" p="187.981903 30.000000">
<t p="187.981903 30.000000" LabelJustification="Left">
<s font="3" size="10" face="96">O</s>
</t>
</n>
<b id="13" B="9" E="8"/>
<b id="14" B="8" E="10" Order="2"/>
</fragment>
<t LabelJustification="Left" LabelAlignment="Above">
<s>Ac</s>
</t>
</n>
</fragment>
</page>
</CDXML>
2 changes: 1 addition & 1 deletion core/indigo-core/molecule/src/molecule_cdxml_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ void MoleculeCdxmlLoader::_addBracket(BaseMolecule& mol, const CdxmlBracket& bra
if (bracket.is_superatom)
{
Superatom& sa = (Superatom&)sgroup;
sa.contracted = DisplayOption::Contracted;
sa.contracted = DisplayOption::Expanded;
sa.subscript.readString(bracket.label.c_str(), true);
}
else
Expand Down

0 comments on commit 94f3e54

Please sign in to comment.