From 0bb9a8e8e542edeeebe17067a26744103e128772 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Thu, 6 Mar 2025 19:14:19 +0300 Subject: [PATCH 1/9] #2798 - Peptide sequence not pasting directly on canvas Fix code. Add UTs --- api/wasm/indigo-ketcher/indigo-ketcher.cpp | 29 +++++++- api/wasm/indigo-ketcher/test/test.js | 34 ++++++++++ .../backend/service/tests/api/indigo_test.py | 68 +++++++++++++++++++ .../backend/service/v2/indigo_api.py | 62 +++++++++++++---- 4 files changed, 176 insertions(+), 17 deletions(-) diff --git a/api/wasm/indigo-ketcher/indigo-ketcher.cpp b/api/wasm/indigo-ketcher/indigo-ketcher.cpp index a8bd71d84f..efbd4983a3 100644 --- a/api/wasm/indigo-ketcher/indigo-ketcher.cpp +++ b/api/wasm/indigo-ketcher/indigo-ketcher.cpp @@ -275,7 +275,7 @@ namespace indigo void indigoSetOptions(const std::map& options) { - std::set to_skip{"smiles", "smarts", "input-format", "output-content-type", "monomerLibrary"}; + std::set to_skip{"smiles", "smarts", "input-format", "output-content-type", "monomerLibrary", "sequence-type"}; for (const auto& option : options) { if (to_skip.count(option.first) < 1) @@ -454,13 +454,38 @@ namespace indigo if (library >= 0) { + auto sequence_type = options.find("sequence-type"); + if (sequence_type != options.end() && (sequence_type->second == "PEPTIDE") + { + print_js("try as PEPTIDE-3-LETTER"); + objectId = indigoLoadSequenceFromString(data.c_str(), "PEPTIDE-3-LETTER", library); + if (objectId >= 0) + { + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETDocument); + } + } print_js("try as IDT"); objectId = indigoLoadIdtFromString(data.c_str(), library); if (objectId >= 0) { return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETDocument); } - + if (sequence_type != options.end()) + { + print_js("try as " + sequence_type->second); + objectId = indigoLoadSequenceFromString(data.c_str(), sequence_type->second.c_str(), library); + if (objectId >= 0) + { + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETDocument); + } + }else{ + print_js("try as PEPTIDE-3-LETTER"); + objectId = indigoLoadSequenceFromString(data.c_str(), "PEPTIDE-3-LETTER", library); + if (objectId >= 0) + { + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETDocument); + } + } print_js("try as HELM"); objectId = indigoLoadHelmFromString(data.c_str(), library); if (objectId >= 0) diff --git a/api/wasm/indigo-ketcher/test/test.js b/api/wasm/indigo-ketcher/test/test.js index 1bfa11bc0d..c2a4a1c626 100644 --- a/api/wasm/indigo-ketcher/test/test.js +++ b/api/wasm/indigo-ketcher/test/test.js @@ -836,6 +836,14 @@ M END const peptide_seq_ref1 = fs.readFileSync("peptide_ref.seq"); assert.equal(peptide_seq, peptide_seq_ref1.toString()); options.delete(); + // test autodetect + let ad_options = new indigo.MapStringString(); + ad_options.set("output-content-type", "application/json"); + ad_options.set("monomerLibrary", monomersLib); + ad_options.set("sequence-type", "PEPTIDE"); + const res2 = indigo.convert(peptide_seq_ref, "ket", ad_options); + assert.equal(res2, peptide_ket_ref.toString()); + ad_options.delete(); }); } @@ -861,6 +869,16 @@ M END const peptide_seq1 = indigo.convert(peptide_ket_ref.toString(), "peptide-sequence-3-letter", options); assert.equal(peptide_seq1, peptide_seq_ref); options.delete(); + // test autodetect + let ad_options = new indigo.MapStringString(); + ad_options.set("output-content-type", "application/json"); + ad_options.set("monomerLibrary", monomersLib); + const res2 = indigo.convert(peptide_seq_ref, "ket", ad_options); + assert.equal(res2, peptide_ket_ref.toString()); + ad_options.set("sequence-type", "PEPTIDE"); + const res3 = indigo.convert(peptide_seq_ref, "ket", ad_options); + assert.equal(res3, peptide_ket_ref.toString()); + ad_options.delete(); }); } @@ -883,6 +901,14 @@ M END const rna_seq_ref1 = fs.readFileSync("rna_ref.seq"); assert.equal(rna_seq, rna_seq_ref1.toString()); options.delete(); + // test autodetect + let ad_options = new indigo.MapStringString(); + ad_options.set("output-content-type", "application/json"); + ad_options.set("monomerLibrary", monomersLib); + ad_options.set("sequence-type", "DNA"); + const res2 = indigo.convert(rna_seq_ref, "ket", ad_options); + assert.equal(res2, rna_ket_ref.toString()); + ad_options.delete(); }); } @@ -906,6 +932,14 @@ M END const dna_seq_ref1 = fs.readFileSync("dna_ref.seq"); assert.equal(dna_seq, dna_seq_ref1.toString()); options.delete(); + // test autodetect + let ad_options = new indigo.MapStringString(); + ad_options.set("output-content-type", "application/json"); + ad_options.set("monomerLibrary", monomersLib); + ad_options.set("sequence-type", "DNA"); + const res2 = indigo.convert(dna_seq_ref, "ket", ad_options); + assert.equal(res2, dna_ket_ref.toString()); + ad_options.delete(); }); } 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 530ac20498..74d5f27274 100644 --- a/utils/indigo-service/backend/service/tests/api/indigo_test.py +++ b/utils/indigo-service/backend/service/tests/api/indigo_test.py @@ -3225,6 +3225,19 @@ def test_convert_sequences(self): self.url_prefix + "/convert", headers=headers, data=data ) + # test autodetect RNA + headers, data = self.get_headers( + { + "struct": "ACGTU", + "options": {"monomerLibrary": monomer_library}, + "output_format": "chemical/x-indigo-ket", + "sequence-type": "RNA", + } + ) + result_rna_ad = requests.post( + self.url_prefix + "/convert", headers=headers, data=data + ) + headers, data = self.get_headers( { "struct": "ACGTU", @@ -3252,6 +3265,19 @@ def test_convert_sequences(self): self.url_prefix + "/convert", headers=headers, data=data ) + # test autodetect DNA + headers, data = self.get_headers( + { + "struct": "ACGTU", + "options": {"monomerLibrary": monomer_library}, + "output_format": "chemical/x-indigo-ket", + "sequence-type": "DNA", + } + ) + result_dna_ad = requests.post( + self.url_prefix + "/convert", headers=headers, data=data + ) + headers, data = self.get_headers( { "struct": "ACGTU", @@ -3278,6 +3304,19 @@ def test_convert_sequences(self): self.url_prefix + "/convert", headers=headers, data=data ) + # test autodetect PEPTIDE + headers, data = self.get_headers( + { + "struct": "ACGTU", + "options": {"monomerLibrary": monomer_library}, + "output_format": "chemical/x-indigo-ket", + "sequence-type": "PEPTIDE", + } + ) + result_peptide_ad = requests.post( + self.url_prefix + "/convert", headers=headers, data=data + ) + peptide_3 = "AlaCysGlyThrSec" headers, data = self.get_headers( { @@ -3291,6 +3330,30 @@ def test_convert_sequences(self): self.url_prefix + "/convert", headers=headers, data=data ) + # test autodetect PEPTIDE-3-LETTER + headers, data = self.get_headers( + { + "struct": peptide_3, + "options": {"monomerLibrary": monomer_library}, + "output_format": "chemical/x-indigo-ket", + "sequence-type": "PEPTIDE", + } + ) + result_ket_3_ad = requests.post( + self.url_prefix + "/convert", headers=headers, data=data + ) + + headers, data = self.get_headers( + { + "struct": peptide_3, + "options": {"monomerLibrary": monomer_library}, + "output_format": "chemical/x-indigo-ket", + } + ) + result_ket_3_ad_no_type = requests.post( + self.url_prefix + "/convert", headers=headers, data=data + ) + headers, data = self.get_headers( { "struct": json.loads(result_ket_3.text)["struct"], @@ -3334,15 +3397,20 @@ def test_convert_sequences(self): with open(os.path.join(ref_path, "rna_ref") + ".ket", "r") as file: rna_ref = file.read() self.assertEqual(result_rna.text, rna_ref) + self.assertEqual(result_rna_ad.text, rna_ref) with open(os.path.join(ref_path, "dna_ref") + ".ket", "r") as file: dna_ref = file.read() self.assertEqual(result_dna.text, dna_ref) + self.assertEqual(result_dna_ad.text, dna_ref) with open(os.path.join(ref_path, "peptide_ref") + ".ket", "r") as file: peptide_ref = file.read() self.assertEqual(result_peptide.text, peptide_ref) + self.assertEqual(result_peptide_ad.text, peptide_ref) self.assertEqual(result_ket_3.text, peptide_ref) + self.assertEqual(result_ket_3_ad.text, peptide_ref) + self.assertEqual(result_ket_3_ad_no_type.text, peptide_ref) def test_convert_fasta(self): ref_path = joinPathPy("ref/", __file__) diff --git a/utils/indigo-service/backend/service/v2/indigo_api.py b/utils/indigo-service/backend/service/v2/indigo_api.py index c174a7da9e..26ede54126 100644 --- a/utils/indigo-service/backend/service/v2/indigo_api.py +++ b/utils/indigo-service/backend/service/v2/indigo_api.py @@ -79,6 +79,7 @@ def indigo_init(options={}): "input-format", "output-content-type", "monomerLibrary", + "sequence-type", ): continue tls.indigo.setOption(option, value) @@ -306,6 +307,50 @@ def remove_unselected_repeating_units_r(r, selected): remove_unselected_repeating_units_m(m, moleculeAtoms) +def try_load_macromol(indigo, md, molstr, library, options): + sequence_type = options.get("sequence-type") + if sequence_type == "PEPTIDE": + try: + md.struct = indigo.loadSequence(molstr, "PEPTIDE-3-LETTER", library) + md.is_rxn = False + md.is_query = False + return + except IndigoException: + pass + try: + md.struct = indigo.loadIdt(molstr, library) + md.is_rxn = False + md.is_query = False + return + except IndigoException: + pass + if sequence_type is not None: + try: + md.struct = indigo.loadSequence(molstr, sequence_type, library) + md.is_rxn = False + md.is_query = False + return + except IndigoException: + pass + else: + try: + md.struct = indigo.loadSequence(molstr, "PEPTIDE-3-LETTER", library) + md.is_rxn = False + md.is_query = False + return + except IndigoException: + pass + try: + md.struct = indigo.loadHelm( + molstr, library + ) + except IndigoException: + raise HttpException( + "struct data not recognized as molecule, query, reaction or reaction query", + 400, + ) + + def load_moldata( molstr, indigo=None, @@ -408,21 +453,8 @@ def load_moldata( "struct data not recognized as molecule, query, reaction or reaction query", 400, ) - else: # has library try to load IDT and HELM - try: - md.struct = indigo.loadIdt(molstr, library) - md.is_rxn = False - except IndigoException: - try: - md.struct = indigo.loadHelm( - molstr, library - ) - except IndigoException: - raise HttpException( - "struct data not recognized as molecule, query, reaction or reaction query", - 400, - ) - + else: # has library try to load macromolecule + try_load_macromol(indigo, md, molstr, library, options) return md From b30648b8ad0da789bbb12e12fa5ff3e39276d8bc Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Thu, 6 Mar 2025 19:25:30 +0300 Subject: [PATCH 2/9] fix typo --- .../backend/service/v2/indigo_api.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/utils/indigo-service/backend/service/v2/indigo_api.py b/utils/indigo-service/backend/service/v2/indigo_api.py index 26ede54126..35e2235bd4 100644 --- a/utils/indigo-service/backend/service/v2/indigo_api.py +++ b/utils/indigo-service/backend/service/v2/indigo_api.py @@ -311,7 +311,9 @@ def try_load_macromol(indigo, md, molstr, library, options): sequence_type = options.get("sequence-type") if sequence_type == "PEPTIDE": try: - md.struct = indigo.loadSequence(molstr, "PEPTIDE-3-LETTER", library) + md.struct = indigo.loadSequence( + molstr, "PEPTIDE-3-LETTER", library + ) md.is_rxn = False md.is_query = False return @@ -334,16 +336,16 @@ def try_load_macromol(indigo, md, molstr, library, options): pass else: try: - md.struct = indigo.loadSequence(molstr, "PEPTIDE-3-LETTER", library) + md.struct = indigo.loadSequence( + molstr, "PEPTIDE-3-LETTER", library + ) md.is_rxn = False md.is_query = False return except IndigoException: pass try: - md.struct = indigo.loadHelm( - molstr, library - ) + md.struct = indigo.loadHelm(molstr, library) except IndigoException: raise HttpException( "struct data not recognized as molecule, query, reaction or reaction query", @@ -454,7 +456,9 @@ def load_moldata( 400, ) else: # has library try to load macromolecule - try_load_macromol(indigo, md, molstr, library, options) + try_load_macromol( + indigo, md, molstr, library, options + ) return md From 3a0351ac9b2f54fe1ca10df2060a783beb8f06f2 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Thu, 6 Mar 2025 19:37:00 +0300 Subject: [PATCH 3/9] fix typo --- api/wasm/indigo-ketcher/indigo-ketcher.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/wasm/indigo-ketcher/indigo-ketcher.cpp b/api/wasm/indigo-ketcher/indigo-ketcher.cpp index efbd4983a3..d3275a97dc 100644 --- a/api/wasm/indigo-ketcher/indigo-ketcher.cpp +++ b/api/wasm/indigo-ketcher/indigo-ketcher.cpp @@ -472,7 +472,8 @@ namespace indigo } if (sequence_type != options.end()) { - print_js("try as " + sequence_type->second); + std::msg = "try as " + sequence_type->second; + print_js(msg.c_str()); objectId = indigoLoadSequenceFromString(data.c_str(), sequence_type->second.c_str(), library); if (objectId >= 0) { From 993cc9181e15b7d8a77018595edcecf9dca82152 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Thu, 6 Mar 2025 19:46:26 +0300 Subject: [PATCH 4/9] fix typo --- api/wasm/indigo-ketcher/indigo-ketcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/wasm/indigo-ketcher/indigo-ketcher.cpp b/api/wasm/indigo-ketcher/indigo-ketcher.cpp index d3275a97dc..2b0676f232 100644 --- a/api/wasm/indigo-ketcher/indigo-ketcher.cpp +++ b/api/wasm/indigo-ketcher/indigo-ketcher.cpp @@ -472,7 +472,7 @@ namespace indigo } if (sequence_type != options.end()) { - std::msg = "try as " + sequence_type->second; + std::string msg = "try as " + sequence_type->second; print_js(msg.c_str()); objectId = indigoLoadSequenceFromString(data.c_str(), sequence_type->second.c_str(), library); if (objectId >= 0) From e506dfc2baf361e046f7e7f5707a277013901ae8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Thu, 6 Mar 2025 20:07:56 +0300 Subject: [PATCH 5/9] Fix errors --- api/wasm/indigo-ketcher/indigo-ketcher.cpp | 6 ++++-- core/indigo-core/common/base_cpp/profiling.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/wasm/indigo-ketcher/indigo-ketcher.cpp b/api/wasm/indigo-ketcher/indigo-ketcher.cpp index 2b0676f232..821407e67f 100644 --- a/api/wasm/indigo-ketcher/indigo-ketcher.cpp +++ b/api/wasm/indigo-ketcher/indigo-ketcher.cpp @@ -455,7 +455,7 @@ namespace indigo if (library >= 0) { auto sequence_type = options.find("sequence-type"); - if (sequence_type != options.end() && (sequence_type->second == "PEPTIDE") + if (sequence_type != options.end() && sequence_type->second == "PEPTIDE") { print_js("try as PEPTIDE-3-LETTER"); objectId = indigoLoadSequenceFromString(data.c_str(), "PEPTIDE-3-LETTER", library); @@ -479,7 +479,9 @@ namespace indigo { return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETDocument); } - }else{ + } + else + { print_js("try as PEPTIDE-3-LETTER"); objectId = indigoLoadSequenceFromString(data.c_str(), "PEPTIDE-3-LETTER", library); if (objectId >= 0) diff --git a/core/indigo-core/common/base_cpp/profiling.h b/core/indigo-core/common/base_cpp/profiling.h index c8f9cdfcc8..e187eab6ba 100644 --- a/core/indigo-core/common/base_cpp/profiling.h +++ b/core/indigo-core/common/base_cpp/profiling.h @@ -24,6 +24,7 @@ #endif #include +#include #include #include "base_cpp/array.h" From bee40f7e8c89e79a1375cf0705f55436a96e2937 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Thu, 6 Mar 2025 21:12:01 +0300 Subject: [PATCH 6/9] Fix UTs --- api/wasm/indigo-ketcher/test/test.js | 6 ++--- .../backend/service/tests/api/indigo_test.py | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/api/wasm/indigo-ketcher/test/test.js b/api/wasm/indigo-ketcher/test/test.js index c2a4a1c626..0ce1cb5680 100644 --- a/api/wasm/indigo-ketcher/test/test.js +++ b/api/wasm/indigo-ketcher/test/test.js @@ -873,10 +873,10 @@ M END let ad_options = new indigo.MapStringString(); ad_options.set("output-content-type", "application/json"); ad_options.set("monomerLibrary", monomersLib); - const res2 = indigo.convert(peptide_seq_ref, "ket", ad_options); + const res2 = JSON.parse(indigo.convert(peptide_seq_ref, "ket", options)).struct; assert.equal(res2, peptide_ket_ref.toString()); ad_options.set("sequence-type", "PEPTIDE"); - const res3 = indigo.convert(peptide_seq_ref, "ket", ad_options); + const res3 = JSON.parse(indigo.convert(peptide_seq_ref, "ket", options)).struct; assert.equal(res3, peptide_ket_ref.toString()); ad_options.delete(); }); @@ -905,7 +905,7 @@ M END let ad_options = new indigo.MapStringString(); ad_options.set("output-content-type", "application/json"); ad_options.set("monomerLibrary", monomersLib); - ad_options.set("sequence-type", "DNA"); + ad_options.set("sequence-type", "RNA"); const res2 = indigo.convert(rna_seq_ref, "ket", ad_options); assert.equal(res2, rna_ket_ref.toString()); ad_options.delete(); 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 74d5f27274..2ae803947c 100644 --- a/utils/indigo-service/backend/service/tests/api/indigo_test.py +++ b/utils/indigo-service/backend/service/tests/api/indigo_test.py @@ -3229,9 +3229,11 @@ def test_convert_sequences(self): headers, data = self.get_headers( { "struct": "ACGTU", - "options": {"monomerLibrary": monomer_library}, + "options": { + "monomerLibrary": monomer_library, + "sequence-type": "RNA", + }, "output_format": "chemical/x-indigo-ket", - "sequence-type": "RNA", } ) result_rna_ad = requests.post( @@ -3269,9 +3271,11 @@ def test_convert_sequences(self): headers, data = self.get_headers( { "struct": "ACGTU", - "options": {"monomerLibrary": monomer_library}, + "options": { + "monomerLibrary": monomer_library, + "sequence-type": "DNA", + }, "output_format": "chemical/x-indigo-ket", - "sequence-type": "DNA", } ) result_dna_ad = requests.post( @@ -3308,9 +3312,11 @@ def test_convert_sequences(self): headers, data = self.get_headers( { "struct": "ACGTU", - "options": {"monomerLibrary": monomer_library}, + "options": { + "monomerLibrary": monomer_library, + "sequence-type": "PEPTIDE", + }, "output_format": "chemical/x-indigo-ket", - "sequence-type": "PEPTIDE", } ) result_peptide_ad = requests.post( @@ -3334,9 +3340,11 @@ def test_convert_sequences(self): headers, data = self.get_headers( { "struct": peptide_3, - "options": {"monomerLibrary": monomer_library}, + "options": { + "monomerLibrary": monomer_library, + "sequence-type": "PEPTIDE", + }, "output_format": "chemical/x-indigo-ket", - "sequence-type": "PEPTIDE", } ) result_ket_3_ad = requests.post( From 44a4282b09cb9a9ce92ab22a1d33879d8d941a2c Mon Sep 17 00:00:00 2001 From: Aliakasndr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Fri, 7 Mar 2025 16:20:49 +0300 Subject: [PATCH 7/9] fix UTs --- api/wasm/indigo-ketcher/test/test.js | 16 ++-- .../reaction/src/query_reaction.cpp | 2 +- .../backend/service/tests/api/indigo_test.py | 82 ++++++++++--------- 3 files changed, 51 insertions(+), 49 deletions(-) diff --git a/api/wasm/indigo-ketcher/test/test.js b/api/wasm/indigo-ketcher/test/test.js index 0ce1cb5680..443ccbb158 100644 --- a/api/wasm/indigo-ketcher/test/test.js +++ b/api/wasm/indigo-ketcher/test/test.js @@ -873,11 +873,11 @@ M END let ad_options = new indigo.MapStringString(); ad_options.set("output-content-type", "application/json"); ad_options.set("monomerLibrary", monomersLib); - const res2 = JSON.parse(indigo.convert(peptide_seq_ref, "ket", options)).struct; - assert.equal(res2, peptide_ket_ref.toString()); + const res2 = JSON.parse(indigo.convert(peptide_seq_ref, "peptide-sequence-3-letter", ad_options)).struct; + assert.equal(res2, peptide_seq_ref); ad_options.set("sequence-type", "PEPTIDE"); - const res3 = JSON.parse(indigo.convert(peptide_seq_ref, "ket", options)).struct; - assert.equal(res3, peptide_ket_ref.toString()); + const res3 = JSON.parse(indigo.convert(peptide_seq_ref, "peptide-sequence-3-letter", ad_options)).struct; + assert.equal(res3, peptide_seq_ref); ad_options.delete(); }); } @@ -906,8 +906,8 @@ M END ad_options.set("output-content-type", "application/json"); ad_options.set("monomerLibrary", monomersLib); ad_options.set("sequence-type", "RNA"); - const res2 = indigo.convert(rna_seq_ref, "ket", ad_options); - assert.equal(res2, rna_ket_ref.toString()); + const res2 = indigo.convert(rna_seq_ref, "sequence", ad_options); + assert.equal(res2, rna_seq_ref1.toString()); ad_options.delete(); }); @@ -937,8 +937,8 @@ M END ad_options.set("output-content-type", "application/json"); ad_options.set("monomerLibrary", monomersLib); ad_options.set("sequence-type", "DNA"); - const res2 = indigo.convert(dna_seq_ref, "ket", ad_options); - assert.equal(res2, dna_ket_ref.toString()); + const res2 = indigo.convert(dna_seq_ref, "sequence", ad_options); + assert.equal(res2, dna_seq_ref1.toString()); ad_options.delete(); }); diff --git a/core/indigo-core/reaction/src/query_reaction.cpp b/core/indigo-core/reaction/src/query_reaction.cpp index d4d6e7fb81..df9bc4287e 100644 --- a/core/indigo-core/reaction/src/query_reaction.cpp +++ b/core/indigo-core/reaction/src/query_reaction.cpp @@ -182,7 +182,7 @@ int QueryReaction::_addBaseMolecule(int side) std::unique_ptr QueryReaction::getBaseReaction(int index) { - std::unique_ptr query_reaction; + std::unique_ptr query_reaction(neu()); query_reaction->clone(*this); return query_reaction; } 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 2ae803947c..f526d84a95 100644 --- a/utils/indigo-service/backend/service/tests/api/indigo_test.py +++ b/utils/indigo-service/backend/service/tests/api/indigo_test.py @@ -3213,9 +3213,11 @@ def test_convert_sequences(self): with open(lib_path, "r") as file: monomer_library = file.read() + monomer_struct = "ACGTU" + headers, data = self.get_headers( { - "struct": "ACGTU", + "struct": monomer_struct, "options": {"monomerLibrary": monomer_library}, "input_format": "chemical/x-rna-sequence", "output_format": "chemical/x-indigo-ket", @@ -3225,6 +3227,21 @@ def test_convert_sequences(self): self.url_prefix + "/convert", headers=headers, data=data ) + headers, data = self.get_headers( + { + "struct": monomer_struct, + "options": {"monomerLibrary": monomer_library}, + "input_format": "chemical/x-rna-sequence", + "output_format": "chemical/x-sequence", + } + ) + + result_rna_1 = requests.post( + self.url_prefix + "/convert", headers=headers, data=data + ) + + self.assertEqual(json.loads(result_rna_1.text)["struct"], monomer_struct) + # test autodetect RNA headers, data = self.get_headers( { @@ -3233,72 +3250,59 @@ def test_convert_sequences(self): "monomerLibrary": monomer_library, "sequence-type": "RNA", }, - "output_format": "chemical/x-indigo-ket", + "output_format": "chemical/x-sequence", } ) result_rna_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) + self.assertEqual(json.loads(result_rna_ad.text)["struct"], monomer_struct) headers, data = self.get_headers( { - "struct": "ACGTU", + "struct": monomer_struct, "options": {"monomerLibrary": monomer_library}, - "input_format": "chemical/x-rna-sequence", - "output_format": "chemical/x-sequence", + "input_format": "chemical/x-dna-sequence", + "output_format": "chemical/x-indigo-ket", } ) - - result_rna_1 = requests.post( + result_dna = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_rna_1.text)["struct"], "ACGTU") - headers, data = self.get_headers( { - "struct": "ACGTU", + "struct": monomer_struct, "options": {"monomerLibrary": monomer_library}, "input_format": "chemical/x-dna-sequence", - "output_format": "chemical/x-indigo-ket", + "output_format": "chemical/x-sequence", } ) - result_dna = requests.post( + result_dna_1 = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) + self.assertEqual(json.loads(result_dna_1.text)["struct"], monomer_struct) + # test autodetect DNA headers, data = self.get_headers( { - "struct": "ACGTU", + "struct": monomer_struct, "options": { "monomerLibrary": monomer_library, "sequence-type": "DNA", }, - "output_format": "chemical/x-indigo-ket", - } - ) - result_dna_ad = requests.post( - self.url_prefix + "/convert", headers=headers, data=data - ) - - headers, data = self.get_headers( - { - "struct": "ACGTU", - "options": {"monomerLibrary": monomer_library}, - "input_format": "chemical/x-dna-sequence", "output_format": "chemical/x-sequence", } ) - result_dna_1 = requests.post( + result_dna_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) - - self.assertEqual(json.loads(result_dna_1.text)["struct"], "ACGTU") + self.assertEqual(json.loads(result_dna_ad.text)["struct"], monomer_struct) headers, data = self.get_headers( { - "struct": "ACGTU", + "struct": monomer_struct, "options": {"monomerLibrary": monomer_library}, "input_format": "chemical/x-peptide-sequence", "output_format": "chemical/x-indigo-ket", @@ -3311,17 +3315,18 @@ def test_convert_sequences(self): # test autodetect PEPTIDE headers, data = self.get_headers( { - "struct": "ACGTU", + "struct": monomer_struct, "options": { "monomerLibrary": monomer_library, "sequence-type": "PEPTIDE", }, - "output_format": "chemical/x-indigo-ket", + "output_format": "chemical/x-sequence", } ) result_peptide_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) + self.assertEqual(json.loads(result_peptide_ad.text)["struct"], monomer_struct) peptide_3 = "AlaCysGlyThrSec" headers, data = self.get_headers( @@ -3344,23 +3349,25 @@ def test_convert_sequences(self): "monomerLibrary": monomer_library, "sequence-type": "PEPTIDE", }, - "output_format": "chemical/x-indigo-ket", + "output_format": "chemical/x-sequence", } ) - result_ket_3_ad = requests.post( + result_peptide_3_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) + self.assertEqual(json.loads(result_peptide_3_ad.text)["struct"], monomer_struct) headers, data = self.get_headers( { "struct": peptide_3, "options": {"monomerLibrary": monomer_library}, - "output_format": "chemical/x-indigo-ket", + "output_format": "chemical/x-sequence", } ) - result_ket_3_ad_no_type = requests.post( + result_peptide_3_ad_no_type = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) + self.assertEqual(json.loads(result_peptide_3_ad_no_type.text)["struct"], monomer_struct) headers, data = self.get_headers( { @@ -3405,20 +3412,15 @@ def test_convert_sequences(self): with open(os.path.join(ref_path, "rna_ref") + ".ket", "r") as file: rna_ref = file.read() self.assertEqual(result_rna.text, rna_ref) - self.assertEqual(result_rna_ad.text, rna_ref) with open(os.path.join(ref_path, "dna_ref") + ".ket", "r") as file: dna_ref = file.read() self.assertEqual(result_dna.text, dna_ref) - self.assertEqual(result_dna_ad.text, dna_ref) with open(os.path.join(ref_path, "peptide_ref") + ".ket", "r") as file: peptide_ref = file.read() self.assertEqual(result_peptide.text, peptide_ref) - self.assertEqual(result_peptide_ad.text, peptide_ref) self.assertEqual(result_ket_3.text, peptide_ref) - self.assertEqual(result_ket_3_ad.text, peptide_ref) - self.assertEqual(result_ket_3_ad_no_type.text, peptide_ref) def test_convert_fasta(self): ref_path = joinPathPy("ref/", __file__) From f31bb3897939b2b474bc2b14c3c8d351251fa273 Mon Sep 17 00:00:00 2001 From: Aliakasndr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Fri, 7 Mar 2025 16:22:39 +0300 Subject: [PATCH 8/9] fix typo --- .../backend/service/tests/api/indigo_test.py | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) 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 f526d84a95..e1a30d50cd 100644 --- a/utils/indigo-service/backend/service/tests/api/indigo_test.py +++ b/utils/indigo-service/backend/service/tests/api/indigo_test.py @@ -3240,7 +3240,9 @@ def test_convert_sequences(self): self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_rna_1.text)["struct"], monomer_struct) + self.assertEqual( + json.loads(result_rna_1.text)["struct"], monomer_struct + ) # test autodetect RNA headers, data = self.get_headers( @@ -3256,7 +3258,9 @@ def test_convert_sequences(self): result_rna_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_rna_ad.text)["struct"], monomer_struct) + self.assertEqual( + json.loads(result_rna_ad.text)["struct"], monomer_struct + ) headers, data = self.get_headers( { @@ -3282,7 +3286,9 @@ def test_convert_sequences(self): self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_dna_1.text)["struct"], monomer_struct) + self.assertEqual( + json.loads(result_dna_1.text)["struct"], monomer_struct + ) # test autodetect DNA headers, data = self.get_headers( @@ -3298,7 +3304,9 @@ def test_convert_sequences(self): result_dna_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_dna_ad.text)["struct"], monomer_struct) + self.assertEqual( + json.loads(result_dna_ad.text)["struct"], monomer_struct + ) headers, data = self.get_headers( { @@ -3326,7 +3334,9 @@ def test_convert_sequences(self): result_peptide_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_peptide_ad.text)["struct"], monomer_struct) + self.assertEqual( + json.loads(result_peptide_ad.text)["struct"], monomer_struct + ) peptide_3 = "AlaCysGlyThrSec" headers, data = self.get_headers( @@ -3355,7 +3365,9 @@ def test_convert_sequences(self): result_peptide_3_ad = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_peptide_3_ad.text)["struct"], monomer_struct) + self.assertEqual( + json.loads(result_peptide_3_ad.text)["struct"], monomer_struct + ) headers, data = self.get_headers( { @@ -3367,7 +3379,10 @@ def test_convert_sequences(self): result_peptide_3_ad_no_type = requests.post( self.url_prefix + "/convert", headers=headers, data=data ) - self.assertEqual(json.loads(result_peptide_3_ad_no_type.text)["struct"], monomer_struct) + self.assertEqual( + json.loads(result_peptide_3_ad_no_type.text)["struct"], + monomer_struct, + ) headers, data = self.get_headers( { From 78f95f43ca841f79088a6e6426f442504a59b02e Mon Sep 17 00:00:00 2001 From: Aliakasndr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Fri, 7 Mar 2025 17:14:07 +0300 Subject: [PATCH 9/9] update actions cache to v4 (#2776) --- .github/workflows/indigo-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/indigo-ci.yaml b/.github/workflows/indigo-ci.yaml index af3c6f312e..9eb365e23a 100644 --- a/.github/workflows/indigo-ci.yaml +++ b/.github/workflows/indigo-ci.yaml @@ -738,7 +738,7 @@ jobs: with: java-version: ${{ matrix.java-version }} - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}