diff --git a/api/tests/integration/tests/formats/helm_to_ket.py b/api/tests/integration/tests/formats/helm_to_ket.py index 119aa201a2..075e1e24c3 100644 --- a/api/tests/integration/tests/formats/helm_to_ket.py +++ b/api/tests/integration/tests/formats/helm_to_ket.py @@ -37,8 +37,8 @@ def find_diff(a, b): "helm_chem_rna": "CHEM1{[MCC]}|RNA1{R(U)P}$CHEM1,RNA1,1:R1-3:R2$$$V2.0", "helm_rna_without_base": "RNA1{RP}$$$$V2.0", "helm_mixed_base": "RNA1{[dR](A)P.[dR](A+G)P.[dR](A)P.[dR](G+C)}$$$$V2.0", - "helm_mixed_custom": "RNA1{[dR](A:10+C:20+G:30+T:50)P.[dR](A:10+C:20+G:30+T:50)P.[dR](A+C+G+T)}$$$$V2.0", - "aminoacids_variants": "PEPTIDE1{(D+N).(L+I).(E+Q).(A+C+D+E+F+G+H+I+K+L+M+N+O+P+Q+R+S+T+U+V+W+Y)}$$$$V2.0", + "helm_mixed_custom": "RNA1{[dR](A:10+[Xan]:20+G:30+T:50)P.[dR](A:10+C:20+G:30+T:50)P.[dR](A+C+G+T)}$$$$V2.0", + "aminoacids_variants": "PEPTIDE1{([Dha]+N).(L+I).(E+Q).(A+C+D+E+F+G+H+I+K+L+M+N+O+P+Q+R+S+T+U+V+W+Y)}$$$$V2.0", "helm_smiles": "PEPTIDE1{G.[[*]N[C@@H](C=O)C([*])=O |$_R1;;;;;;_R2;$|].C}|PEPTIDE2{G.[[*:1]N[C@@H](C=O)C([*:2])=O].C}$$$$", "helm_smiles_sugar": "RNA1{[C([*:3])[C@@H](O[*:2])CO[*:1]](A)P}$$$$V2.0", "helm_no_left_ap": "PEPTIDE1{[DACys].C}$$$$V2.0", diff --git a/api/tests/integration/tests/formats/ket_to_helm.py b/api/tests/integration/tests/formats/ket_to_helm.py index 0c28c1490e..ad3ee95e62 100644 --- a/api/tests/integration/tests/formats/ket_to_helm.py +++ b/api/tests/integration/tests/formats/ket_to_helm.py @@ -43,8 +43,8 @@ def find_diff(a, b): "helm_rna_without_base": "RNA1{RP}$$$$V2.0", "helm_cycled_polymer": "PEPTIDE1{A.C.D.E.F}$PEPTIDE1,PEPTIDE1,5:R2-1:R1$$$V2.0", "helm_mixed_base": "RNA1{[dR](A)P.[dR](A+G)P.[dR](A)P.[dR](G+C)}$$$$V2.0", - "helm_mixed_custom": "RNA1{[dR](A:10+C:20+G:30+T:50)P.[dR](A:10+C:20+G:30+T:50)P.[dR](A+C+G+T)}$$$$V2.0", - "aminoacids_variants": "PEPTIDE1{(D+N).(L+I).(E+Q).(A+C+D+E+F+G+H+I+K+L+M+N+O+P+Q+R+S+T+U+V+W+Y)}$$$$V2.0", + "helm_mixed_custom": "RNA1{[dR](A:10+[Xan]:20+G:30+T:50)P.[dR](A:10+C:20+G:30+T:50)P.[dR](A+C+G+T)}$$$$V2.0", + "aminoacids_variants": "PEPTIDE1{([Dha]+N).(L+I).(E+Q).(A+C+D+E+F+G+H+I+K+L+M+N+O+P+Q+R+S+T+U+V+W+Y)}$$$$V2.0", "dna_variants": "RNA1{[dR](C+G+T)P.[dR](A+C+G+T)}$$$$V2.0", "rna_variants": "RNA1{R(G+T)P.R(A+C+G+T)}$$$$V2.0", "helm_monomer_molecule": "PEPTIDE1{A}|PEPTIDE2{G}|CHEM1{[C(N[*:2])=C[*:1] |$;;_R2;;_R1$|]}$CHEM1,PEPTIDE1,1:R2-1:R1$$$V2.0", diff --git a/api/tests/integration/tests/formats/ref/aminoacids_variants.ket b/api/tests/integration/tests/formats/ref/aminoacids_variants.ket index f9e8cc0291..d7a5498489 100644 --- a/api/tests/integration/tests/formats/ref/aminoacids_variants.ket +++ b/api/tests/integration/tests/formats/ref/aminoacids_variants.ket @@ -51,7 +51,7 @@ ], "templates": [ { - "$ref": "monomerTemplate-D___Aspartic acid" + "$ref": "monomerTemplate-Dha___2-aminoprop-2-enoic acid" }, { "$ref": "monomerTemplate-N___Asparagine" @@ -74,6 +74,9 @@ { "$ref": "monomerTemplate-C___Cysteine" }, + { + "$ref": "monomerTemplate-D___Aspartic acid" + }, { "$ref": "monomerTemplate-F___Phenylalanine" }, @@ -117,7 +120,7 @@ "$ref": "monomerTemplate-Y___Tyrosine" }, { - "$ref": "ambiguousMonomerTemplate-B" + "$ref": "ambiguousMonomerTemplate-Var0" }, { "$ref": "ambiguousMonomerTemplate-J" @@ -138,8 +141,8 @@ "y": -0.000000 }, "seqid": 1, - "alias": "B", - "templateId": "B" + "alias": "Var0", + "templateId": "Var0" }, "ambiguousMonomer-1": { "type": "ambiguousMonomer", @@ -174,39 +177,30 @@ "alias": "X", "templateId": "X" }, - "monomerTemplate-D___Aspartic acid": { + "monomerTemplate-Dha___2-aminoprop-2-enoic acid": { "type": "monomerTemplate", - "id": "D___Aspartic acid", + "id": "Dha___2-aminoprop-2-enoic acid", "class": "AminoAcid", "classHELM": "PEPTIDE", - "fullName": "Aspartic acid", - "alias": "D", - "naturalAnalogShort": "D", + "fullName": "2-aminoprop-2-enoic acid", + "alias": "Dha", + "naturalAnalogShort": "A", "attachmentPoints": [ { - "attachmentAtom": 3, + "attachmentAtom": 2, "type": "left", "leavingGroup": { "atoms": [ - 4 + 3 ] } }, { - "attachmentAtom": 0, + "attachmentAtom": 4, "type": "right", "leavingGroup": { "atoms": [ - 9 - ] - } - }, - { - "attachmentAtom": 8, - "type": "side", - "leavingGroup": { - "atoms": [ - 10 + 5 ] } } @@ -215,105 +209,72 @@ { "label": "C", "location": [ - 1.631000, - -1.557800, - 0.000000 - ] - }, - { - "label": "O", - "location": [ - 1.632700, - -2.739200, + 2.600000, + -1.500000, 0.000000 ] }, { "label": "C", "location": [ - 0.350700, - -0.820100, + 2.600000, + 0.000000, 0.000000 - ], - "stereoLabel": "abs" + ] }, { "label": "N", "location": [ - -0.929500, - -1.557800, + 1.300000, + 0.750000, 0.000000 ] }, { "label": "H", "location": [ - -1.952500, - -0.966900, + 0.000700, + 0.000400, 0.000000 ] }, { "label": "C", "location": [ - 0.348500, - 0.657500, - 0.000000 - ] - }, - { - "label": "C", - "location": [ - -0.931700, - 1.395200, + 3.900000, + 0.750000, 0.000000 ] }, { "label": "O", "location": [ - -1.954200, - 0.803200, + 3.900000, + 2.250000, 0.000000 ] }, { "label": "O", "location": [ - -0.933500, - 2.576600, - 0.000000 - ] - }, - { - "label": "O", - "location": [ - 2.653400, - -0.965800, - 0.000000 - ] - }, - { - "label": "H", - "location": [ - 0.085100, - 3.175100, + 5.199200, + 0.000400, 0.000000 ] } ], "bonds": [ { - "type": 2, + "type": 1, "atoms": [ - 1, - 0 + 0, + 1 ] }, { - "type": 1, + "type": 2, "atoms": [ - 0, + 1, 2 ] }, @@ -327,51 +288,22 @@ { "type": 1, "atoms": [ - 3, + 1, 4 ] }, { "type": 1, "atoms": [ - 2, + 4, 5 - ], - "stereo": 1 - }, - { - "type": 1, - "atoms": [ - 5, - 6 ] }, { "type": 2, "atoms": [ - 6, - 7 - ] - }, - { - "type": 1, - "atoms": [ - 6, - 8 - ] - }, - { - "type": 1, - "atoms": [ - 0, - 9 - ] - }, - { - "type": 1, - "atoms": [ - 8, - 10 + 4, + 6 ] } ] @@ -1675,6 +1607,208 @@ } ] }, + "monomerTemplate-D___Aspartic acid": { + "type": "monomerTemplate", + "id": "D___Aspartic acid", + "class": "AminoAcid", + "classHELM": "PEPTIDE", + "fullName": "Aspartic acid", + "alias": "D", + "naturalAnalogShort": "D", + "attachmentPoints": [ + { + "attachmentAtom": 3, + "type": "left", + "leavingGroup": { + "atoms": [ + 4 + ] + } + }, + { + "attachmentAtom": 0, + "type": "right", + "leavingGroup": { + "atoms": [ + 9 + ] + } + }, + { + "attachmentAtom": 8, + "type": "side", + "leavingGroup": { + "atoms": [ + 10 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 1.631000, + -1.557800, + 0.000000 + ] + }, + { + "label": "O", + "location": [ + 1.632700, + -2.739200, + 0.000000 + ] + }, + { + "label": "C", + "location": [ + 0.350700, + -0.820100, + 0.000000 + ], + "stereoLabel": "abs" + }, + { + "label": "N", + "location": [ + -0.929500, + -1.557800, + 0.000000 + ] + }, + { + "label": "H", + "location": [ + -1.952500, + -0.966900, + 0.000000 + ] + }, + { + "label": "C", + "location": [ + 0.348500, + 0.657500, + 0.000000 + ] + }, + { + "label": "C", + "location": [ + -0.931700, + 1.395200, + 0.000000 + ] + }, + { + "label": "O", + "location": [ + -1.954200, + 0.803200, + 0.000000 + ] + }, + { + "label": "O", + "location": [ + -0.933500, + 2.576600, + 0.000000 + ] + }, + { + "label": "O", + "location": [ + 2.653400, + -0.965800, + 0.000000 + ] + }, + { + "label": "H", + "location": [ + 0.085100, + 3.175100, + 0.000000 + ] + } + ], + "bonds": [ + { + "type": 2, + "atoms": [ + 1, + 0 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 5 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 5, + 6 + ] + }, + { + "type": 2, + "atoms": [ + 6, + 7 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 8 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 9 + ] + }, + { + "type": 1, + "atoms": [ + 8, + 10 + ] + } + ] + }, "monomerTemplate-F___Phenylalanine": { "type": "monomerTemplate", "id": "F___Phenylalanine", @@ -4665,14 +4799,14 @@ } ] }, - "ambiguousMonomerTemplate-B": { + "ambiguousMonomerTemplate-Var0": { "type": "ambiguousMonomerTemplate", "subtype": "mixture", - "id": "B", - "alias": "B", + "id": "Var0", + "alias": "Var0", "options": [ { - "templateId": "D___Aspartic acid" + "templateId": "Dha___2-aminoprop-2-enoic acid" }, { "templateId": "N___Asparagine" diff --git a/api/tests/integration/tests/formats/ref/helm_mixed_custom.ket b/api/tests/integration/tests/formats/ref/helm_mixed_custom.ket index 94198258cd..5ad62ea826 100644 --- a/api/tests/integration/tests/formats/ref/helm_mixed_custom.ket +++ b/api/tests/integration/tests/formats/ref/helm_mixed_custom.ket @@ -113,7 +113,7 @@ "$ref": "monomerTemplate-A___Adenine" }, { - "$ref": "monomerTemplate-C___Cytosine" + "$ref": "monomerTemplate-Xan___Xanthine" }, { "$ref": "monomerTemplate-G___Guanine" @@ -125,7 +125,13 @@ "$ref": "monomerTemplate-P___Phosphate" }, { - "$ref": "ambiguousMonomerTemplate-N0" + "$ref": "monomerTemplate-C___Cytosine" + }, + { + "$ref": "ambiguousMonomerTemplate-Var0" + }, + { + "$ref": "ambiguousMonomerTemplate-N1" }, { "$ref": "ambiguousMonomerTemplate-N" @@ -151,8 +157,8 @@ "y": -1.600000 }, "seqid": 2, - "alias": "N0", - "templateId": "N0" + "alias": "Var0", + "templateId": "Var0" }, "monomer2": { "type": "monomer", @@ -184,8 +190,8 @@ "y": -1.600000 }, "seqid": 5, - "alias": "N0", - "templateId": "N0" + "alias": "N1", + "templateId": "N1" }, "monomer5": { "type": "monomer", @@ -629,21 +635,21 @@ } ] }, - "monomerTemplate-C___Cytosine": { + "monomerTemplate-Xan___Xanthine": { "type": "monomerTemplate", - "id": "C___Cytosine", + "id": "Xan___Xanthine", "class": "Base", "classHELM": "RNA", - "fullName": "Cytosine", - "alias": "C", - "naturalAnalogShort": "C", + "fullName": "Xanthine", + "alias": "Xan", + "naturalAnalogShort": "X", "attachmentPoints": [ { - "attachmentAtom": 3, + "attachmentAtom": 6, "type": "left", "leavingGroup": { "atoms": [ - 8 + 9 ] } } @@ -652,72 +658,96 @@ { "label": "C", "location": [ - 1.861700, - 1.349900, + 1.299000, + -0.750000, + 0.000000 + ] + }, + { + "label": "N", + "location": [ + 1.299000, + 0.750000, 0.000000 ] }, { "label": "C", "location": [ - 1.111700, - 2.648900, + 0.000000, + 1.500000, 0.000000 ] }, { "label": "C", "location": [ - -0.388200, - 2.649000, + 0.000000, + -1.500000, + 0.000000 + ] + }, + { + "label": "C", + "location": [ + -1.299000, + -0.750000, 0.000000 ] }, { "label": "N", "location": [ - -1.138200, - 1.350000, + -1.299000, + 0.750000, + 0.000000 + ] + }, + { + "label": "N", + "location": [ + -2.413300, + -1.753000, 0.000000 ] }, { "label": "C", "location": [ - -0.388300, - 0.050900, + -1.803200, + -3.123300, 0.000000 ] }, { "label": "N", "location": [ - 1.111700, - 0.050900, + -0.311400, + -2.966500, 0.000000 ] }, { - "label": "N", + "label": "H", "location": [ - 3.061800, - 1.349900, + -3.880500, + -1.441000, 0.000000 ] }, { "label": "O", "location": [ - -0.988400, - -0.988300, + 0.000000, + 3.000000, 0.000000 ] }, { - "label": "H", + "label": "O", "location": [ - -2.338300, - 1.350000, + 2.598100, + -1.500000, 0.000000 ] } @@ -731,59 +761,87 @@ ] }, { - "type": 2, + "type": 1, "atoms": [ - 0, - 5 + 1, + 2 ] }, { "type": 1, "atoms": [ 0, - 6 + 3 ] }, { "type": 2, "atoms": [ - 1, - 2 + 3, + 4 ] }, { "type": 1, "atoms": [ - 2, - 3 + 4, + 5 ] }, { "type": 1, "atoms": [ - 3, - 4 + 5, + 2 ] }, { "type": 1, "atoms": [ - 3, + 4, + 6 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 7 + ] + }, + { + "type": 2, + "atoms": [ + 7, 8 ] }, { "type": 1, "atoms": [ - 4, - 5 + 8, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 9 ] }, { "type": 2, "atoms": [ - 4, - 7 + 2, + 10 + ] + }, + { + "type": 2, + "atoms": [ + 0, + 11 ] } ] @@ -1274,11 +1332,194 @@ } ] }, - "ambiguousMonomerTemplate-N0": { + "monomerTemplate-C___Cytosine": { + "type": "monomerTemplate", + "id": "C___Cytosine", + "class": "Base", + "classHELM": "RNA", + "fullName": "Cytosine", + "alias": "C", + "naturalAnalogShort": "C", + "attachmentPoints": [ + { + "attachmentAtom": 3, + "type": "left", + "leavingGroup": { + "atoms": [ + 8 + ] + } + } + ], + "atoms": [ + { + "label": "C", + "location": [ + 1.861700, + 1.349900, + 0.000000 + ] + }, + { + "label": "C", + "location": [ + 1.111700, + 2.648900, + 0.000000 + ] + }, + { + "label": "C", + "location": [ + -0.388200, + 2.649000, + 0.000000 + ] + }, + { + "label": "N", + "location": [ + -1.138200, + 1.350000, + 0.000000 + ] + }, + { + "label": "C", + "location": [ + -0.388300, + 0.050900, + 0.000000 + ] + }, + { + "label": "N", + "location": [ + 1.111700, + 0.050900, + 0.000000 + ] + }, + { + "label": "N", + "location": [ + 3.061800, + 1.349900, + 0.000000 + ] + }, + { + "label": "O", + "location": [ + -0.988400, + -0.988300, + 0.000000 + ] + }, + { + "label": "H", + "location": [ + -2.338300, + 1.350000, + 0.000000 + ] + } + ], + "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 + ] + } + ] + }, + "ambiguousMonomerTemplate-Var0": { + "type": "ambiguousMonomerTemplate", + "subtype": "mixture", + "id": "Var0", + "alias": "Var0", + "options": [ + { + "templateId": "A___Adenine", + "ratio": 10.000000 + }, + { + "templateId": "Xan___Xanthine", + "ratio": 20.000000 + }, + { + "templateId": "G___Guanine", + "ratio": 30.000000 + }, + { + "templateId": "T___Thymine", + "ratio": 50.000000 + } + ] + }, + "ambiguousMonomerTemplate-N1": { "type": "ambiguousMonomerTemplate", "subtype": "mixture", - "id": "N0", - "alias": "N0", + "id": "N1", + "alias": "N1", "options": [ { "templateId": "A___Adenine", diff --git a/core/indigo-core/molecule/src/sequence_saver.cpp b/core/indigo-core/molecule/src/sequence_saver.cpp index 15df4d0264..effe901244 100644 --- a/core/indigo-core/molecule/src/sequence_saver.cpp +++ b/core/indigo-core/molecule/src/sequence_saver.cpp @@ -1148,7 +1148,12 @@ std::string SequenceSaver::saveHELM(KetDocument& document, std::vector 0) variants += mixture ? '+' : ','; - variants += templates.at(option.templateId()).getStringProp("alias"); + auto alias = templates.at(option.templateId()).getStringProp("alias"); + if (alias.size() > 1) + variants += '['; + variants += alias; + if (alias.size() > 1) + variants += ']'; auto num = mixture ? option.ratio() : option.probability(); if (num.has_value()) {