From cc1b0d10a2ca80394cfd430c1b12139e8ae59064 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Tue, 9 Apr 2024 13:47:28 +0300 Subject: [PATCH] #1588 Import of standard IDT monomers (#1904) Co-authored-by: even1024 Co-authored-by: Aliakasndr Dziarkach --- api/c/indigo/indigo.h | 4 + api/c/indigo/src/indigo_molecule.cpp | 50 + api/dotnet/src/Indigo.cs | 12 + api/dotnet/src/IndigoLib.cs | 6 + .../src/main/java/com/epam/indigo/Indigo.java | 10 + .../main/java/com/epam/indigo/IndigoLib.java | 6 + api/python/indigo/indigo/indigo.py | 40 + api/python/indigo/indigo/indigo_lib.py | 4 + .../integration/ref/formats/idt_to_ket.py.out | 3 + .../integration/tests/formats/idt_to_ket.py | 43 + .../tests/formats/molecules/idt_acg.idt | 1 + .../tests/formats/molecules/idt_maxmgc.idt | 1 + .../integration/tests/formats/ref/idt_acg.ket | 1310 +++++++++++++ .../tests/formats/ref/idt_maxmgc.ket | 1692 +++++++++++++++++ api/wasm/indigo-ketcher/indigo-ketcher.cpp | 128 +- api/wasm/indigo-ketcher/test/idt_maxmgc.ket | 1 + api/wasm/indigo-ketcher/test/test.js | 15 + .../molecule/monomers_basic_templates.h | 894 ++++++++- core/indigo-core/molecule/sequence_loader.h | 10 +- .../molecule/src/molecule_auto_loader.cpp | 6 + .../indigo-core/molecule/src/monomers_lib.cpp | 1 + .../molecule/src/sequence_loader.cpp | 126 +- utils/indigo-depict/main.c | 4 + .../backend/service/tests/api/indigo_test.py | 54 +- .../service/tests/api/ref/idt_maxmgc.ket | 1 + .../tests/api/structures/idt_maxmgc.idt | 1 + .../backend/service/v2/indigo_api.py | 12 +- .../backend/service/v2/validation.py | 1 + 28 files changed, 4299 insertions(+), 137 deletions(-) create mode 100644 api/tests/integration/ref/formats/idt_to_ket.py.out create mode 100644 api/tests/integration/tests/formats/idt_to_ket.py create mode 100644 api/tests/integration/tests/formats/molecules/idt_acg.idt create mode 100644 api/tests/integration/tests/formats/molecules/idt_maxmgc.idt create mode 100644 api/tests/integration/tests/formats/ref/idt_acg.ket create mode 100644 api/tests/integration/tests/formats/ref/idt_maxmgc.ket create mode 100644 api/wasm/indigo-ketcher/test/idt_maxmgc.ket create mode 100644 utils/indigo-service/backend/service/tests/api/ref/idt_maxmgc.ket create mode 100644 utils/indigo-service/backend/service/tests/api/structures/idt_maxmgc.idt diff --git a/api/c/indigo/indigo.h b/api/c/indigo/indigo.h index e0dd79fe89..bade902bdf 100644 --- a/api/c/indigo/indigo.h +++ b/api/c/indigo/indigo.h @@ -203,6 +203,10 @@ CEXPORT int indigoLoadFasta(int source, const char* seq_type); CEXPORT int indigoLoadFastaFromString(const char* string, const char* seq_type); CEXPORT int indigoLoadFastaFromFile(const char* filename, const char* seq_type); +CEXPORT int indigoLoadIDT(int source); +CEXPORT int indigoLoadIDTFromString(const char* string); +CEXPORT int indigoLoadIDTFromFile(const char* filename); + CEXPORT int indigoSaveMolfile(int molecule, int output); CEXPORT int indigoSaveMolfileToFile(int molecule, const char* filename); CEXPORT const char* indigoMolfile(int molecule); diff --git a/api/c/indigo/src/indigo_molecule.cpp b/api/c/indigo/src/indigo_molecule.cpp index 8186bc7b70..a9546198a5 100644 --- a/api/c/indigo/src/indigo_molecule.cpp +++ b/api/c/indigo/src/indigo_molecule.cpp @@ -626,6 +626,56 @@ CEXPORT int indigoLoadFastaFromFile(const char* filename, const char* seq_type) INDIGO_END(-1); } +CEXPORT int indigoLoadIDT(int source) +{ + INDIGO_BEGIN + { + IndigoObject& obj = self.getObject(source); + SequenceLoader loader(IndigoScanner::get(obj)); + + std::unique_ptr molptr = std::make_unique(); + + Molecule& mol = molptr->mol; + loader.loadIDT(mol); + return self.addObject(molptr.release()); + } + INDIGO_END(-1); +} + +CEXPORT int indigoLoadIDTFromString(const char* string) +{ + INDIGO_BEGIN + { + int source = indigoReadString(string); + int result; + + if (source <= 0) + return -1; + + result = indigoLoadIDT(source); + indigoFree(source); + return result; + } + INDIGO_END(-1); +} + +CEXPORT int indigoLoadIDTFromFile(const char* filename) +{ + INDIGO_BEGIN + { + int source = indigoReadFile(filename); + int result; + + if (source < 0) + return -1; + + result = indigoLoadIDT(source); + indigoFree(source); + return result; + } + INDIGO_END(-1); +} + CEXPORT int indigoLoadSmarts(int source) { INDIGO_BEGIN diff --git a/api/dotnet/src/Indigo.cs b/api/dotnet/src/Indigo.cs index d51462864c..1e4e3c08af 100644 --- a/api/dotnet/src/Indigo.cs +++ b/api/dotnet/src/Indigo.cs @@ -454,6 +454,12 @@ public IndigoObject loadFasta(string str, string seq_type) return new IndigoObject(this, checkResult(IndigoLib.indigoLoadFastaFromString(str, seq_type))); } + public IndigoObject loadIDT(string str) + { + setSessionID(); + return new IndigoObject(this, checkResult(IndigoLib.indigoLoadIDTFromString(str))); + } + public IndigoObject loadSmarts(byte[] buf) { setSessionID(); @@ -478,6 +484,12 @@ public IndigoObject loadFastaFromFile(string path, string seq_type) return new IndigoObject(this, checkResult(IndigoLib.indigoLoadFastaFromFile(path, seq_type))); } + public IndigoObject loadIDTFromFile(string path) + { + setSessionID(); + return new IndigoObject(this, checkResult(IndigoLib.indigoLoadIDTFromFile(path))); + } + public IndigoObject loadReaction(string str) { setSessionID(); diff --git a/api/dotnet/src/IndigoLib.cs b/api/dotnet/src/IndigoLib.cs index eed1a1d29d..ebdc58fe02 100644 --- a/api/dotnet/src/IndigoLib.cs +++ b/api/dotnet/src/IndigoLib.cs @@ -134,12 +134,18 @@ public unsafe class IndigoLib [DllImport("indigo"), SuppressUnmanagedCodeSecurity] public static extern int indigoLoadFastaFromString(string str, string seq_type); + [DllImport("indigo"), SuppressUnmanagedCodeSecurity] + public static extern int indigoLoadIDTFromString(string str); + [DllImport("indigo"), SuppressUnmanagedCodeSecurity] public static extern int indigoLoadSequenceFromFile(string filename, string seq_type); [DllImport("indigo"), SuppressUnmanagedCodeSecurity] public static extern int indigoLoadFastaFromFile(string filename, string seq_type); + [DllImport("indigo"), SuppressUnmanagedCodeSecurity] + public static extern int indigoLoadIDTFromFile(string filename); + [DllImport("indigo"), SuppressUnmanagedCodeSecurity] public static extern int indigoLoadSmartsFromBuffer(byte[] buffer, int size); diff --git a/api/java/indigo/src/main/java/com/epam/indigo/Indigo.java b/api/java/indigo/src/main/java/com/epam/indigo/Indigo.java index 78ecb588ac..a71658a8cb 100644 --- a/api/java/indigo/src/main/java/com/epam/indigo/Indigo.java +++ b/api/java/indigo/src/main/java/com/epam/indigo/Indigo.java @@ -380,6 +380,16 @@ public IndigoObject loadFastaFromFile(String path, String seq_type) { return new IndigoObject(this, checkResult(this, lib.indigoLoadFastaFromFile(path, seq_type))); } + public IndigoObject loadIDT(String str) { + setSessionID(); + return new IndigoObject(this, checkResult(this, lib.indigoLoadIDTFromString(str))); + } + + public IndigoObject loadIDTFromFile(String path) { + setSessionID(); + return new IndigoObject(this, checkResult(this, lib.indigoLoadIDTFromFile(path))); + } + public IndigoObject loadReaction(String str) { setSessionID(); return new IndigoObject(this, checkResult(this, lib.indigoLoadReactionFromString(str))); diff --git a/api/java/indigo/src/main/java/com/epam/indigo/IndigoLib.java b/api/java/indigo/src/main/java/com/epam/indigo/IndigoLib.java index 097d68debd..c3abe57424 100644 --- a/api/java/indigo/src/main/java/com/epam/indigo/IndigoLib.java +++ b/api/java/indigo/src/main/java/com/epam/indigo/IndigoLib.java @@ -129,6 +129,12 @@ public interface IndigoLib extends Library { int indigoLoadFastaFromFile(String filename, String seq_type); + int indigoLoadIDT(int source); + + int indigoLoadIDTFromString(String str); + + int indigoLoadIDTFromFile(String filename); + int indigoLoadStructureFromString(String str, String params); int indigoLoadStructureFromFile(String filename, String params); diff --git a/api/python/indigo/indigo/indigo.py b/api/python/indigo/indigo/indigo.py index 6612f744c1..15110f23eb 100644 --- a/api/python/indigo/indigo/indigo.py +++ b/api/python/indigo/indigo/indigo.py @@ -600,6 +600,46 @@ def loadFastaFromFile(self, filename, seq_type): ), ) + def loadIDT(self, string): + """Loads molecule from IDT string + + Args: + string (str): sequence string + + Returns: + IndigoObject: loaded query molecular structure + + Raises: + IndigoException: Exception if structure format is incorrect + """ + + return IndigoObject( + self, + IndigoLib.checkResult( + self._lib().indigoLoadIDTFromString(string.encode()) + ), + ) + + def loadIDTFromFile(self, filename): + """Loads query molecule from file in IDT sequence format + + Args: + filename (str): full path to the file with sequence string + + Returns: + IndigoObject: loaded query molecular structure + + Raises: + IndigoException: Exception if structure format is incorrect + """ + + return IndigoObject( + self, + IndigoLib.checkResult( + self._lib().indigoLoadIDTFromFile(filename.encode()) + ), + ) + def loadReaction(self, string): """Loads reaction from string. Format will be automatically recognized. diff --git a/api/python/indigo/indigo/indigo_lib.py b/api/python/indigo/indigo/indigo_lib.py index b06ab10899..bb0f58584b 100644 --- a/api/python/indigo/indigo/indigo_lib.py +++ b/api/python/indigo/indigo/indigo_lib.py @@ -152,6 +152,10 @@ def __init__(self) -> None: c_char_p, c_char_p, ] + IndigoLib.lib.indigoLoadIDTFromString.restype = c_int + IndigoLib.lib.indigoLoadIDTFromString.argtypes = [c_char_p] + IndigoLib.lib.indigoLoadIDTFromFile.restype = c_int + IndigoLib.lib.indigoLoadIDTFromFile.argtypes = [c_char_p] IndigoLib.lib.indigoLoadReactionFromString.restype = c_int IndigoLib.lib.indigoLoadReactionFromString.argtypes = [c_char_p] IndigoLib.lib.indigoLoadReactionFromFile.restype = c_int diff --git a/api/tests/integration/ref/formats/idt_to_ket.py.out b/api/tests/integration/ref/formats/idt_to_ket.py.out new file mode 100644 index 0000000000..a36b7be508 --- /dev/null +++ b/api/tests/integration/ref/formats/idt_to_ket.py.out @@ -0,0 +1,3 @@ +*** IDT to KET *** +idt_acg.ket:SUCCEED +idt_maxmgc.ket:SUCCEED diff --git a/api/tests/integration/tests/formats/idt_to_ket.py b/api/tests/integration/tests/formats/idt_to_ket.py new file mode 100644 index 0000000000..c54c3e150f --- /dev/null +++ b/api/tests/integration/tests/formats/idt_to_ket.py @@ -0,0 +1,43 @@ +import difflib +import os +import sys + + +def find_diff(a, b): + return "\n".join(difflib.unified_diff(a.splitlines(), b.splitlines())) + + +sys.path.append( + os.path.normpath( + os.path.join(os.path.abspath(__file__), "..", "..", "..", "common") + ) +) +from env_indigo import Indigo, joinPathPy # noqa + +indigo = Indigo() +indigo.setOption("json-saving-pretty", True) +indigo.setOption("ignore-stereochemistry-errors", True) + +print("*** IDT to KET ***") + +root = joinPathPy("molecules/", __file__) +ref_path = joinPathPy("ref/", __file__) + +fasta_files = [ + "idt_acg", + "idt_maxmgc", +] + +for filename in fasta_files: + mol = indigo.loadIDTFromFile(os.path.join(root, filename + ".idt")) + # with open(os.path.join(ref_path, filename) + ".ket", "w") as file: + # file.write(mol.json()) + with open(os.path.join(ref_path, filename) + ".ket", "r") as file: + ket_ref = file.read() + ket = mol.json() + diff = find_diff(ket_ref, ket) + if not diff: + print(filename + ".ket:SUCCEED") + else: + print(filename + ".ket:FAILED") + print(diff) diff --git a/api/tests/integration/tests/formats/molecules/idt_acg.idt b/api/tests/integration/tests/formats/molecules/idt_acg.idt new file mode 100644 index 0000000000..8df9c40afb --- /dev/null +++ b/api/tests/integration/tests/formats/molecules/idt_acg.idt @@ -0,0 +1 @@ +ACG \ No newline at end of file diff --git a/api/tests/integration/tests/formats/molecules/idt_maxmgc.idt b/api/tests/integration/tests/formats/molecules/idt_maxmgc.idt new file mode 100644 index 0000000000..9a443d9daf --- /dev/null +++ b/api/tests/integration/tests/formats/molecules/idt_maxmgc.idt @@ -0,0 +1 @@ +mA*mGC \ No newline at end of file diff --git a/api/tests/integration/tests/formats/ref/idt_acg.ket b/api/tests/integration/tests/formats/ref/idt_acg.ket new file mode 100644 index 0000000000..8d30515fd5 --- /dev/null +++ b/api/tests/integration/tests/formats/ref/idt_acg.ket @@ -0,0 +1,1310 @@ +{ + "root": { + "nodes": [ + { + "$ref": "monomer0" + }, + { + "$ref": "monomer1" + }, + { + "$ref": "monomer2" + }, + { + "$ref": "monomer3" + }, + { + "$ref": "monomer4" + }, + { + "$ref": "monomer5" + }, + { + "$ref": "monomer6" + }, + { + "$ref": "monomer7" + } + ], + "connections": [ + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer0", + "attachmentPointId": "R3" + }, + "endpoint2": { + "monomerId": "monomer1", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer2", + "attachmentPointId": "R3" + }, + "endpoint2": { + "monomerId": "monomer3", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer0", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer4", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer4", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer2", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer5", + "attachmentPointId": "R3" + }, + "endpoint2": { + "monomerId": "monomer6", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer2", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer7", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer7", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer5", + "attachmentPointId": "R1" + } + } + ], + "templates": [ + { + "$ref": "monomerTemplate-Ade" + }, + { + "$ref": "monomerTemplate-dRib" + }, + { + "$ref": "monomerTemplate-dRib" + }, + { + "$ref": "monomerTemplate-Cyt" + }, + { + "$ref": "monomerTemplate-P" + }, + { + "$ref": "monomerTemplate-Gua" + } + ] + }, + "monomer0": { + "type": "monomer", + "id": "0", + "seqid": 1, + "position": { + "x": 0.0, + "y": -0.0 + }, + "alias": "dR", + "templateId": "dRib" + }, + "monomer1": { + "type": "monomer", + "id": "1", + "seqid": 1, + "position": { + "x": 0.0, + "y": -1.600000023841858 + }, + "alias": "A", + "templateId": "Ade" + }, + "monomer2": { + "type": "monomer", + "id": "2", + "seqid": 2, + "position": { + "x": 3.200000047683716, + "y": -0.0 + }, + "alias": "dR", + "templateId": "dRib" + }, + "monomer3": { + "type": "monomer", + "id": "3", + "seqid": 2, + "position": { + "x": 3.200000047683716, + "y": -1.600000023841858 + }, + "alias": "C", + "templateId": "Cyt" + }, + "monomer4": { + "type": "monomer", + "id": "4", + "seqid": 1, + "position": { + "x": 1.600000023841858, + "y": -0.0 + }, + "alias": "P", + "templateId": "P" + }, + "monomer5": { + "type": "monomer", + "id": "5", + "seqid": 3, + "position": { + "x": 6.400000095367432, + "y": -0.0 + }, + "alias": "dR", + "templateId": "dRib" + }, + "monomer6": { + "type": "monomer", + "id": "6", + "seqid": 3, + "position": { + "x": 6.400000095367432, + "y": -1.600000023841858 + }, + "alias": "G", + "templateId": "Gua" + }, + "monomer7": { + "type": "monomer", + "id": "7", + "seqid": 2, + "position": { + "x": 4.800000190734863, + "y": -0.0 + }, + "alias": "P", + "templateId": "P" + }, + "monomerTemplate-Ade": { + "type": "monomerTemplate", + "id": "Ade", + "class": "Base", + "classHELM": "RNA", + "alias": "A", + "name": "Ade", + "fullName": "Adenine", + "naturalAnalogShort": "A", + "naturalAnalog": "Ade", + "attachmentPoints": [ + { + "attachmentAtom": 6, + "leavingGroup": { + "atoms": [ + 10 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 0.7141363024711609, + 0.172292098402977, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.05462583899497986, + -0.5200490355491638, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.0385116338729859, + -0.200432687997818, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.2537044286727906, + 0.8115247488021851, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.4849422574043274, + 1.5038658380508423, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 0.4990125596523285, + 1.1842495203018189, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.6464310884475709, + -1.0369253158569337, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.0382357835769654, + -1.8738317489624024, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -0.054280977696180347, + -1.5540775060653687, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 1.5013829469680787, + -0.08338717371225357, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -2.474095344543457, + -1.0369253158569337, + 0.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 + ] + } + ] + }, + "monomerTemplate-dRib": { + "type": "monomerTemplate", + "id": "dRib", + "class": "Sugar", + "classHELM": "RNA", + "alias": "dR", + "name": "dRib", + "fullName": "Deoxy-Ribose", + "naturalAnalogShort": "R", + "naturalAnalog": "Rib", + "attachmentPoints": [ + { + "attachmentAtom": 8, + "leavingGroup": { + "atoms": [ + 9 + ] + } + }, + { + "attachmentAtom": 5, + "leavingGroup": { + "atoms": [ + 10 + ] + } + }, + { + "attachmentAtom": 2, + "leavingGroup": { + "atoms": [ + 7 + ] + } + } + ], + "atoms": [ + { + "label": "O", + "location": [ + -0.8787999749183655, + -1.2079999446868897, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.3668000102043152, + 0.20190000534057618, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 0.30379998683929446, + -2.13070011138916, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.1323000192642213, + 0.15060000121593476, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.5468000173568726, + -1.2910000085830689, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 2.051500082015991, + 1.333799958229065, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.2080999612808228, + 1.4416999816894532, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.262800008058548, + -3.329900026321411, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -2.7049999237060549, + 1.333799958229065, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -3.3787999153137209, + 2.32669997215271, + 0.0 + ] + }, + { + "label": "H", + "location": [ + 3.240299940109253, + 1.1708999872207642, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 6 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 2, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 7 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 5 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 5, + 10 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 8 + ] + }, + { + "type": 1, + "atoms": [ + 8, + 9 + ] + } + ] + }, + "monomerTemplate-dRib": { + "type": "monomerTemplate", + "id": "dRib", + "class": "Sugar", + "classHELM": "RNA", + "alias": "dR", + "name": "dRib", + "fullName": "Deoxy-Ribose", + "naturalAnalogShort": "R", + "naturalAnalog": "Rib", + "attachmentPoints": [ + { + "attachmentAtom": 8, + "leavingGroup": { + "atoms": [ + 9 + ] + } + }, + { + "attachmentAtom": 5, + "leavingGroup": { + "atoms": [ + 10 + ] + } + }, + { + "attachmentAtom": 2, + "leavingGroup": { + "atoms": [ + 7 + ] + } + } + ], + "atoms": [ + { + "label": "O", + "location": [ + -0.8787999749183655, + -1.2079999446868897, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.3668000102043152, + 0.20190000534057618, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 0.30379998683929446, + -2.13070011138916, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.1323000192642213, + 0.15060000121593476, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.5468000173568726, + -1.2910000085830689, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 2.051500082015991, + 1.333799958229065, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.2080999612808228, + 1.4416999816894532, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.262800008058548, + -3.329900026321411, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -2.7049999237060549, + 1.333799958229065, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -3.3787999153137209, + 2.32669997215271, + 0.0 + ] + }, + { + "label": "H", + "location": [ + 3.240299940109253, + 1.1708999872207642, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 6 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 2, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 7 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 5 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 5, + 10 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 8 + ] + }, + { + "type": 1, + "atoms": [ + 8, + 9 + ] + } + ] + }, + "monomerTemplate-Cyt": { + "type": "monomerTemplate", + "id": "Cyt", + "class": "Base", + "classHELM": "RNA", + "alias": "C", + "name": "Cyt", + "fullName": "Cytosine", + "naturalAnalogShort": "C", + "naturalAnalog": "Cyt", + "attachmentPoints": [ + { + "attachmentAtom": 3, + "leavingGroup": { + "atoms": [ + 8 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 1.8617000579833985, + 1.3499000072479249, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 1.1117000579833985, + 2.648900032043457, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.3882000148296356, + 2.6489999294281008, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.138200044631958, + 1.350000023841858, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.38830000162124636, + 0.05090000107884407, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 1.1117000579833985, + 0.05090000107884407, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 3.061800003051758, + 1.3499000072479249, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -0.9883999824523926, + -0.9883000254631043, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -2.3382999897003176, + 1.350000023841858, + 0.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 + ] + } + ] + }, + "monomerTemplate-P": { + "type": "monomerTemplate", + "id": "P", + "class": "Phosphate", + "classHELM": "RNA", + "alias": "P", + "name": "P", + "fullName": "Phosphate", + "naturalAnalogShort": "P", + "attachmentPoints": [ + { + "attachmentAtom": 0, + "leavingGroup": { + "atoms": [ + 1 + ] + } + }, + { + "attachmentAtom": 0, + "leavingGroup": { + "atoms": [ + 3 + ] + } + } + ], + "atoms": [ + { + "label": "P", + "location": [ + -0.19991692900657655, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -1.199918270111084, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.2998337149620056, + -0.8661677837371826, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.8000843524932861, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.2998337149620056, + 0.8661677837371826, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 2, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 4 + ] + } + ] + }, + "monomerTemplate-Gua": { + "type": "monomerTemplate", + "id": "Gua", + "class": "Base", + "classHELM": "RNA", + "alias": "G", + "name": "Gua", + "fullName": "Guanine", + "naturalAnalogShort": "G", + "naturalAnalog": "Gua", + "attachmentPoints": [ + { + "attachmentAtom": 6, + "leavingGroup": { + "atoms": [ + 11 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 1.0354000329971314, + 0.24979999661445619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.07919999957084656, + -0.7540000081062317, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.5056999921798707, + -0.2906000018119812, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.8177000284194947, + 1.1765999794006348, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.7031000256538391, + 2.1803998947143556, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 0.7235000133514404, + 1.7170000076293946, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -2.3870999813079836, + -1.5033999681472779, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.5053000450134278, + -2.7167999744415285, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -0.0786999985575676, + -2.253200054168701, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 2.176800012588501, + -0.120899997651577, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -0.9527000188827515, + 3.3541998863220217, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -3.587100028991699, + -1.5033999681472779, + 0.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 + ] + } + ] + } +} \ No newline at end of file diff --git a/api/tests/integration/tests/formats/ref/idt_maxmgc.ket b/api/tests/integration/tests/formats/ref/idt_maxmgc.ket new file mode 100644 index 0000000000..3cc69c00f3 --- /dev/null +++ b/api/tests/integration/tests/formats/ref/idt_maxmgc.ket @@ -0,0 +1,1692 @@ +{ + "root": { + "nodes": [ + { + "$ref": "monomer0" + }, + { + "$ref": "monomer1" + }, + { + "$ref": "monomer2" + }, + { + "$ref": "monomer3" + }, + { + "$ref": "monomer4" + }, + { + "$ref": "monomer5" + }, + { + "$ref": "monomer6" + }, + { + "$ref": "monomer7" + } + ], + "connections": [ + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer0", + "attachmentPointId": "R3" + }, + "endpoint2": { + "monomerId": "monomer1", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer2", + "attachmentPointId": "R3" + }, + "endpoint2": { + "monomerId": "monomer3", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer0", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer4", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer4", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer2", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer5", + "attachmentPointId": "R3" + }, + "endpoint2": { + "monomerId": "monomer6", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer2", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer7", + "attachmentPointId": "R1" + } + }, + { + "connectionType": "single", + "endpoint1": { + "monomerId": "monomer7", + "attachmentPointId": "R2" + }, + "endpoint2": { + "monomerId": "monomer5", + "attachmentPointId": "R1" + } + } + ], + "templates": [ + { + "$ref": "monomerTemplate-Ade" + }, + { + "$ref": "monomerTemplate-mR" + }, + { + "$ref": "monomerTemplate-mR" + }, + { + "$ref": "monomerTemplate-Gua" + }, + { + "$ref": "monomerTemplate-sP" + }, + { + "$ref": "monomerTemplate-Cyt" + }, + { + "$ref": "monomerTemplate-dRib" + }, + { + "$ref": "monomerTemplate-P" + } + ] + }, + "monomer0": { + "type": "monomer", + "id": "0", + "seqid": 1, + "position": { + "x": 0.0, + "y": -0.0 + }, + "alias": "mR", + "templateId": "mR" + }, + "monomer1": { + "type": "monomer", + "id": "1", + "seqid": 1, + "position": { + "x": 0.0, + "y": -1.600000023841858 + }, + "alias": "A", + "templateId": "Ade" + }, + "monomer2": { + "type": "monomer", + "id": "2", + "seqid": 2, + "position": { + "x": 3.200000047683716, + "y": -0.0 + }, + "alias": "mR", + "templateId": "mR" + }, + "monomer3": { + "type": "monomer", + "id": "3", + "seqid": 2, + "position": { + "x": 3.200000047683716, + "y": -1.600000023841858 + }, + "alias": "G", + "templateId": "Gua" + }, + "monomer4": { + "type": "monomer", + "id": "4", + "seqid": 1, + "position": { + "x": 1.600000023841858, + "y": -0.0 + }, + "alias": "sP", + "templateId": "sP" + }, + "monomer5": { + "type": "monomer", + "id": "5", + "seqid": 3, + "position": { + "x": 6.400000095367432, + "y": -0.0 + }, + "alias": "dR", + "templateId": "dRib" + }, + "monomer6": { + "type": "monomer", + "id": "6", + "seqid": 3, + "position": { + "x": 6.400000095367432, + "y": -1.600000023841858 + }, + "alias": "C", + "templateId": "Cyt" + }, + "monomer7": { + "type": "monomer", + "id": "7", + "seqid": 2, + "position": { + "x": 4.800000190734863, + "y": -0.0 + }, + "alias": "P", + "templateId": "P" + }, + "monomerTemplate-Ade": { + "type": "monomerTemplate", + "id": "Ade", + "class": "Base", + "classHELM": "RNA", + "alias": "A", + "name": "Ade", + "fullName": "Adenine", + "naturalAnalogShort": "A", + "naturalAnalog": "Ade", + "attachmentPoints": [ + { + "attachmentAtom": 6, + "leavingGroup": { + "atoms": [ + 10 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 0.7141363024711609, + 0.172292098402977, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.05462583899497986, + -0.5200490355491638, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.0385116338729859, + -0.200432687997818, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.2537044286727906, + 0.8115247488021851, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.4849422574043274, + 1.5038658380508423, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 0.4990125596523285, + 1.1842495203018189, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.6464310884475709, + -1.0369253158569337, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.0382357835769654, + -1.8738317489624024, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -0.054280977696180347, + -1.5540775060653687, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 1.5013829469680787, + -0.08338717371225357, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -2.474095344543457, + -1.0369253158569337, + 0.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 + ] + } + ] + }, + "monomerTemplate-mR": { + "type": "monomerTemplate", + "id": "mR", + "class": "Sugar", + "classHELM": "RNA", + "alias": "mR", + "name": "mR", + "fullName": "2'-O-Methyl-Ribose", + "naturalAnalogShort": "R", + "naturalAnalog": "Rib", + "attachmentPoints": [ + { + "attachmentAtom": 9, + "leavingGroup": { + "atoms": [ + 10 + ] + } + }, + { + "attachmentAtom": 5, + "leavingGroup": { + "atoms": [ + 11 + ] + } + }, + { + "attachmentAtom": 2, + "leavingGroup": { + "atoms": [ + 8 + ] + } + } + ], + "atoms": [ + { + "label": "O", + "location": [ + -1.3493000268936158, + -0.8392999768257141, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.8371999859809876, + 0.5705999732017517, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + -0.16660000383853913, + -1.7619999647140504, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 0.661899983882904, + 0.5192999839782715, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.0764000415802003, + -0.9222999811172485, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "O", + "location": [ + 1.5810999870300294, + 1.7024999856948853, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 2.483599901199341, + -1.4366999864578248, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.6785000562667847, + 1.8102999925613404, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -0.2076999992132187, + -2.961199998855591, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -3.1754000186920168, + 1.7024999856948853, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -3.8492000102996828, + 2.6953999996185304, + 0.0 + ] + }, + { + "label": "H", + "location": [ + 2.76990008354187, + 1.5394999980926514, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 2.6910998821258547, + -2.6185998916625978, + 0.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 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 12 + ] + } + ] + }, + "monomerTemplate-mR": { + "type": "monomerTemplate", + "id": "mR", + "class": "Sugar", + "classHELM": "RNA", + "alias": "mR", + "name": "mR", + "fullName": "2'-O-Methyl-Ribose", + "naturalAnalogShort": "R", + "naturalAnalog": "Rib", + "attachmentPoints": [ + { + "attachmentAtom": 9, + "leavingGroup": { + "atoms": [ + 10 + ] + } + }, + { + "attachmentAtom": 5, + "leavingGroup": { + "atoms": [ + 11 + ] + } + }, + { + "attachmentAtom": 2, + "leavingGroup": { + "atoms": [ + 8 + ] + } + } + ], + "atoms": [ + { + "label": "O", + "location": [ + -1.3493000268936158, + -0.8392999768257141, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.8371999859809876, + 0.5705999732017517, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + -0.16660000383853913, + -1.7619999647140504, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 0.661899983882904, + 0.5192999839782715, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.0764000415802003, + -0.9222999811172485, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "O", + "location": [ + 1.5810999870300294, + 1.7024999856948853, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 2.483599901199341, + -1.4366999864578248, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.6785000562667847, + 1.8102999925613404, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -0.2076999992132187, + -2.961199998855591, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -3.1754000186920168, + 1.7024999856948853, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -3.8492000102996828, + 2.6953999996185304, + 0.0 + ] + }, + { + "label": "H", + "location": [ + 2.76990008354187, + 1.5394999980926514, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 2.6910998821258547, + -2.6185998916625978, + 0.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 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 12 + ] + } + ] + }, + "monomerTemplate-Gua": { + "type": "monomerTemplate", + "id": "Gua", + "class": "Base", + "classHELM": "RNA", + "alias": "G", + "name": "Gua", + "fullName": "Guanine", + "naturalAnalogShort": "G", + "naturalAnalog": "Gua", + "attachmentPoints": [ + { + "attachmentAtom": 6, + "leavingGroup": { + "atoms": [ + 11 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 1.0354000329971314, + 0.24979999661445619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.07919999957084656, + -0.7540000081062317, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.5056999921798707, + -0.2906000018119812, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.8177000284194947, + 1.1765999794006348, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.7031000256538391, + 2.1803998947143556, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 0.7235000133514404, + 1.7170000076293946, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -2.3870999813079836, + -1.5033999681472779, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.5053000450134278, + -2.7167999744415285, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -0.0786999985575676, + -2.253200054168701, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 2.176800012588501, + -0.120899997651577, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -0.9527000188827515, + 3.3541998863220217, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -3.587100028991699, + -1.5033999681472779, + 0.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 + ] + } + ] + }, + "monomerTemplate-sP": { + "type": "monomerTemplate", + "id": "sP", + "class": "Phosphate", + "classHELM": "RNA", + "alias": "sP", + "name": "sP", + "fullName": "Phosphate", + "naturalAnalogShort": "P", + "attachmentPoints": [ + { + "attachmentAtom": 0, + "leavingGroup": { + "atoms": [ + 1 + ] + } + }, + { + "attachmentAtom": 0, + "leavingGroup": { + "atoms": [ + 3 + ] + } + } + ], + "atoms": [ + { + "label": "P", + "location": [ + -0.19991692900657655, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -1.199918270111084, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.2998337149620056, + -0.8661677837371826, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.8000843524932861, + 0.0, + 0.0 + ] + }, + { + "label": "S", + "location": [ + 0.2998337149620056, + 0.8661677837371826, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 2, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 4 + ] + } + ] + }, + "monomerTemplate-Cyt": { + "type": "monomerTemplate", + "id": "Cyt", + "class": "Base", + "classHELM": "RNA", + "alias": "C", + "name": "Cyt", + "fullName": "Cytosine", + "naturalAnalogShort": "C", + "naturalAnalog": "Cyt", + "attachmentPoints": [ + { + "attachmentAtom": 3, + "leavingGroup": { + "atoms": [ + 8 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 1.8617000579833985, + 1.3499000072479249, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 1.1117000579833985, + 2.648900032043457, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.3882000148296356, + 2.6489999294281008, + 0.0 + ] + }, + { + "label": "N", + "location": [ + -1.138200044631958, + 1.350000023841858, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.38830000162124636, + 0.05090000107884407, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 1.1117000579833985, + 0.05090000107884407, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 3.061800003051758, + 1.3499000072479249, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -0.9883999824523926, + -0.9883000254631043, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -2.3382999897003176, + 1.350000023841858, + 0.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 + ] + } + ] + }, + "monomerTemplate-dRib": { + "type": "monomerTemplate", + "id": "dRib", + "class": "Sugar", + "classHELM": "RNA", + "alias": "dR", + "name": "dRib", + "fullName": "Deoxy-Ribose", + "naturalAnalogShort": "R", + "naturalAnalog": "Rib", + "attachmentPoints": [ + { + "attachmentAtom": 8, + "leavingGroup": { + "atoms": [ + 9 + ] + } + }, + { + "attachmentAtom": 5, + "leavingGroup": { + "atoms": [ + 10 + ] + } + }, + { + "attachmentAtom": 2, + "leavingGroup": { + "atoms": [ + 7 + ] + } + } + ], + "atoms": [ + { + "label": "O", + "location": [ + -0.8787999749183655, + -1.2079999446868897, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -0.3668000102043152, + 0.20190000534057618, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 0.30379998683929446, + -2.13070011138916, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.1323000192642213, + 0.15060000121593476, + 0.0 + ], + "stereoLabel": "abs" + }, + { + "label": "C", + "location": [ + 1.5468000173568726, + -1.2910000085830689, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 2.051500082015991, + 1.333799958229065, + 0.0 + ] + }, + { + "label": "C", + "location": [ + -1.2080999612808228, + 1.4416999816894532, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.262800008058548, + -3.329900026321411, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -2.7049999237060549, + 1.333799958229065, + 0.0 + ] + }, + { + "label": "H", + "location": [ + -3.3787999153137209, + 2.32669997215271, + 0.0 + ] + }, + { + "label": "H", + "location": [ + 3.240299940109253, + 1.1708999872207642, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 6 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 2, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 7 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 5 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 5, + 10 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 8 + ] + }, + { + "type": 1, + "atoms": [ + 8, + 9 + ] + } + ] + }, + "monomerTemplate-P": { + "type": "monomerTemplate", + "id": "P", + "class": "Phosphate", + "classHELM": "RNA", + "alias": "P", + "name": "P", + "fullName": "Phosphate", + "naturalAnalogShort": "P", + "attachmentPoints": [ + { + "attachmentAtom": 0, + "leavingGroup": { + "atoms": [ + 1 + ] + } + }, + { + "attachmentAtom": 0, + "leavingGroup": { + "atoms": [ + 3 + ] + } + } + ], + "atoms": [ + { + "label": "P", + "location": [ + -0.19991692900657655, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + -1.199918270111084, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.2998337149620056, + -0.8661677837371826, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.8000843524932861, + 0.0, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.2998337149620056, + 0.8661677837371826, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 2, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 4 + ] + } + ] + } +} \ No newline at end of file diff --git a/api/wasm/indigo-ketcher/indigo-ketcher.cpp b/api/wasm/indigo-ketcher/indigo-ketcher.cpp index 09e74d9f7c..379c4a7ba2 100644 --- a/api/wasm/indigo-ketcher/indigo-ketcher.cpp +++ b/api/wasm/indigo-ketcher/indigo-ketcher.cpp @@ -320,88 +320,94 @@ namespace indigo int objectId = -1; auto input_format = options.find("input-format"); - if (input_format != options.end() && (input_format->second == "smarts" || input_format->second == "chemical/x-daylight-smarts")) + if (input_format != options.end()) { - print_js("load as smarts"); - objectId = indigoLoadSmartsFromBuffer(data.c_str(), data.size()); - if (objectId >= 0) - { - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMoleculeQuery); - } - exceptionMessages.emplace_back(indigoGetLastError()); - // Let's try reaction - print_js("try as reaction"); - objectId = indigoLoadReactionSmartsFromBuffer(data.c_str(), data.size()); - if (objectId >= 0) + if (input_format->second == "smarts" || input_format->second == "chemical/x-daylight-smarts") { - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETReaction); - } - exceptionMessages.emplace_back(indigoGetLastError()); - } - else if (input_format != options.end() && seq_formats.count(input_format->second)) - { - auto seq_it = seq_formats.find(input_format->second); - objectId = indigoLoadSequenceFromString(data.c_str(), seq_it->second.c_str()); - if (objectId >= 0) - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); - } - else if (input_format != options.end() && fasta_formats.count(input_format->second)) - { - auto fasta_it = fasta_formats.find(input_format->second); - objectId = indigoLoadFastaFromString(data.c_str(), fasta_it->second.c_str()); - if (objectId >= 0) - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); - } - else - { - if (data.find("InChI") == 0) - { - objectId = indigoInchiLoadMolecule(data.c_str()); - if (objectId >= 0) - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); - } - bool query = false; - auto i = options.find("query"); - if (i != options.end() and i->second == "true") - { - query = true; - } - if (!query) - { - // Let's try a simple molecule - print_js("try as molecule"); - objectId = indigoLoadMoleculeFromBuffer(data.c_str(), data.size()); + print_js("load as smarts"); + objectId = indigoLoadSmartsFromBuffer(data.c_str(), data.size()); if (objectId >= 0) { - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMoleculeQuery); } exceptionMessages.emplace_back(indigoGetLastError()); - // Let's try reaction print_js("try as reaction"); - objectId = indigoLoadReactionFromBuffer(data.c_str(), data.size()); + objectId = indigoLoadReactionSmartsFromBuffer(data.c_str(), data.size()); if (objectId >= 0) { return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETReaction); } exceptionMessages.emplace_back(indigoGetLastError()); } - exceptionMessages.emplace_back(indigoGetLastError()); - // Let's try query molecule - print_js("try as query molecule"); - objectId = indigoLoadQueryMoleculeFromBuffer(data.c_str(), data.size()); + else if (seq_formats.count(input_format->second)) + { + auto seq_it = seq_formats.find(input_format->second); + objectId = indigoLoadSequenceFromString(data.c_str(), seq_it->second.c_str()); + if (objectId >= 0) + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); + } + else if (fasta_formats.count(input_format->second)) + { + auto fasta_it = fasta_formats.find(input_format->second); + objectId = indigoLoadFastaFromString(data.c_str(), fasta_it->second.c_str()); + if (objectId >= 0) + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); + } + else if (input_format->second == "chemical/x-idt") + { + objectId = indigoLoadIDTFromString(data.c_str()); + if (objectId >= 0) + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); + } + } + if (data.find("InChI") == 0) + { + objectId = indigoInchiLoadMolecule(data.c_str()); + if (objectId >= 0) + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); + } + bool query = false; + auto i = options.find("query"); + if (i != options.end() and i->second == "true") + { + query = true; + } + if (!query) + { + // Let's try a simple molecule + print_js("try as molecule"); + objectId = indigoLoadMoleculeFromBuffer(data.c_str(), data.size()); if (objectId >= 0) { - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMoleculeQuery); + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); } exceptionMessages.emplace_back(indigoGetLastError()); - // Let's try query reaction - print_js("try as query reaction"); - objectId = indigoLoadQueryReactionFromBuffer(data.c_str(), data.size()); + + // Let's try reaction + print_js("try as reaction"); + objectId = indigoLoadReactionFromBuffer(data.c_str(), data.size()); if (objectId >= 0) { - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETReactionQuery); + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETReaction); } + exceptionMessages.emplace_back(indigoGetLastError()); + } + exceptionMessages.emplace_back(indigoGetLastError()); + // Let's try query molecule + print_js("try as query molecule"); + objectId = indigoLoadQueryMoleculeFromBuffer(data.c_str(), data.size()); + if (objectId >= 0) + { + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMoleculeQuery); + } + exceptionMessages.emplace_back(indigoGetLastError()); + // Let's try query reaction + print_js("try as query reaction"); + objectId = indigoLoadQueryReactionFromBuffer(data.c_str(), data.size()); + if (objectId >= 0) + { + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETReactionQuery); } // It's not anything we can load, let's throw an exception std::stringstream ss; diff --git a/api/wasm/indigo-ketcher/test/idt_maxmgc.ket b/api/wasm/indigo-ketcher/test/idt_maxmgc.ket new file mode 100644 index 0000000000..9e8c3d5b0e --- /dev/null +++ b/api/wasm/indigo-ketcher/test/idt_maxmgc.ket @@ -0,0 +1 @@ +{"struct":"{\"root\":{\"nodes\":[{\"$ref\":\"monomer0\"},{\"$ref\":\"monomer1\"},{\"$ref\":\"monomer2\"},{\"$ref\":\"monomer3\"},{\"$ref\":\"monomer4\"},{\"$ref\":\"monomer5\"},{\"$ref\":\"monomer6\"},{\"$ref\":\"monomer7\"}],\"connections\":[{\"connectionType\":\"single\",\"endpoint1\":{\"monomerId\":\"monomer0\",\"attachmentPointId\":\"R3\"},\"endpoint2\":{\"monomerId\":\"monomer1\",\"attachmentPointId\":\"R1\"}},{\"connectionType\":\"single\",\"endpoint1\":{\"monomerId\":\"monomer2\",\"attachmentPointId\":\"R3\"},\"endpoint2\":{\"monomerId\":\"monomer3\",\"attachmentPointId\":\"R1\"}},{\"connectionType\":\"single\",\"endpoint1\":{\"monomerId\":\"monomer0\",\"attachmentPointId\":\"R2\"},\"endpoint2\":{\"monomerId\":\"monomer4\",\"attachmentPointId\":\"R1\"}},{\"connectionType\":\"single\",\"endpoint1\":{\"monomerId\":\"monomer4\",\"attachmentPointId\":\"R2\"},\"endpoint2\":{\"monomerId\":\"monomer2\",\"attachmentPointId\":\"R1\"}},{\"connectionType\":\"single\",\"endpoint1\":{\"monomerId\":\"monomer5\",\"attachmentPointId\":\"R3\"},\"endpoint2\":{\"monomerId\":\"monomer6\",\"attachmentPointId\":\"R1\"}},{\"connectionType\":\"single\",\"endpoint1\":{\"monomerId\":\"monomer2\",\"attachmentPointId\":\"R2\"},\"endpoint2\":{\"monomerId\":\"monomer7\",\"attachmentPointId\":\"R1\"}},{\"connectionType\":\"single\",\"endpoint1\":{\"monomerId\":\"monomer7\",\"attachmentPointId\":\"R2\"},\"endpoint2\":{\"monomerId\":\"monomer5\",\"attachmentPointId\":\"R1\"}}],\"templates\":[{\"$ref\":\"monomerTemplate-Ade\"},{\"$ref\":\"monomerTemplate-mR\"},{\"$ref\":\"monomerTemplate-mR\"},{\"$ref\":\"monomerTemplate-Gua\"},{\"$ref\":\"monomerTemplate-sP\"},{\"$ref\":\"monomerTemplate-Cyt\"},{\"$ref\":\"monomerTemplate-dRib\"},{\"$ref\":\"monomerTemplate-P\"}]},\"monomer0\":{\"type\":\"monomer\",\"id\":\"0\",\"seqid\":1,\"position\":{\"x\":0.0,\"y\":-0.0},\"alias\":\"mR\",\"templateId\":\"mR\"},\"monomer1\":{\"type\":\"monomer\",\"id\":\"1\",\"seqid\":1,\"position\":{\"x\":0.0,\"y\":-1.600000023841858},\"alias\":\"A\",\"templateId\":\"Ade\"},\"monomer2\":{\"type\":\"monomer\",\"id\":\"2\",\"seqid\":2,\"position\":{\"x\":3.200000047683716,\"y\":-0.0},\"alias\":\"mR\",\"templateId\":\"mR\"},\"monomer3\":{\"type\":\"monomer\",\"id\":\"3\",\"seqid\":2,\"position\":{\"x\":3.200000047683716,\"y\":-1.600000023841858},\"alias\":\"G\",\"templateId\":\"Gua\"},\"monomer4\":{\"type\":\"monomer\",\"id\":\"4\",\"seqid\":1,\"position\":{\"x\":1.600000023841858,\"y\":-0.0},\"alias\":\"sP\",\"templateId\":\"sP\"},\"monomer5\":{\"type\":\"monomer\",\"id\":\"5\",\"seqid\":3,\"position\":{\"x\":6.400000095367432,\"y\":-0.0},\"alias\":\"dR\",\"templateId\":\"dRib\"},\"monomer6\":{\"type\":\"monomer\",\"id\":\"6\",\"seqid\":3,\"position\":{\"x\":6.400000095367432,\"y\":-1.600000023841858},\"alias\":\"C\",\"templateId\":\"Cyt\"},\"monomer7\":{\"type\":\"monomer\",\"id\":\"7\",\"seqid\":2,\"position\":{\"x\":4.800000190734863,\"y\":-0.0},\"alias\":\"P\",\"templateId\":\"P\"},\"monomerTemplate-Ade\":{\"type\":\"monomerTemplate\",\"id\":\"Ade\",\"class\":\"Base\",\"classHELM\":\"RNA\",\"alias\":\"A\",\"name\":\"Ade\",\"fullName\":\"Adenine\",\"naturalAnalogShort\":\"A\",\"naturalAnalog\":\"Ade\",\"attachmentPoints\":[{\"attachmentAtom\":6,\"leavingGroup\":{\"atoms\":[10]}}],\"atoms\":[{\"label\":\"C\",\"location\":[0.7141363024711609,0.172292098402977,0.0]},{\"label\":\"C\",\"location\":[-0.05462583899497986,-0.5200490355491638,0.0]},{\"label\":\"C\",\"location\":[-1.0385116338729859,-0.200432687997818,0.0]},{\"label\":\"N\",\"location\":[-1.2537044286727906,0.8115247488021851,0.0]},{\"label\":\"C\",\"location\":[-0.4849422574043274,1.5038658380508423,0.0]},{\"label\":\"N\",\"location\":[0.4990125596523285,1.1842495203018189,0.0]},{\"label\":\"N\",\"location\":[-1.6464310884475709,-1.0369253158569337,0.0]},{\"label\":\"C\",\"location\":[-1.0382357835769654,-1.8738317489624024,0.0]},{\"label\":\"N\",\"location\":[-0.054280977696180347,-1.5540775060653687,0.0]},{\"label\":\"N\",\"location\":[1.5013829469680787,-0.08338717371225357,0.0]},{\"label\":\"H\",\"location\":[-2.474095344543457,-1.0369253158569337,0.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]}]},\"monomerTemplate-mR\":{\"type\":\"monomerTemplate\",\"id\":\"mR\",\"class\":\"Sugar\",\"classHELM\":\"RNA\",\"alias\":\"mR\",\"name\":\"mR\",\"fullName\":\"2'-O-Methyl-Ribose\",\"naturalAnalogShort\":\"R\",\"naturalAnalog\":\"Rib\",\"attachmentPoints\":[{\"attachmentAtom\":9,\"leavingGroup\":{\"atoms\":[10]}},{\"attachmentAtom\":5,\"leavingGroup\":{\"atoms\":[11]}},{\"attachmentAtom\":2,\"leavingGroup\":{\"atoms\":[8]}}],\"atoms\":[{\"label\":\"O\",\"location\":[-1.3493000268936158,-0.8392999768257141,0.0]},{\"label\":\"C\",\"location\":[-0.8371999859809876,0.5705999732017517,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[-0.16660000383853913,-1.7619999647140504,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[0.661899983882904,0.5192999839782715,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[1.0764000415802003,-0.9222999811172485,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"O\",\"location\":[1.5810999870300294,1.7024999856948853,0.0]},{\"label\":\"O\",\"location\":[2.483599901199341,-1.4366999864578248,0.0]},{\"label\":\"C\",\"location\":[-1.6785000562667847,1.8102999925613404,0.0]},{\"label\":\"O\",\"location\":[-0.2076999992132187,-2.961199998855591,0.0]},{\"label\":\"O\",\"location\":[-3.1754000186920168,1.7024999856948853,0.0]},{\"label\":\"H\",\"location\":[-3.8492000102996828,2.6953999996185304,0.0]},{\"label\":\"H\",\"location\":[2.76990008354187,1.5394999980926514,0.0]},{\"label\":\"C\",\"location\":[2.6910998821258547,-2.6185998916625978,0.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]},{\"type\":1,\"atoms\":[6,12]}]},\"monomerTemplate-mR\":{\"type\":\"monomerTemplate\",\"id\":\"mR\",\"class\":\"Sugar\",\"classHELM\":\"RNA\",\"alias\":\"mR\",\"name\":\"mR\",\"fullName\":\"2'-O-Methyl-Ribose\",\"naturalAnalogShort\":\"R\",\"naturalAnalog\":\"Rib\",\"attachmentPoints\":[{\"attachmentAtom\":9,\"leavingGroup\":{\"atoms\":[10]}},{\"attachmentAtom\":5,\"leavingGroup\":{\"atoms\":[11]}},{\"attachmentAtom\":2,\"leavingGroup\":{\"atoms\":[8]}}],\"atoms\":[{\"label\":\"O\",\"location\":[-1.3493000268936158,-0.8392999768257141,0.0]},{\"label\":\"C\",\"location\":[-0.8371999859809876,0.5705999732017517,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[-0.16660000383853913,-1.7619999647140504,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[0.661899983882904,0.5192999839782715,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[1.0764000415802003,-0.9222999811172485,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"O\",\"location\":[1.5810999870300294,1.7024999856948853,0.0]},{\"label\":\"O\",\"location\":[2.483599901199341,-1.4366999864578248,0.0]},{\"label\":\"C\",\"location\":[-1.6785000562667847,1.8102999925613404,0.0]},{\"label\":\"O\",\"location\":[-0.2076999992132187,-2.961199998855591,0.0]},{\"label\":\"O\",\"location\":[-3.1754000186920168,1.7024999856948853,0.0]},{\"label\":\"H\",\"location\":[-3.8492000102996828,2.6953999996185304,0.0]},{\"label\":\"H\",\"location\":[2.76990008354187,1.5394999980926514,0.0]},{\"label\":\"C\",\"location\":[2.6910998821258547,-2.6185998916625978,0.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]},{\"type\":1,\"atoms\":[6,12]}]},\"monomerTemplate-Gua\":{\"type\":\"monomerTemplate\",\"id\":\"Gua\",\"class\":\"Base\",\"classHELM\":\"RNA\",\"alias\":\"G\",\"name\":\"Gua\",\"fullName\":\"Guanine\",\"naturalAnalogShort\":\"G\",\"naturalAnalog\":\"Gua\",\"attachmentPoints\":[{\"attachmentAtom\":6,\"leavingGroup\":{\"atoms\":[11]}}],\"atoms\":[{\"label\":\"C\",\"location\":[1.0354000329971314,0.24979999661445619,0.0]},{\"label\":\"C\",\"location\":[-0.07919999957084656,-0.7540000081062317,0.0]},{\"label\":\"C\",\"location\":[-1.5056999921798707,-0.2906000018119812,0.0]},{\"label\":\"N\",\"location\":[-1.8177000284194947,1.1765999794006348,0.0]},{\"label\":\"C\",\"location\":[-0.7031000256538391,2.1803998947143556,0.0]},{\"label\":\"N\",\"location\":[0.7235000133514404,1.7170000076293946,0.0]},{\"label\":\"N\",\"location\":[-2.3870999813079836,-1.5033999681472779,0.0]},{\"label\":\"C\",\"location\":[-1.5053000450134278,-2.7167999744415285,0.0]},{\"label\":\"N\",\"location\":[-0.0786999985575676,-2.253200054168701,0.0]},{\"label\":\"O\",\"location\":[2.176800012588501,-0.120899997651577,0.0]},{\"label\":\"N\",\"location\":[-0.9527000188827515,3.3541998863220217,0.0]},{\"label\":\"H\",\"location\":[-3.587100028991699,-1.5033999681472779,0.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]}]},\"monomerTemplate-sP\":{\"type\":\"monomerTemplate\",\"id\":\"sP\",\"class\":\"Phosphate\",\"classHELM\":\"RNA\",\"alias\":\"sP\",\"name\":\"sP\",\"fullName\":\"Phosphate\",\"naturalAnalogShort\":\"P\",\"attachmentPoints\":[{\"attachmentAtom\":0,\"leavingGroup\":{\"atoms\":[1]}},{\"attachmentAtom\":0,\"leavingGroup\":{\"atoms\":[3]}}],\"atoms\":[{\"label\":\"P\",\"location\":[-0.19991692900657655,0.0,0.0]},{\"label\":\"O\",\"location\":[-1.199918270111084,0.0,0.0]},{\"label\":\"O\",\"location\":[0.2998337149620056,-0.8661677837371826,0.0]},{\"label\":\"O\",\"location\":[0.8000843524932861,0.0,0.0]},{\"label\":\"S\",\"location\":[0.2998337149620056,0.8661677837371826,0.0]}],\"bonds\":[{\"type\":1,\"atoms\":[0,1]},{\"type\":2,\"atoms\":[0,2]},{\"type\":1,\"atoms\":[0,3]},{\"type\":1,\"atoms\":[0,4]}]},\"monomerTemplate-Cyt\":{\"type\":\"monomerTemplate\",\"id\":\"Cyt\",\"class\":\"Base\",\"classHELM\":\"RNA\",\"alias\":\"C\",\"name\":\"Cyt\",\"fullName\":\"Cytosine\",\"naturalAnalogShort\":\"C\",\"naturalAnalog\":\"Cyt\",\"attachmentPoints\":[{\"attachmentAtom\":3,\"leavingGroup\":{\"atoms\":[8]}}],\"atoms\":[{\"label\":\"C\",\"location\":[1.8617000579833985,1.3499000072479249,0.0]},{\"label\":\"C\",\"location\":[1.1117000579833985,2.648900032043457,0.0]},{\"label\":\"C\",\"location\":[-0.3882000148296356,2.6489999294281008,0.0]},{\"label\":\"N\",\"location\":[-1.138200044631958,1.350000023841858,0.0]},{\"label\":\"C\",\"location\":[-0.38830000162124636,0.05090000107884407,0.0]},{\"label\":\"N\",\"location\":[1.1117000579833985,0.05090000107884407,0.0]},{\"label\":\"N\",\"location\":[3.061800003051758,1.3499000072479249,0.0]},{\"label\":\"O\",\"location\":[-0.9883999824523926,-0.9883000254631043,0.0]},{\"label\":\"H\",\"location\":[-2.3382999897003176,1.350000023841858,0.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]}]},\"monomerTemplate-dRib\":{\"type\":\"monomerTemplate\",\"id\":\"dRib\",\"class\":\"Sugar\",\"classHELM\":\"RNA\",\"alias\":\"dR\",\"name\":\"dRib\",\"fullName\":\"Deoxy-Ribose\",\"naturalAnalogShort\":\"R\",\"naturalAnalog\":\"Rib\",\"attachmentPoints\":[{\"attachmentAtom\":8,\"leavingGroup\":{\"atoms\":[9]}},{\"attachmentAtom\":5,\"leavingGroup\":{\"atoms\":[10]}},{\"attachmentAtom\":2,\"leavingGroup\":{\"atoms\":[7]}}],\"atoms\":[{\"label\":\"O\",\"location\":[-0.8787999749183655,-1.2079999446868897,0.0]},{\"label\":\"C\",\"location\":[-0.3668000102043152,0.20190000534057618,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[0.30379998683929446,-2.13070011138916,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[1.1323000192642213,0.15060000121593476,0.0],\"stereoLabel\":\"abs\"},{\"label\":\"C\",\"location\":[1.5468000173568726,-1.2910000085830689,0.0]},{\"label\":\"O\",\"location\":[2.051500082015991,1.333799958229065,0.0]},{\"label\":\"C\",\"location\":[-1.2080999612808228,1.4416999816894532,0.0]},{\"label\":\"O\",\"location\":[0.262800008058548,-3.329900026321411,0.0]},{\"label\":\"O\",\"location\":[-2.7049999237060549,1.333799958229065,0.0]},{\"label\":\"H\",\"location\":[-3.3787999153137209,2.32669997215271,0.0]},{\"label\":\"H\",\"location\":[3.240299940109253,1.1708999872207642,0.0]}],\"bonds\":[{\"type\":1,\"atoms\":[0,1]},{\"type\":1,\"atoms\":[0,2]},{\"type\":1,\"atoms\":[1,3]},{\"type\":1,\"atoms\":[1,6],\"stereo\":6},{\"type\":1,\"atoms\":[2,4]},{\"type\":1,\"atoms\":[2,7],\"stereo\":6},{\"type\":1,\"atoms\":[3,4]},{\"type\":1,\"atoms\":[3,5],\"stereo\":1},{\"type\":1,\"atoms\":[5,10]},{\"type\":1,\"atoms\":[6,8]},{\"type\":1,\"atoms\":[8,9]}]},\"monomerTemplate-P\":{\"type\":\"monomerTemplate\",\"id\":\"P\",\"class\":\"Phosphate\",\"classHELM\":\"RNA\",\"alias\":\"P\",\"name\":\"P\",\"fullName\":\"Phosphate\",\"naturalAnalogShort\":\"P\",\"attachmentPoints\":[{\"attachmentAtom\":0,\"leavingGroup\":{\"atoms\":[1]}},{\"attachmentAtom\":0,\"leavingGroup\":{\"atoms\":[3]}}],\"atoms\":[{\"label\":\"P\",\"location\":[-0.19991692900657655,0.0,0.0]},{\"label\":\"O\",\"location\":[-1.199918270111084,0.0,0.0]},{\"label\":\"O\",\"location\":[0.2998337149620056,-0.8661677837371826,0.0]},{\"label\":\"O\",\"location\":[0.8000843524932861,0.0,0.0]},{\"label\":\"O\",\"location\":[0.2998337149620056,0.8661677837371826,0.0]}],\"bonds\":[{\"type\":1,\"atoms\":[0,1]},{\"type\":2,\"atoms\":[0,2]},{\"type\":1,\"atoms\":[0,3]},{\"type\":1,\"atoms\":[0,4]}]}}","format":"ket","original_format":"unknown"} \ No newline at end of file diff --git a/api/wasm/indigo-ketcher/test/test.js b/api/wasm/indigo-ketcher/test/test.js index 2bce6dc5cf..252c3103de 100644 --- a/api/wasm/indigo-ketcher/test/test.js +++ b/api/wasm/indigo-ketcher/test/test.js @@ -947,6 +947,21 @@ M END options.delete(); }); } + + { + test("IDT", "basic", () => { + var fs = require('fs'); + let options = new indigo.MapStringString(); + options.set("output-content-type", "application/json"); + options.set("input-format", "chemical/x-idt"); + const idt = "mA*mGC"; + const res_ket = indigo.convert(idt, "ket", options); + const res_ket_ref = fs.readFileSync("idt_maxmgc.ket"); + assert.equal(res_ket, res_ket_ref.toString()); + options.delete(); + }); + } + // Run tests run(); }); diff --git a/core/indigo-core/molecule/monomers_basic_templates.h b/core/indigo-core/molecule/monomers_basic_templates.h index 8523972cce..315da7914f 100644 --- a/core/indigo-core/molecule/monomers_basic_templates.h +++ b/core/indigo-core/molecule/monomers_basic_templates.h @@ -12,9 +12,18 @@ namespace indigo " \"$ref\": \"monomerTemplate-P\"\n" " },\n" " {\n" + " \"$ref\": \"monomerTemplate-sP\"\n" + " },\n" + " {\n" " \"$ref\": \"monomerTemplate-Rib\"\n" " },\n" " {\n" + " \"$ref\": \"monomerTemplate-LR\"\n" + " },\n" + " {\n" + " \"$ref\": \"monomerTemplate-mR\"\n" + " },\n" + " {\n" " \"$ref\": \"monomerTemplate-Ade\"\n" " },\n" " {\n" @@ -30,6 +39,9 @@ namespace indigo " \"$ref\": \"monomerTemplate-Ura\"\n" " },\n" " {\n" + " \"$ref\": \"monomerTemplate-Ino\"\n" + " },\n" + " {\n" " \"$ref\": \"monomerTemplate-dRib\"\n" " },\n" " {\n" @@ -173,40 +185,624 @@ namespace indigo " {\n" " \"type\": 1,\n" " \"atoms\": [\n" - " 0,\n" - " 1\n" + " 0,\n" + " 1\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 2,\n" + " \"atoms\": [\n" + " 0,\n" + " 2\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 3\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 4\n" + " ]\n" + " }\n" + " ]\n" + " },\n" + " \"monomerTemplate-sP\": {\n" + " \"type\": \"monomerTemplate\",\n" + " \"id\": \"sP\",\n" + " \"fullName\": \"Phosphate\",\n" + " \"class\": \"Phosphate\",\n" + " \"classHELM\": \"RNA\",\n" + " \"alias\": \"sP\",\n" + " \"naturalAnalog\": \"P\",\n" + " \"naturalAnalogShort\": \"P\",\n" + " \"attachmentPoints\": [\n" + " {\n" + " \"attachmentAtom\": 0,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 1\n" + " ]\n" + " },\n" + " \"type\": \"left\"\n" + " },\n" + " {\n" + " \"attachmentAtom\": 0,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 3\n" + " ]\n" + " },\n" + " \"type\": \"right\"\n" + " }\n" + " ],\n" + " \"atoms\": [\n" + " {\n" + " \"label\": \"P\",\n" + " \"location\": [\n" + " -0.19991692871090108,\n" + " 0,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " -1.1999182394782262,\n" + " 0,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 0.29983372634506966,\n" + " -0.8661678020096315,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 0.800084382056424,\n" + " 0,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"S\",\n" + " \"location\": [\n" + " 0.29983372634506966,\n" + " 0.8661678020096315,\n" + " 0\n" + " ]\n" + " }\n" + " ],\n" + " \"bonds\": [\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 1\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 2,\n" + " \"atoms\": [\n" + " 0,\n" + " 2\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 3\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 4\n" + " ]\n" + " }\n" + " ]\n" + " }," + " \"monomerTemplate-Rib\": {\n" + " \"type\": \"monomerTemplate\",\n" + " \"id\": \"Rib\",\n" + " \"fullName\": \"Ribose\",\n" + " \"class\": \"Sugar\",\n" + " \"classHELM\": \"RNA\",\n" + " \"alias\": \"R\",\n" + " \"naturalAnalog\": \"Rib\",\n" + " \"naturalAnalogShort\": \"R\",\n" + " \"attachmentPoints\": [\n" + " {\n" + " \"attachmentAtom\": 9,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 10\n" + " ]\n" + " }\n" + " },\n" + " {\n" + " \"attachmentAtom\": 5,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 11\n" + " ]\n" + " }\n" + " },\n" + " {\n" + " \"attachmentAtom\": 2,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 8\n" + " ]\n" + " }\n" + " }\n" + " ],\n" + " \"atoms\": [\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " -0.7870668737745955,\n" + " -0.7617767155358548,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -0.4212883139374412,\n" + " 0.2454717053907153,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 0.05779587009926911,\n" + " -1.4208925344924144,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 0.6497570315857263,\n" + " 0.20889384940699984,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 0.9458090534539231,\n" + " -0.821072849259456,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 1.306300970043431,\n" + " 1.0541137989057054,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 1.7515935019701854,\n" + " -1.1136956971291794,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -1.022322498294859,\n" + " 1.131198772746387,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 0.028505008862309486,\n" + " -2.2776145051109995,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " -2.091724697943758,\n" + " 1.0541137989057054,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"H\",\n" + " \"location\": [\n" + " -2.573094997979451,\n" + " 1.7634527287149055,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"H\",\n" + " \"location\": [\n" + " 2.1556645047902916,\n" + " 0.9376647652075489,\n" + " 0\n" + " ]\n" + " }\n" + " ],\n" + " \"bonds\": [\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 1\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 2\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 1,\n" + " 3\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 1,\n" + " 7\n" + " ],\n" + " \"stereo\": 6\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 2,\n" + " 4\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 2,\n" + " 8\n" + " ],\n" + " \"stereo\": 6\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 3,\n" + " 4\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 3,\n" + " 5\n" + " ],\n" + " \"stereo\": 1\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 4,\n" + " 6\n" + " ],\n" + " \"stereo\": 1\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 5,\n" + " 11\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 7,\n" + " 9\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 9,\n" + " 10\n" + " ]\n" + " }\n" + " ]\n" + " },\n" + " \"monomerTemplate-LR\": {\n" + " \"type\": \"monomerTemplate\",\n" + " \"id\": \"LR\",\n" + " \"fullName\": \"2,'4'-locked-Ribose\",\n" + " \"class\": \"Sugar\",\n" + " \"classHELM\": \"RNA\",\n" + " \"alias\": \"LR\",\n" + " \"naturalAnalog\": \"Rib\",\n" + " \"naturalAnalogShort\": \"R\",\n" + " \"attachmentPoints\": [\n" + " {\n" + " \"attachmentAtom\": 8,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 9\n" + " ]\n" + " },\n" + " \"type\": \"left\"\n" + " },\n" + " {\n" + " \"attachmentAtom\": 5,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 10\n" + " ]\n" + " },\n" + " \"type\": \"right\"\n" + " },\n" + " {\n" + " \"attachmentAtom\": 2,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 7\n" + " ]\n" + " },\n" + " \"type\": \"side\"\n" + " }\n" + " ],\n" + " \"atoms\": [\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " -0.6408069550632618,\n" + " 0.025362798468799477,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 0.3575229898739885,\n" + " -0.36716613720847996,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -1.0304957857036705,\n" + " -0.7046762939156813,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 1.270517685796424,\n" + " 0.04795154085507401,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -0.13625899281545137,\n" + " -1.1351833783418142,\n" + " 0\n" + " ],\n" + " \"stereoLabel\": \"abs\"\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 1.0314204710645123,\n" + " 1.0201260998713748,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 0.24728728507079492,\n" + " 0.6217188072573164,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " -1.7668755777053513,\n" + " -0.41155103452887903,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " -0.660423494503974,\n" + " 1.0201260998713748,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"H\",\n" + " \"location\": [\n" + " -0.7478723100578556,\n" + " 1.807891978354113,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"H\",\n" + " \"location\": [\n" + " 1.6107358496318043,\n" + " 1.5609349380550472,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 0.41247571988972076,\n" + " -1.331018527977206,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 0.052707065567973915,\n" + " -2.154648988669731,\n" + " 0\n" + " ]\n" + " }\n" + " ],\n" + " \"bonds\": [\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 1\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 2\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 1,\n" + " 3\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 1,\n" + " 6\n" + " ],\n" + " \"stereo\": 1\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 2,\n" + " 4\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 2,\n" + " 7\n" + " ],\n" + " \"stereo\": 6\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 3,\n" + " 4\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 5,\n" + " 10\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 6,\n" + " 8\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 8,\n" + " 9\n" " ]\n" " },\n" " {\n" - " \"type\": 2,\n" + " \"type\": 1,\n" " \"atoms\": [\n" - " 0,\n" - " 2\n" - " ]\n" + " 1,\n" + " 11\n" + " ],\n" + " \"stereo\": 6\n" " },\n" " {\n" " \"type\": 1,\n" " \"atoms\": [\n" - " 0,\n" - " 3\n" + " 11,\n" + " 12\n" " ]\n" " },\n" " {\n" " \"type\": 1,\n" " \"atoms\": [\n" - " 0,\n" - " 4\n" - " ]\n" + " 4,\n" + " 12\n" + " ],\n" + " \"stereo\": 1\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 3,\n" + " 5\n" + " ],\n" + " \"stereo\": 1\n" " }\n" " ]\n" " },\n" - " \"monomerTemplate-Rib\": {\n" + " \"monomerTemplate-mR\": {\n" " \"type\": \"monomerTemplate\",\n" - " \"id\": \"Rib\",\n" - " \"fullName\": \"Ribose\",\n" + " \"id\": \"mR\",\n" + " \"fullName\": \"2'-O-Methyl-Ribose\",\n" " \"class\": \"Sugar\",\n" " \"classHELM\": \"RNA\",\n" - " \"alias\": \"R\",\n" + " \"alias\": \"mR\",\n" " \"naturalAnalog\": \"Rib\",\n" " \"naturalAnalogShort\": \"R\",\n" " \"attachmentPoints\": [\n" @@ -216,7 +812,8 @@ namespace indigo " \"atoms\": [\n" " 10\n" " ]\n" - " }\n" + " },\n" + " \"type\": \"left\"\n" " },\n" " {\n" " \"attachmentAtom\": 5,\n" @@ -224,7 +821,8 @@ namespace indigo " \"atoms\": [\n" " 11\n" " ]\n" - " }\n" + " },\n" + " \"type\": \"right\"\n" " },\n" " {\n" " \"attachmentAtom\": 2,\n" @@ -232,23 +830,24 @@ namespace indigo " \"atoms\": [\n" " 8\n" " ]\n" - " }\n" + " },\n" + " \"type\": \"side\"\n" " }\n" " ],\n" " \"atoms\": [\n" " {\n" " \"label\": \"O\",\n" " \"location\": [\n" - " -0.7870668737745955,\n" - " -0.7617767155358548,\n" + " -1.3493,\n" + " -0.8393,\n" " 0\n" " ]\n" " },\n" " {\n" " \"label\": \"C\",\n" " \"location\": [\n" - " -0.4212883139374412,\n" - " 0.2454717053907153,\n" + " -0.8372,\n" + " 0.5706,\n" " 0\n" " ],\n" " \"stereoLabel\": \"abs\"\n" @@ -256,8 +855,8 @@ namespace indigo " {\n" " \"label\": \"C\",\n" " \"location\": [\n" - " 0.05779587009926911,\n" - " -1.4208925344924144,\n" + " -0.1666,\n" + " -1.762,\n" " 0\n" " ],\n" " \"stereoLabel\": \"abs\"\n" @@ -265,8 +864,8 @@ namespace indigo " {\n" " \"label\": \"C\",\n" " \"location\": [\n" - " 0.6497570315857263,\n" - " 0.20889384940699984,\n" + " 0.6619,\n" + " 0.5193,\n" " 0\n" " ],\n" " \"stereoLabel\": \"abs\"\n" @@ -274,8 +873,8 @@ namespace indigo " {\n" " \"label\": \"C\",\n" " \"location\": [\n" - " 0.9458090534539231,\n" - " -0.821072849259456,\n" + " 1.0764,\n" + " -0.9223,\n" " 0\n" " ],\n" " \"stereoLabel\": \"abs\"\n" @@ -283,56 +882,64 @@ namespace indigo " {\n" " \"label\": \"O\",\n" " \"location\": [\n" - " 1.306300970043431,\n" - " 1.0541137989057054,\n" + " 1.5811,\n" + " 1.7025,\n" " 0\n" " ]\n" " },\n" " {\n" " \"label\": \"O\",\n" " \"location\": [\n" - " 1.7515935019701854,\n" - " -1.1136956971291794,\n" + " 2.4836,\n" + " -1.4367,\n" " 0\n" " ]\n" " },\n" " {\n" " \"label\": \"C\",\n" " \"location\": [\n" - " -1.022322498294859,\n" - " 1.131198772746387,\n" + " -1.6785,\n" + " 1.8103,\n" " 0\n" " ]\n" " },\n" " {\n" " \"label\": \"O\",\n" " \"location\": [\n" - " 0.028505008862309486,\n" - " -2.2776145051109995,\n" + " -0.2077,\n" + " -2.9612,\n" " 0\n" " ]\n" " },\n" " {\n" " \"label\": \"O\",\n" " \"location\": [\n" - " -2.091724697943758,\n" - " 1.0541137989057054,\n" + " -3.1754,\n" + " 1.7025,\n" " 0\n" " ]\n" " },\n" " {\n" " \"label\": \"H\",\n" " \"location\": [\n" - " -2.573094997979451,\n" - " 1.7634527287149055,\n" + " -3.8492,\n" + " 2.6954,\n" " 0\n" " ]\n" " },\n" " {\n" " \"label\": \"H\",\n" " \"location\": [\n" - " 2.1556645047902916,\n" - " 0.9376647652075489,\n" + " 2.7699,\n" + " 1.5395,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 2.6911,\n" + " -2.6186,\n" " 0\n" " ]\n" " }\n" @@ -425,6 +1032,13 @@ namespace indigo " 9,\n" " 10\n" " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 6,\n" + " 12\n" + " ]\n" " }\n" " ]\n" " },\n" @@ -1327,6 +1941,202 @@ namespace indigo " }\n" " ]\n" " },\n" + " \"monomerTemplate-Ino\": {\n" + " \"type\": \"monomerTemplate\",\n" + " \"id\": \"Ino\",\n" + " \"fullName\": \"Inosine\",\n" + " \"class\": \"Base\",\n" + " \"classHELM\": \"RNA\",\n" + " \"alias\": \"I\",\n" + " \"naturalAnalog\": \"X\",\n" + " \"naturalAnalogShort\": \"X\",\n" + " \"attachmentPoints\": [\n" + " {\n" + " \"attachmentAtom\": 6,\n" + " \"leavingGroup\": {\n" + " \"atoms\": [\n" + " 10\n" + " ]\n" + " }\n" + " }\n" + " ],\n" + " \"atoms\": [\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " 0.7141362781700783,\n" + " 0.17229210188032215,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -0.05462583854652327,\n" + " -0.5200490184858402,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -1.0385116805492436,\n" + " -0.20043268537398562,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"N\",\n" + " \"location\": [\n" + " -1.2537043778537293,\n" + " 0.8115247681040312,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -0.48494226113712763,\n" + " 1.5038658884701934,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"N\",\n" + " \"location\": [\n" + " 0.4990125528839594,\n" + " 1.184249555358339,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"N\",\n" + " \"location\": [\n" + " -1.6464310504344153,\n" + " -1.0369253241268066,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"C\",\n" + " \"location\": [\n" + " -1.0382357924757764,\n" + " -1.8738317949898284,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"N\",\n" + " \"location\": [\n" + " -0.054280978454689155,\n" + " -1.55407751784124,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"O\",\n" + " \"location\": [\n" + " 1.5013828958089879,\n" + " -0.08338717020548818,\n" + " 0\n" + " ]\n" + " },\n" + " {\n" + " \"label\": \"H\",\n" + " \"location\": [\n" + " -2.474095270836283,\n" + " -1.0369253241268066,\n" + " 0\n" + " ]\n" + " }\n" + " ],\n" + " \"bonds\": [\n" + " {\n" + " \"type\": 2,\n" + " \"atoms\": [\n" + " 0,\n" + " 9\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 5\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 0,\n" + " 1\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 8,\n" + " 1\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 2,\n" + " \"atoms\": [\n" + " 1,\n" + " 2\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 6,\n" + " 2\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 2,\n" + " 3\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 2,\n" + " \"atoms\": [\n" + " 3,\n" + " 4\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 4,\n" + " 5\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 6,\n" + " 7\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 1,\n" + " \"atoms\": [\n" + " 6,\n" + " 10\n" + " ]\n" + " },\n" + " {\n" + " \"type\": 2,\n" + " \"atoms\": [\n" + " 7,\n" + " 8\n" + " ]\n" + " }\n" + " ]\n" + " },\n" " \"monomerTemplate-dRib\": {\n" " \"type\": \"monomerTemplate\",\n" " \"id\": \"dRib\",\n" diff --git a/core/indigo-core/molecule/sequence_loader.h b/core/indigo-core/molecule/sequence_loader.h index 0278e48aa0..31393d6c84 100644 --- a/core/indigo-core/molecule/sequence_loader.h +++ b/core/indigo-core/molecule/sequence_loader.h @@ -56,23 +56,25 @@ namespace indigo void loadSequence(BaseMolecule& mol, const std::string& seq_type_str); void loadFasta(BaseMolecule& mol, const std::string& seq_type_str); void loadFasta(BaseMolecule& mol, SeqType seq_type); + void loadIDT(BaseMolecule& mol); private: bool addMonomer(BaseMolecule& mol, char ch, SeqType seq_type); - bool addTemplate(BaseMolecule& mol, char ch, SeqType seq_type); + bool addTemplate(BaseMolecule& mol, const std::string alias, MonomerType seq_type); void addAminoAcid(BaseMolecule& mol, char ch); - void addNucleotide(BaseMolecule& mol, char ch, const std::string& sugar_alias); + void addNucleotide(BaseMolecule& mol, char ch, const std::string& sugar_alias, const std::string& phosphate_alias); bool addMonomerTemplate(BaseMolecule& mol, MonomerType mt, const std::string& alias); + bool checkAddTemplate(BaseMolecule& mol, MonomerType type, const std::string monomer); SequenceLoader(const SequenceLoader&); // no implicit copy Scanner& _scanner; - std::unordered_set, pair_hash> _added_templates; + std::unordered_set, pair_hash> _added_templates; const MonomerTemplates& _mon_lib; Array _left_apid; Array _right_apid; Array _xlink_apid; int _seq_id; - int _last_sugar_idx; + int _last_monomer_idx; int _row; int _col; }; diff --git a/core/indigo-core/molecule/src/molecule_auto_loader.cpp b/core/indigo-core/molecule/src/molecule_auto_loader.cpp index da7a48ee6f..facc024a4f 100644 --- a/core/indigo-core/molecule/src/molecule_auto_loader.cpp +++ b/core/indigo-core/molecule/src/molecule_auto_loader.cpp @@ -391,6 +391,7 @@ void MoleculeAutoLoader::_loadMolecule(BaseMolecule& mol) const std::string kPeptide = "PEPTIDE:"; const std::string kRNA = "RNA:"; const std::string kDNA = "DNA:"; + const std::string kIDT = "IDT:"; long long start_pos = _scanner->tell(); if (_scanner->length() > static_cast(kRNA.size())) @@ -408,6 +409,11 @@ void MoleculeAutoLoader::_loadMolecule(BaseMolecule& mol) sl.loadSequence(mol, SequenceLoader::SeqType::DNASeq); return; } + else if (kIDT == tag.data()) + { + sl.loadIDT(mol); + return; + } else { _scanner->seek(start_pos, SEEK_SET); diff --git a/core/indigo-core/molecule/src/monomers_lib.cpp b/core/indigo-core/molecule/src/monomers_lib.cpp index 74b619ffa0..9938ae1873 100644 --- a/core/indigo-core/molecule/src/monomers_lib.cpp +++ b/core/indigo-core/molecule/src/monomers_lib.cpp @@ -143,6 +143,7 @@ namespace indigo if (!data.Parse(kMonomersBasicTemplates).HasParseError()) { MoleculeJsonLoader loader(data); + loader.stereochemistry_options.ignore_errors = true; loader.loadMolecule(_templates_mol->asMolecule()); for (auto i = _templates_mol->tgroups.begin(); i != _templates_mol->tgroups.end(); i = _templates_mol->tgroups.next(i)) { diff --git a/core/indigo-core/molecule/src/sequence_loader.cpp b/core/indigo-core/molecule/src/sequence_loader.cpp index 937fc29e6c..8098010cfd 100644 --- a/core/indigo-core/molecule/src/sequence_loader.cpp +++ b/core/indigo-core/molecule/src/sequence_loader.cpp @@ -33,7 +33,7 @@ using namespace indigo; IMPL_ERROR(SequenceLoader, "SEQUENCE loader"); SequenceLoader::SequenceLoader(Scanner& scanner) - : _scanner(scanner), _mon_lib(MonomerTemplates::_instance()), _seq_id(0), _last_sugar_idx(-1), _row(-1), _col(0) + : _scanner(scanner), _mon_lib(MonomerTemplates::_instance()), _seq_id(0), _last_monomer_idx(-1), _row(-1), _col(0) { _left_apid.readString(kLeftAttachmentPoint, true); _right_apid.readString(kRightAttachmentPoint, true); @@ -59,7 +59,7 @@ void SequenceLoader::loadFasta(BaseMolecule& mol, const std::string& seq_type_st void SequenceLoader::loadFasta(BaseMolecule& mol, SeqType seq_type) { _seq_id = 0; - _last_sugar_idx = -1; + _last_monomer_idx = -1; _row = 0; _col = 0; int frag_idx = 0; @@ -88,6 +88,7 @@ void SequenceLoader::loadFasta(BaseMolecule& mol, SeqType seq_type) _col = 0; _row++; } + _last_monomer_idx = -1; properties.insert(kFASTA_HEADER, fasta_str); if (mol.vertexCount() > 0) // do not increment fragment id if first fragment frag_idx++; @@ -146,7 +147,7 @@ void SequenceLoader::loadSequence(BaseMolecule& mol, const std::string& seq_type void SequenceLoader::loadSequence(BaseMolecule& mol, SeqType seq_type) { _seq_id = 0; - _last_sugar_idx = -1; + _last_monomer_idx = -1; _row = 0; _col = 0; mol.clear(); @@ -175,15 +176,15 @@ void SequenceLoader::loadSequence(BaseMolecule& mol, SeqType seq_type) throw Error("Invalid symbols in the sequence: %s", invalid_symbols.c_str()); } -bool SequenceLoader::addTemplate(BaseMolecule& mol, char ch, SeqType seq_type) +bool SequenceLoader::addTemplate(BaseMolecule& mol, const std::string alias, MonomerType mon_type) { int tg_idx = mol.tgroups.addTGroup(); auto& tg = mol.tgroups.getTGroup(tg_idx); - if (_mon_lib.getMonomerTemplate(seq_type == SeqType::PEPTIDESeq ? MonomerType::AminoAcid : MonomerType::Base, std::string(1, ch), tg)) + if (_mon_lib.getMonomerTemplate(mon_type, alias, tg)) { tg.tgroup_id = tg_idx; - _added_templates.emplace(seq_type, ch); + _added_templates.emplace(mon_type, alias); return true; } return false; @@ -191,7 +192,8 @@ bool SequenceLoader::addTemplate(BaseMolecule& mol, char ch, SeqType seq_type) bool SequenceLoader::addMonomer(BaseMolecule& mol, char ch, SeqType seq_type) { - if (_added_templates.find(std::make_pair(seq_type, ch)) == _added_templates.end() && !addTemplate(mol, ch, seq_type)) + MonomerType mt = seq_type == SeqType::PEPTIDESeq ? MonomerType::AminoAcid : MonomerType::Base; + if (_added_templates.count(std::make_pair(mt, std::string(1, ch))) == 0 && !addTemplate(mol, std::string(1, ch), mt)) return false; // add phosphate template @@ -205,10 +207,10 @@ bool SequenceLoader::addMonomer(BaseMolecule& mol, char ch, SeqType seq_type) addAminoAcid(mol, ch); break; case SeqType::RNASeq: - addNucleotide(mol, ch, "R"); + addNucleotide(mol, ch, "R", "P"); break; case SeqType::DNASeq: - addNucleotide(mol, ch, "dR"); + addNucleotide(mol, ch, "dR", "P"); break; } _col++; @@ -233,11 +235,11 @@ void SequenceLoader::addAminoAcid(BaseMolecule& mol, char ch) } } -void SequenceLoader::addNucleotide(BaseMolecule& mol, char ch, const std::string& sugar_alias) +void SequenceLoader::addNucleotide(BaseMolecule& mol, char ch, const std::string& sugar_alias, const std::string& phosphate_alias) { Vec3f pos(_col * MoleculeLayout::DEFAULT_BOND_LENGTH, -MoleculeLayout::DEFAULT_BOND_LENGTH * _row, 0); - // add ribose template + // add sugar template if (_seq_id == 1) addMonomerTemplate(mol, MonomerType::Sugar, sugar_alias); @@ -262,27 +264,34 @@ void SequenceLoader::addNucleotide(BaseMolecule& mol, char ch, const std::string mol.asMolecule().setTemplateAtomAttachmentDestination(sugar_idx, nuc_base_idx, _xlink_apid); mol.asMolecule().setTemplateAtomAttachmentDestination(nuc_base_idx, sugar_idx, _left_apid); - if (_seq_id > 1) + if (_seq_id > 1 && phosphate_alias.size()) { // add phosphate int phosphate_idx = mol.asMolecule().addAtom(-1); - mol.asMolecule().setTemplateAtom(phosphate_idx, "P"); + mol.asMolecule().setTemplateAtom(phosphate_idx, phosphate_alias.c_str()); mol.asMolecule().setTemplateAtomClass(phosphate_idx, kMonomerClassPHOSPHATE); mol.asMolecule().setTemplateAtomSeqid(phosphate_idx, _seq_id - 1); Vec3f phosphate_coord(pos.x - MoleculeLayout::DEFAULT_BOND_LENGTH, pos.y, 0); mol.asMolecule().setAtomXyz(phosphate_idx, phosphate_coord); // connect phosphate to the last sugar - mol.asMolecule().addBond_Silent(_last_sugar_idx, phosphate_idx, BOND_SINGLE); - mol.asMolecule().setTemplateAtomAttachmentDestination(phosphate_idx, _last_sugar_idx, _left_apid); - mol.asMolecule().setTemplateAtomAttachmentDestination(_last_sugar_idx, phosphate_idx, _right_apid); + mol.asMolecule().addBond_Silent(_last_monomer_idx, phosphate_idx, BOND_SINGLE); + mol.asMolecule().setTemplateAtomAttachmentDestination(phosphate_idx, _last_monomer_idx, _left_apid); + mol.asMolecule().setTemplateAtomAttachmentDestination(_last_monomer_idx, phosphate_idx, _right_apid); - // connect phoshpate to the current sugar + // connect phosphate to the current sugar mol.asMolecule().addBond_Silent(phosphate_idx, sugar_idx, BOND_SINGLE); mol.asMolecule().setTemplateAtomAttachmentDestination(phosphate_idx, sugar_idx, _right_apid); mol.asMolecule().setTemplateAtomAttachmentDestination(sugar_idx, phosphate_idx, _left_apid); } - _last_sugar_idx = sugar_idx; + else if (_last_monomer_idx >= 0) + { + // No phosphate - connect sugar to previous monomer + mol.asMolecule().addBond_Silent(_last_monomer_idx, sugar_idx, BOND_SINGLE); + mol.asMolecule().setTemplateAtomAttachmentDestination(sugar_idx, _last_monomer_idx, _left_apid); + mol.asMolecule().setTemplateAtomAttachmentDestination(_last_monomer_idx, sugar_idx, _right_apid); + } + _last_monomer_idx = sugar_idx; _col++; } @@ -299,3 +308,84 @@ bool SequenceLoader::addMonomerTemplate(BaseMolecule& mol, MonomerType mt, const mol.tgroups.remove(tg_idx); return false; } + +// return true if monomer already in templates or successfuly added. otherwise - false +bool SequenceLoader::checkAddTemplate(BaseMolecule& mol, MonomerType type, const std::string monomer) +{ + if (_added_templates.count(std::make_pair(type, monomer)) == 0) + if (!addTemplate(mol, monomer, type)) + return false; + return true; +} + +void SequenceLoader::loadIDT(BaseMolecule& mol) +{ + const auto IDT_DEF_SUGAR = "dR"; + const auto IDT_DEF_PHOSPHATE = "P"; + static const std::unordered_set IDT_STANDARD_BASES = {'A', 'T', 'C', 'G', 'U', 'I'}; + _seq_id = 0; + _last_monomer_idx = -1; + _row = 0; + _col = 0; + mol.clear(); + std::string invalid_symbols; + std::string sugar = IDT_DEF_SUGAR; + std::string phosphate = ""; + std::string base = ""; + + while (!_scanner.isEOF()) + { + auto ch = _scanner.readChar(); + switch (ch) + { + case '+': + sugar = "LR"; + break; + case 'm': + sugar = "mR"; + break; + case 'r': + sugar = "R"; + break; + case '*': + phosphate = "sP"; + break; + default: + base = std::string(1, ch); + break; + }; + if (base.size() > 0) + { + if (_col > 0 && phosphate.size() == 0) + { + phosphate = IDT_DEF_PHOSPHATE; + } + if (IDT_STANDARD_BASES.count(ch) == 0) + { + if (invalid_symbols.size()) + invalid_symbols += ','; + invalid_symbols += ch; + } + else + { + if (!checkAddTemplate(mol, MonomerType::Base, base)) + throw Error("Unknown base '%s'", base.c_str()); + if (!checkAddTemplate(mol, MonomerType::Sugar, sugar)) + throw Error("Unknown sugar '%s'", sugar.c_str()); + if (phosphate.size() > 0 && !checkAddTemplate(mol, MonomerType::Phosphate, phosphate)) + throw Error("Unknown phosphate '%s'", phosphate.c_str()); + + _seq_id++; + + addNucleotide(mol, ch, sugar, phosphate); + _col++; + } + sugar = IDT_DEF_SUGAR; // reset sugar to default + phosphate = ""; + base = ""; + } + } + + if (invalid_symbols.size()) + throw Error("Invalid symbols in the sequence: %s", invalid_symbols.c_str()); +} diff --git a/utils/indigo-depict/main.c b/utils/indigo-depict/main.c index 1c48b389bd..f6c748eb9f 100644 --- a/utils/indigo-depict/main.c +++ b/utils/indigo-depict/main.c @@ -937,6 +937,10 @@ int main(int argc, char* argv[]) { obj = indigoLoadSequence(reader, p.seq_type); } + else if (strcasecmp(p.infile_ext, "idt") == 0) + { + obj = indigoLoadIDT(reader); + } else obj = indigoLoadMolecule(reader); diff --git a/utils/indigo-service/backend/service/tests/api/indigo_test.py b/utils/indigo-service/backend/service/tests/api/indigo_test.py index 3dd4a64407..1e00d7836f 100644 --- a/utils/indigo-service/backend/service/tests/api/indigo_test.py +++ b/utils/indigo-service/backend/service/tests/api/indigo_test.py @@ -474,10 +474,16 @@ def test_headers_wrong(self): data="c1ccccc1", ) self.assertEqual(400, result.status_code) - expected_text = "ValidationError: {'input_format': ['Must be one of: chemical/x-mdl-rxnfile, \ -chemical/x-mdl-molfile, chemical/x-indigo-ket, chemical/x-daylight-smiles, \ -chemical/x-cml, chemical/x-inchi, chemical/x-inchi-key, chemical/x-iupac, chemical/x-daylight-smarts, \ -chemical/x-inchi-aux, chemical/x-chemaxon-cxsmiles, chemical/x-cdxml, chemical/x-cdx, chemical/x-sdf, chemical/x-peptide-sequence, chemical/x-rna-sequence, chemical/x-dna-sequence, chemical/x-sequence, chemical/x-peptide-fasta, chemical/x-rna-fasta, chemical/x-dna-fasta, chemical/x-fasta.']}" + formats = "chemical/x-mdl-rxnfile, chemical/x-mdl-molfile, chemical/x-indigo-ket, \ +chemical/x-daylight-smiles, chemical/x-cml, chemical/x-inchi, chemical/x-inchi-key, \ +chemical/x-iupac, chemical/x-daylight-smarts, chemical/x-inchi-aux, chemical/x-chemaxon-cxsmiles, \ +chemical/x-cdxml, chemical/x-cdx, chemical/x-sdf, chemical/x-peptide-sequence, \ +chemical/x-rna-sequence, chemical/x-dna-sequence, chemical/x-sequence, chemical/x-peptide-fasta, \ +chemical/x-rna-fasta, chemical/x-dna-fasta, chemical/x-fasta, chemical/x-idt." + expected_text = ( + "ValidationError: {'input_format': ['Must be one of: %s']}" + % formats + ) self.assertEquals( expected_text, result.text, @@ -492,10 +498,10 @@ def test_headers_wrong(self): data="c1ccccc1", ) self.assertEqual(400, result.status_code) - expected_text = "ValidationError: {'output_format': ['Must be one of: chemical/x-mdl-rxnfile, \ -chemical/x-mdl-molfile, chemical/x-indigo-ket, chemical/x-daylight-smiles, \ -chemical/x-cml, chemical/x-inchi, chemical/x-inchi-key, chemical/x-iupac, chemical/x-daylight-smarts, \ -chemical/x-inchi-aux, chemical/x-chemaxon-cxsmiles, chemical/x-cdxml, chemical/x-cdx, chemical/x-sdf, chemical/x-peptide-sequence, chemical/x-rna-sequence, chemical/x-dna-sequence, chemical/x-sequence, chemical/x-peptide-fasta, chemical/x-rna-fasta, chemical/x-dna-fasta, chemical/x-fasta.']}" + expected_text = ( + "ValidationError: {'output_format': ['Must be one of: %s']}" + % formats + ) self.assertEquals( expected_text, result.text, @@ -590,7 +596,7 @@ def test_convert_large_cdx(self): self.url_prefix + "/convert", headers=headers, data=data ) self.assertEqual(200, result.status_code) - print(result.text) + # print(result.text) def test_convert_correct(self): formats = ( @@ -3413,6 +3419,36 @@ def test_convert_fasta(self): json.loads(result_dna_ket.text)["struct"], file.read() ) + def test_convert_idt(self): + fname = "idt_maxmgc" + idt_prefix = os.path.join(joinPathPy("structures/", __file__), fname) + + # IDT to ket + with open(idt_prefix + ".idt", "r") as file: + idt = file.read() + + headers, data = self.get_headers( + { + "struct": idt, + "input_format": "chemical/x-idt", + "output_format": "chemical/x-indigo-ket", + } + ) + + result = requests.post( + self.url_prefix + "/convert", headers=headers, data=data + ) + result_ket = json.loads(result.text)["struct"] + + ref_prefix = os.path.join(joinPathPy("ref/", __file__), fname) + # write references + # with open(ref_prefix + ".ket", "w") as file: + # file.write(result_ket) + + # check + with open(ref_prefix + ".ket", "r") as file: + self.assertEqual(result_ket, file.read()) + if __name__ == "__main__": unittest.main(verbosity=2, warnings="ignore") diff --git a/utils/indigo-service/backend/service/tests/api/ref/idt_maxmgc.ket b/utils/indigo-service/backend/service/tests/api/ref/idt_maxmgc.ket new file mode 100644 index 0000000000..61d635fba8 --- /dev/null +++ b/utils/indigo-service/backend/service/tests/api/ref/idt_maxmgc.ket @@ -0,0 +1 @@ +{"root":{"nodes":[{"$ref":"monomer0"},{"$ref":"monomer1"},{"$ref":"monomer2"},{"$ref":"monomer3"},{"$ref":"monomer4"},{"$ref":"monomer5"},{"$ref":"monomer6"},{"$ref":"monomer7"}],"connections":[{"connectionType":"single","endpoint1":{"monomerId":"monomer0","attachmentPointId":"R3"},"endpoint2":{"monomerId":"monomer1","attachmentPointId":"R1"}},{"connectionType":"single","endpoint1":{"monomerId":"monomer2","attachmentPointId":"R3"},"endpoint2":{"monomerId":"monomer3","attachmentPointId":"R1"}},{"connectionType":"single","endpoint1":{"monomerId":"monomer0","attachmentPointId":"R2"},"endpoint2":{"monomerId":"monomer4","attachmentPointId":"R1"}},{"connectionType":"single","endpoint1":{"monomerId":"monomer4","attachmentPointId":"R2"},"endpoint2":{"monomerId":"monomer2","attachmentPointId":"R1"}},{"connectionType":"single","endpoint1":{"monomerId":"monomer5","attachmentPointId":"R3"},"endpoint2":{"monomerId":"monomer6","attachmentPointId":"R1"}},{"connectionType":"single","endpoint1":{"monomerId":"monomer2","attachmentPointId":"R2"},"endpoint2":{"monomerId":"monomer7","attachmentPointId":"R1"}},{"connectionType":"single","endpoint1":{"monomerId":"monomer7","attachmentPointId":"R2"},"endpoint2":{"monomerId":"monomer5","attachmentPointId":"R1"}}],"templates":[{"$ref":"monomerTemplate-Ade"},{"$ref":"monomerTemplate-mR"},{"$ref":"monomerTemplate-mR"},{"$ref":"monomerTemplate-Gua"},{"$ref":"monomerTemplate-sP"},{"$ref":"monomerTemplate-Cyt"},{"$ref":"monomerTemplate-dRib"},{"$ref":"monomerTemplate-P"}]},"monomer0":{"type":"monomer","id":"0","seqid":1,"position":{"x":0.0,"y":-0.0},"alias":"mR","templateId":"mR"},"monomer1":{"type":"monomer","id":"1","seqid":1,"position":{"x":0.0,"y":-1.600000023841858},"alias":"A","templateId":"Ade"},"monomer2":{"type":"monomer","id":"2","seqid":2,"position":{"x":3.200000047683716,"y":-0.0},"alias":"mR","templateId":"mR"},"monomer3":{"type":"monomer","id":"3","seqid":2,"position":{"x":3.200000047683716,"y":-1.600000023841858},"alias":"G","templateId":"Gua"},"monomer4":{"type":"monomer","id":"4","seqid":1,"position":{"x":1.600000023841858,"y":-0.0},"alias":"sP","templateId":"sP"},"monomer5":{"type":"monomer","id":"5","seqid":3,"position":{"x":6.400000095367432,"y":-0.0},"alias":"dR","templateId":"dRib"},"monomer6":{"type":"monomer","id":"6","seqid":3,"position":{"x":6.400000095367432,"y":-1.600000023841858},"alias":"C","templateId":"Cyt"},"monomer7":{"type":"monomer","id":"7","seqid":2,"position":{"x":4.800000190734863,"y":-0.0},"alias":"P","templateId":"P"},"monomerTemplate-Ade":{"type":"monomerTemplate","id":"Ade","class":"Base","classHELM":"RNA","alias":"A","name":"Ade","fullName":"Adenine","naturalAnalogShort":"A","naturalAnalog":"Ade","attachmentPoints":[{"attachmentAtom":6,"leavingGroup":{"atoms":[10]}}],"atoms":[{"label":"C","location":[0.7141363024711609,0.172292098402977,0.0]},{"label":"C","location":[-0.05462583899497986,-0.5200490355491638,0.0]},{"label":"C","location":[-1.0385116338729859,-0.200432687997818,0.0]},{"label":"N","location":[-1.2537044286727906,0.8115247488021851,0.0]},{"label":"C","location":[-0.4849422574043274,1.5038658380508423,0.0]},{"label":"N","location":[0.4990125596523285,1.1842495203018189,0.0]},{"label":"N","location":[-1.6464310884475709,-1.0369253158569337,0.0]},{"label":"C","location":[-1.0382357835769654,-1.8738317489624024,0.0]},{"label":"N","location":[-0.054280977696180347,-1.5540775060653687,0.0]},{"label":"N","location":[1.5013829469680787,-0.08338717371225357,0.0]},{"label":"H","location":[-2.474095344543457,-1.0369253158569337,0.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]}]},"monomerTemplate-mR":{"type":"monomerTemplate","id":"mR","class":"Sugar","classHELM":"RNA","alias":"mR","name":"mR","fullName":"2'-O-Methyl-Ribose","naturalAnalogShort":"R","naturalAnalog":"Rib","attachmentPoints":[{"attachmentAtom":9,"leavingGroup":{"atoms":[10]}},{"attachmentAtom":5,"leavingGroup":{"atoms":[11]}},{"attachmentAtom":2,"leavingGroup":{"atoms":[8]}}],"atoms":[{"label":"O","location":[-1.3493000268936158,-0.8392999768257141,0.0]},{"label":"C","location":[-0.8371999859809876,0.5705999732017517,0.0],"stereoLabel":"abs"},{"label":"C","location":[-0.16660000383853913,-1.7619999647140504,0.0],"stereoLabel":"abs"},{"label":"C","location":[0.661899983882904,0.5192999839782715,0.0],"stereoLabel":"abs"},{"label":"C","location":[1.0764000415802003,-0.9222999811172485,0.0],"stereoLabel":"abs"},{"label":"O","location":[1.5810999870300294,1.7024999856948853,0.0]},{"label":"O","location":[2.483599901199341,-1.4366999864578248,0.0]},{"label":"C","location":[-1.6785000562667847,1.8102999925613404,0.0]},{"label":"O","location":[-0.2076999992132187,-2.961199998855591,0.0]},{"label":"O","location":[-3.1754000186920168,1.7024999856948853,0.0]},{"label":"H","location":[-3.8492000102996828,2.6953999996185304,0.0]},{"label":"H","location":[2.76990008354187,1.5394999980926514,0.0]},{"label":"C","location":[2.6910998821258547,-2.6185998916625978,0.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]},{"type":1,"atoms":[6,12]}]},"monomerTemplate-mR":{"type":"monomerTemplate","id":"mR","class":"Sugar","classHELM":"RNA","alias":"mR","name":"mR","fullName":"2'-O-Methyl-Ribose","naturalAnalogShort":"R","naturalAnalog":"Rib","attachmentPoints":[{"attachmentAtom":9,"leavingGroup":{"atoms":[10]}},{"attachmentAtom":5,"leavingGroup":{"atoms":[11]}},{"attachmentAtom":2,"leavingGroup":{"atoms":[8]}}],"atoms":[{"label":"O","location":[-1.3493000268936158,-0.8392999768257141,0.0]},{"label":"C","location":[-0.8371999859809876,0.5705999732017517,0.0],"stereoLabel":"abs"},{"label":"C","location":[-0.16660000383853913,-1.7619999647140504,0.0],"stereoLabel":"abs"},{"label":"C","location":[0.661899983882904,0.5192999839782715,0.0],"stereoLabel":"abs"},{"label":"C","location":[1.0764000415802003,-0.9222999811172485,0.0],"stereoLabel":"abs"},{"label":"O","location":[1.5810999870300294,1.7024999856948853,0.0]},{"label":"O","location":[2.483599901199341,-1.4366999864578248,0.0]},{"label":"C","location":[-1.6785000562667847,1.8102999925613404,0.0]},{"label":"O","location":[-0.2076999992132187,-2.961199998855591,0.0]},{"label":"O","location":[-3.1754000186920168,1.7024999856948853,0.0]},{"label":"H","location":[-3.8492000102996828,2.6953999996185304,0.0]},{"label":"H","location":[2.76990008354187,1.5394999980926514,0.0]},{"label":"C","location":[2.6910998821258547,-2.6185998916625978,0.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]},{"type":1,"atoms":[6,12]}]},"monomerTemplate-Gua":{"type":"monomerTemplate","id":"Gua","class":"Base","classHELM":"RNA","alias":"G","name":"Gua","fullName":"Guanine","naturalAnalogShort":"G","naturalAnalog":"Gua","attachmentPoints":[{"attachmentAtom":6,"leavingGroup":{"atoms":[11]}}],"atoms":[{"label":"C","location":[1.0354000329971314,0.24979999661445619,0.0]},{"label":"C","location":[-0.07919999957084656,-0.7540000081062317,0.0]},{"label":"C","location":[-1.5056999921798707,-0.2906000018119812,0.0]},{"label":"N","location":[-1.8177000284194947,1.1765999794006348,0.0]},{"label":"C","location":[-0.7031000256538391,2.1803998947143556,0.0]},{"label":"N","location":[0.7235000133514404,1.7170000076293946,0.0]},{"label":"N","location":[-2.3870999813079836,-1.5033999681472779,0.0]},{"label":"C","location":[-1.5053000450134278,-2.7167999744415285,0.0]},{"label":"N","location":[-0.0786999985575676,-2.253200054168701,0.0]},{"label":"O","location":[2.176800012588501,-0.120899997651577,0.0]},{"label":"N","location":[-0.9527000188827515,3.3541998863220217,0.0]},{"label":"H","location":[-3.587100028991699,-1.5033999681472779,0.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]}]},"monomerTemplate-sP":{"type":"monomerTemplate","id":"sP","class":"Phosphate","classHELM":"RNA","alias":"sP","name":"sP","fullName":"Phosphate","naturalAnalogShort":"P","attachmentPoints":[{"attachmentAtom":0,"leavingGroup":{"atoms":[1]}},{"attachmentAtom":0,"leavingGroup":{"atoms":[3]}}],"atoms":[{"label":"P","location":[-0.19991692900657655,0.0,0.0]},{"label":"O","location":[-1.199918270111084,0.0,0.0]},{"label":"O","location":[0.2998337149620056,-0.8661677837371826,0.0]},{"label":"O","location":[0.8000843524932861,0.0,0.0]},{"label":"S","location":[0.2998337149620056,0.8661677837371826,0.0]}],"bonds":[{"type":1,"atoms":[0,1]},{"type":2,"atoms":[0,2]},{"type":1,"atoms":[0,3]},{"type":1,"atoms":[0,4]}]},"monomerTemplate-Cyt":{"type":"monomerTemplate","id":"Cyt","class":"Base","classHELM":"RNA","alias":"C","name":"Cyt","fullName":"Cytosine","naturalAnalogShort":"C","naturalAnalog":"Cyt","attachmentPoints":[{"attachmentAtom":3,"leavingGroup":{"atoms":[8]}}],"atoms":[{"label":"C","location":[1.8617000579833985,1.3499000072479249,0.0]},{"label":"C","location":[1.1117000579833985,2.648900032043457,0.0]},{"label":"C","location":[-0.3882000148296356,2.6489999294281008,0.0]},{"label":"N","location":[-1.138200044631958,1.350000023841858,0.0]},{"label":"C","location":[-0.38830000162124636,0.05090000107884407,0.0]},{"label":"N","location":[1.1117000579833985,0.05090000107884407,0.0]},{"label":"N","location":[3.061800003051758,1.3499000072479249,0.0]},{"label":"O","location":[-0.9883999824523926,-0.9883000254631043,0.0]},{"label":"H","location":[-2.3382999897003176,1.350000023841858,0.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]}]},"monomerTemplate-dRib":{"type":"monomerTemplate","id":"dRib","class":"Sugar","classHELM":"RNA","alias":"dR","name":"dRib","fullName":"Deoxy-Ribose","naturalAnalogShort":"R","naturalAnalog":"Rib","attachmentPoints":[{"attachmentAtom":8,"leavingGroup":{"atoms":[9]}},{"attachmentAtom":5,"leavingGroup":{"atoms":[10]}},{"attachmentAtom":2,"leavingGroup":{"atoms":[7]}}],"atoms":[{"label":"O","location":[-0.8787999749183655,-1.2079999446868897,0.0]},{"label":"C","location":[-0.3668000102043152,0.20190000534057618,0.0],"stereoLabel":"abs"},{"label":"C","location":[0.30379998683929446,-2.13070011138916,0.0],"stereoLabel":"abs"},{"label":"C","location":[1.1323000192642213,0.15060000121593476,0.0],"stereoLabel":"abs"},{"label":"C","location":[1.5468000173568726,-1.2910000085830689,0.0]},{"label":"O","location":[2.051500082015991,1.333799958229065,0.0]},{"label":"C","location":[-1.2080999612808228,1.4416999816894532,0.0]},{"label":"O","location":[0.262800008058548,-3.329900026321411,0.0]},{"label":"O","location":[-2.7049999237060549,1.333799958229065,0.0]},{"label":"H","location":[-3.3787999153137209,2.32669997215271,0.0]},{"label":"H","location":[3.240299940109253,1.1708999872207642,0.0]}],"bonds":[{"type":1,"atoms":[0,1]},{"type":1,"atoms":[0,2]},{"type":1,"atoms":[1,3]},{"type":1,"atoms":[1,6],"stereo":6},{"type":1,"atoms":[2,4]},{"type":1,"atoms":[2,7],"stereo":6},{"type":1,"atoms":[3,4]},{"type":1,"atoms":[3,5],"stereo":1},{"type":1,"atoms":[5,10]},{"type":1,"atoms":[6,8]},{"type":1,"atoms":[8,9]}]},"monomerTemplate-P":{"type":"monomerTemplate","id":"P","class":"Phosphate","classHELM":"RNA","alias":"P","name":"P","fullName":"Phosphate","naturalAnalogShort":"P","attachmentPoints":[{"attachmentAtom":0,"leavingGroup":{"atoms":[1]}},{"attachmentAtom":0,"leavingGroup":{"atoms":[3]}}],"atoms":[{"label":"P","location":[-0.19991692900657655,0.0,0.0]},{"label":"O","location":[-1.199918270111084,0.0,0.0]},{"label":"O","location":[0.2998337149620056,-0.8661677837371826,0.0]},{"label":"O","location":[0.8000843524932861,0.0,0.0]},{"label":"O","location":[0.2998337149620056,0.8661677837371826,0.0]}],"bonds":[{"type":1,"atoms":[0,1]},{"type":2,"atoms":[0,2]},{"type":1,"atoms":[0,3]},{"type":1,"atoms":[0,4]}]}} \ No newline at end of file diff --git a/utils/indigo-service/backend/service/tests/api/structures/idt_maxmgc.idt b/utils/indigo-service/backend/service/tests/api/structures/idt_maxmgc.idt new file mode 100644 index 0000000000..9a443d9daf --- /dev/null +++ b/utils/indigo-service/backend/service/tests/api/structures/idt_maxmgc.idt @@ -0,0 +1 @@ +mA*mGC \ No newline at end of file diff --git a/utils/indigo-service/backend/service/v2/indigo_api.py b/utils/indigo-service/backend/service/v2/indigo_api.py index 13e6c5b33a..098c01cc62 100644 --- a/utils/indigo-service/backend/service/v2/indigo_api.py +++ b/utils/indigo-service/backend/service/v2/indigo_api.py @@ -347,6 +347,10 @@ def load_moldata( md.struct = indigo.loadFasta(molstr, "DNA") md.is_rxn = False md.is_query = False + elif input_format == "chemical/x-idt": + md.struct = indigo.loadIDT(molstr) + md.is_rxn = False + md.is_query = False elif molstr.startswith("InChI"): md.struct = indigo.inchi.loadMolecule(molstr) md.is_rxn = False @@ -875,9 +879,11 @@ def convert(): elif request.method == "GET": input_dict = { "struct": request.args["struct"], - "output_format": request.args["output_format"] - if "output_format" in request.args - else "chemical/x-mdl-molfile", + "output_format": ( + request.args["output_format"] + if "output_format" in request.args + else "chemical/x-mdl-molfile" + ), } data = IndigoRequestSchema().load(input_dict) diff --git a/utils/indigo-service/backend/service/v2/validation.py b/utils/indigo-service/backend/service/v2/validation.py index 7dab99a8ac..2632f09b41 100644 --- a/utils/indigo-service/backend/service/v2/validation.py +++ b/utils/indigo-service/backend/service/v2/validation.py @@ -32,6 +32,7 @@ class InputFormatSchema(Schema): "chemical/x-rna-fasta", "chemical/x-dna-fasta", "chemical/x-fasta", + "chemical/x-idt", ) input_format = fields.Str(missing=None, validate=OneOf(struct_mime_types))