diff --git a/api/tests/integration/tests/formats/ref/anacyclamide.ket b/api/tests/integration/tests/formats/ref/anacyclamide.ket index 77fa36cc93..841cffcb2e 100644 --- a/api/tests/integration/tests/formats/ref/anacyclamide.ket +++ b/api/tests/integration/tests/formats/ref/anacyclamide.ket @@ -288,6 +288,7 @@ "classHELM": "PEPTIDE", "alias": "Q", "name": "Gln", + "naturalAnalogShort": "Q", "attachmentPoints": [ { "attachmentAtom": 0, @@ -501,6 +502,7 @@ "classHELM": "PEPTIDE", "alias": "S", "name": "Ser", + "naturalAnalogShort": "S", "attachmentPoints": [ { "attachmentAtom": 0, @@ -669,6 +671,7 @@ "classHELM": "PEPTIDE", "alias": "T", "name": "Thr", + "naturalAnalogShort": "T", "attachmentPoints": [ { "attachmentAtom": 0, @@ -854,6 +857,7 @@ "classHELM": "PEPTIDE", "alias": "P", "name": "Pro", + "naturalAnalogShort": "P", "attachmentPoints": [ { "attachmentAtom": 7, @@ -1021,6 +1025,7 @@ "classHELM": "PEPTIDE", "alias": "V", "name": "Val", + "naturalAnalogShort": "V", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1181,6 +1186,7 @@ "classHELM": "PEPTIDE", "alias": "G", "name": "Gly", + "naturalAnalogShort": "G", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1294,6 +1300,7 @@ "classHELM": "PEPTIDE", "alias": "W", "name": "Trp", + "naturalAnalogShort": "W", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1596,6 +1603,7 @@ "classHELM": "PEPTIDE", "alias": "I", "name": "Ile", + "naturalAnalogShort": "I", "attachmentPoints": [ { "attachmentAtom": 0, diff --git a/api/tests/integration/tests/formats/ref/apamine.ket b/api/tests/integration/tests/formats/ref/apamine.ket index 8c7b51e412..8d4b8f551f 100644 --- a/api/tests/integration/tests/formats/ref/apamine.ket +++ b/api/tests/integration/tests/formats/ref/apamine.ket @@ -590,6 +590,7 @@ "classHELM": "PEPTIDE", "alias": "H", "name": "His", + "naturalAnalogShort": "H", "attachmentPoints": [ { "attachmentAtom": 5, @@ -825,6 +826,7 @@ "classHELM": "PEPTIDE", "alias": "Q", "name": "Gln", + "naturalAnalogShort": "Q", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1038,6 +1040,7 @@ "classHELM": "PEPTIDE", "alias": "R", "name": "Arg", + "naturalAnalogShort": "R", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1281,6 +1284,7 @@ "classHELM": "PEPTIDE", "alias": "A", "name": "Ala", + "naturalAnalogShort": "A", "attachmentPoints": [ { "attachmentAtom": 2, @@ -1411,6 +1415,7 @@ "classHELM": "PEPTIDE", "alias": "L", "name": "Leu", + "naturalAnalogShort": "L", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1586,6 +1591,7 @@ "classHELM": "PEPTIDE", "alias": "T", "name": "Thr", + "naturalAnalogShort": "T", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1771,6 +1777,7 @@ "classHELM": "PEPTIDE", "alias": "E", "name": "Glu", + "naturalAnalogShort": "E", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1984,6 +1991,7 @@ "classHELM": "PEPTIDE", "alias": "P", "name": "Pro", + "naturalAnalogShort": "P", "attachmentPoints": [ { "attachmentAtom": 7, @@ -2151,6 +2159,7 @@ "classHELM": "PEPTIDE", "alias": "K", "name": "Lys", + "naturalAnalogShort": "K", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2364,6 +2373,7 @@ "classHELM": "PEPTIDE", "alias": "N", "name": "Asn", + "naturalAnalogShort": "N", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2562,6 +2572,7 @@ "classHELM": "PEPTIDE", "alias": "C", "name": "C", + "naturalAnalogShort": "C", "attachmentPoints": [ { "attachmentAtom": 4 @@ -2670,6 +2681,7 @@ "classHELM": "PEPTIDE", "alias": "C", "name": "C", + "naturalAnalogShort": "C", "attachmentPoints": [ { "attachmentAtom": 4 @@ -2778,6 +2790,7 @@ "classHELM": "PEPTIDE", "alias": "C", "name": "C", + "naturalAnalogShort": "C", "attachmentPoints": [ { "attachmentAtom": 4 @@ -2886,6 +2899,7 @@ "classHELM": "PEPTIDE", "alias": "C", "name": "C", + "naturalAnalogShort": "C", "attachmentPoints": [ { "attachmentAtom": 4 diff --git a/api/tests/integration/tests/formats/ref/conjugate.ket b/api/tests/integration/tests/formats/ref/conjugate.ket index f900f1976a..f1cb0262bf 100644 --- a/api/tests/integration/tests/formats/ref/conjugate.ket +++ b/api/tests/integration/tests/formats/ref/conjugate.ket @@ -2231,6 +2231,7 @@ "classHELM": "PEPTIDE", "alias": "D", "name": "Asp", + "naturalAnalogShort": "D", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2429,6 +2430,7 @@ "classHELM": "PEPTIDE", "alias": "F", "name": "Phe", + "naturalAnalogShort": "F", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2656,6 +2658,7 @@ "classHELM": "PEPTIDE", "alias": "G", "name": "Gly", + "naturalAnalogShort": "G", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2769,6 +2772,7 @@ "classHELM": "PEPTIDE", "alias": "H", "name": "His", + "naturalAnalogShort": "H", "attachmentPoints": [ { "attachmentAtom": 5, @@ -3004,6 +3008,7 @@ "classHELM": "PEPTIDE", "alias": "I", "name": "Ile", + "naturalAnalogShort": "I", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3181,6 +3186,7 @@ "classHELM": "PEPTIDE", "alias": "K", "name": "Lys", + "naturalAnalogShort": "K", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3562,6 +3568,7 @@ "classHELM": "PEPTIDE", "alias": "V", "name": "Val", + "naturalAnalogShort": "V", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3722,6 +3729,7 @@ "classHELM": "PEPTIDE", "alias": "E", "name": "Glu", + "naturalAnalogShort": "E", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3935,6 +3943,7 @@ "classHELM": "PEPTIDE", "alias": "C", "name": "Cys", + "naturalAnalogShort": "C", "attachmentPoints": [ { "attachmentAtom": 8, @@ -4370,6 +4379,7 @@ "classHELM": "PEPTIDE", "alias": "E", "name": "E", + "naturalAnalogShort": "E", "attachmentPoints": [ { "attachmentAtom": 0 diff --git a/api/tests/integration/tests/formats/ref/cysteine.ket b/api/tests/integration/tests/formats/ref/cysteine.ket index 4ba0204948..68a796da1f 100644 --- a/api/tests/integration/tests/formats/ref/cysteine.ket +++ b/api/tests/integration/tests/formats/ref/cysteine.ket @@ -15,6 +15,7 @@ "classHELM": "PEPTIDE", "alias": "C", "name": "cys", + "naturalAnalogShort": "C", "attachmentPoints": [ { "attachmentAtom": 8, diff --git a/api/tests/integration/tests/formats/ref/fmoc.ket b/api/tests/integration/tests/formats/ref/fmoc.ket index 9c9ac00594..f01a5486d5 100644 --- a/api/tests/integration/tests/formats/ref/fmoc.ket +++ b/api/tests/integration/tests/formats/ref/fmoc.ket @@ -856,6 +856,7 @@ "classHELM": "PEPTIDE", "alias": "H", "name": "His", + "naturalAnalogShort": "H", "attachmentPoints": [ { "attachmentAtom": 5, @@ -1091,6 +1092,7 @@ "classHELM": "PEPTIDE", "alias": "A", "name": "Ala", + "naturalAnalogShort": "A", "attachmentPoints": [ { "attachmentAtom": 2, @@ -1221,6 +1223,7 @@ "classHELM": "PEPTIDE", "alias": "E", "name": "Glu", + "naturalAnalogShort": "E", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1434,6 +1437,7 @@ "classHELM": "PEPTIDE", "alias": "G", "name": "Gly", + "naturalAnalogShort": "G", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1547,6 +1551,7 @@ "classHELM": "PEPTIDE", "alias": "T", "name": "Thr", + "naturalAnalogShort": "T", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1732,6 +1737,7 @@ "classHELM": "PEPTIDE", "alias": "F", "name": "Phe", + "naturalAnalogShort": "F", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1959,6 +1965,7 @@ "classHELM": "PEPTIDE", "alias": "S", "name": "Ser", + "naturalAnalogShort": "S", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2127,6 +2134,7 @@ "classHELM": "PEPTIDE", "alias": "D", "name": "Asp", + "naturalAnalogShort": "D", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2325,6 +2333,7 @@ "classHELM": "PEPTIDE", "alias": "V", "name": "Val", + "naturalAnalogShort": "V", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2485,6 +2494,7 @@ "classHELM": "PEPTIDE", "alias": "Y", "name": "Tyr", + "naturalAnalogShort": "Y", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2750,6 +2760,7 @@ "classHELM": "PEPTIDE", "alias": "L", "name": "Leu", + "naturalAnalogShort": "L", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2925,6 +2936,7 @@ "classHELM": "PEPTIDE", "alias": "Q", "name": "Gln", + "naturalAnalogShort": "Q", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3138,6 +3150,7 @@ "classHELM": "PEPTIDE", "alias": "K", "name": "Lys", + "naturalAnalogShort": "K", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3351,6 +3364,7 @@ "classHELM": "PEPTIDE", "alias": "I", "name": "Ile", + "naturalAnalogShort": "I", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3528,6 +3542,7 @@ "classHELM": "PEPTIDE", "alias": "W", "name": "Trp", + "naturalAnalogShort": "W", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3830,6 +3845,7 @@ "classHELM": "PEPTIDE", "alias": "R", "name": "Arg", + "naturalAnalogShort": "R", "attachmentPoints": [ { "attachmentAtom": 0, diff --git a/api/tests/integration/tests/formats/ref/pepchem.ket b/api/tests/integration/tests/formats/ref/pepchem.ket index 96029585f8..343e8dea60 100644 --- a/api/tests/integration/tests/formats/ref/pepchem.ket +++ b/api/tests/integration/tests/formats/ref/pepchem.ket @@ -826,6 +826,7 @@ "classHELM": "PEPTIDE", "alias": "H", "name": "His", + "naturalAnalogShort": "H", "attachmentPoints": [ { "attachmentAtom": 5, @@ -1061,6 +1062,7 @@ "classHELM": "PEPTIDE", "alias": "A", "name": "Ala", + "naturalAnalogShort": "A", "attachmentPoints": [ { "attachmentAtom": 2, @@ -1191,6 +1193,7 @@ "classHELM": "PEPTIDE", "alias": "E", "name": "Glu", + "naturalAnalogShort": "E", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1404,6 +1407,7 @@ "classHELM": "PEPTIDE", "alias": "G", "name": "Gly", + "naturalAnalogShort": "G", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1517,6 +1521,7 @@ "classHELM": "PEPTIDE", "alias": "T", "name": "Thr", + "naturalAnalogShort": "T", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1702,6 +1707,7 @@ "classHELM": "PEPTIDE", "alias": "F", "name": "Phe", + "naturalAnalogShort": "F", "attachmentPoints": [ { "attachmentAtom": 0, @@ -1929,6 +1935,7 @@ "classHELM": "PEPTIDE", "alias": "S", "name": "Ser", + "naturalAnalogShort": "S", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2097,6 +2104,7 @@ "classHELM": "PEPTIDE", "alias": "D", "name": "Asp", + "naturalAnalogShort": "D", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2295,6 +2303,7 @@ "classHELM": "PEPTIDE", "alias": "V", "name": "Val", + "naturalAnalogShort": "V", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2455,6 +2464,7 @@ "classHELM": "PEPTIDE", "alias": "Y", "name": "Tyr", + "naturalAnalogShort": "Y", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2720,6 +2730,7 @@ "classHELM": "PEPTIDE", "alias": "L", "name": "Leu", + "naturalAnalogShort": "L", "attachmentPoints": [ { "attachmentAtom": 0, @@ -2895,6 +2906,7 @@ "classHELM": "PEPTIDE", "alias": "I", "name": "Ile", + "naturalAnalogShort": "I", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3072,6 +3084,7 @@ "classHELM": "PEPTIDE", "alias": "W", "name": "Trp", + "naturalAnalogShort": "W", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3374,6 +3387,7 @@ "classHELM": "PEPTIDE", "alias": "R", "name": "Arg", + "naturalAnalogShort": "R", "attachmentPoints": [ { "attachmentAtom": 0, @@ -3617,6 +3631,7 @@ "classHELM": "PEPTIDE", "alias": "Q", "name": "Gln", + "naturalAnalogShort": "Q", "attachmentPoints": [ { "attachmentAtom": 0, diff --git a/api/tests/integration/tests/formats/ref/peptides.ket b/api/tests/integration/tests/formats/ref/peptides.ket index 45756340bb..6c45fd8a8c 100644 --- a/api/tests/integration/tests/formats/ref/peptides.ket +++ b/api/tests/integration/tests/formats/ref/peptides.ket @@ -11988,6 +11988,7 @@ "classHELM": "PEPTIDE", "alias": "M", "name": "Met", + "naturalAnalogShort": "M", "attachmentPoints": [ { "attachmentAtom": 0, @@ -12163,6 +12164,7 @@ "classHELM": "PEPTIDE", "alias": "T", "name": "Thr", + "naturalAnalogShort": "T", "attachmentPoints": [ { "attachmentAtom": 0, @@ -12348,6 +12350,7 @@ "classHELM": "PEPTIDE", "alias": "P", "name": "Pro", + "naturalAnalogShort": "P", "attachmentPoints": [ { "attachmentAtom": 7, @@ -12515,6 +12518,7 @@ "classHELM": "PEPTIDE", "alias": "E", "name": "Glu", + "naturalAnalogShort": "E", "attachmentPoints": [ { "attachmentAtom": 0, @@ -12728,6 +12732,7 @@ "classHELM": "PEPTIDE", "alias": "D", "name": "Asp", + "naturalAnalogShort": "D", "attachmentPoints": [ { "attachmentAtom": 0, @@ -12926,6 +12931,7 @@ "classHELM": "PEPTIDE", "alias": "Q", "name": "Gln", + "naturalAnalogShort": "Q", "attachmentPoints": [ { "attachmentAtom": 0, @@ -13139,6 +13145,7 @@ "classHELM": "PEPTIDE", "alias": "L", "name": "Leu", + "naturalAnalogShort": "L", "attachmentPoints": [ { "attachmentAtom": 0, @@ -13314,6 +13321,7 @@ "classHELM": "PEPTIDE", "alias": "G", "name": "Gly", + "naturalAnalogShort": "G", "attachmentPoints": [ { "attachmentAtom": 0, @@ -13427,6 +13435,7 @@ "classHELM": "PEPTIDE", "alias": "S", "name": "Ser", + "naturalAnalogShort": "S", "attachmentPoints": [ { "attachmentAtom": 0, @@ -13595,6 +13604,7 @@ "classHELM": "PEPTIDE", "alias": "A", "name": "Ala", + "naturalAnalogShort": "A", "attachmentPoints": [ { "attachmentAtom": 2, @@ -13725,6 +13735,7 @@ "classHELM": "PEPTIDE", "alias": "R", "name": "Arg", + "naturalAnalogShort": "R", "attachmentPoints": [ { "attachmentAtom": 0, @@ -13968,6 +13979,7 @@ "classHELM": "PEPTIDE", "alias": "V", "name": "Val", + "naturalAnalogShort": "V", "attachmentPoints": [ { "attachmentAtom": 0, @@ -14128,6 +14140,7 @@ "classHELM": "PEPTIDE", "alias": "F", "name": "Phe", + "naturalAnalogShort": "F", "attachmentPoints": [ { "attachmentAtom": 0, @@ -14355,6 +14368,7 @@ "classHELM": "PEPTIDE", "alias": "Y", "name": "Tyr", + "naturalAnalogShort": "Y", "attachmentPoints": [ { "attachmentAtom": 0, @@ -14620,6 +14634,7 @@ "classHELM": "PEPTIDE", "alias": "I", "name": "Ile", + "naturalAnalogShort": "I", "attachmentPoints": [ { "attachmentAtom": 0, @@ -14797,6 +14812,7 @@ "classHELM": "PEPTIDE", "alias": "W", "name": "Trp", + "naturalAnalogShort": "W", "attachmentPoints": [ { "attachmentAtom": 0, @@ -15099,6 +15115,7 @@ "classHELM": "PEPTIDE", "alias": "K", "name": "Lys", + "naturalAnalogShort": "K", "attachmentPoints": [ { "attachmentAtom": 0, @@ -15312,6 +15329,7 @@ "classHELM": "PEPTIDE", "alias": "H", "name": "His", + "naturalAnalogShort": "H", "attachmentPoints": [ { "attachmentAtom": 5, @@ -15547,6 +15565,7 @@ "classHELM": "PEPTIDE", "alias": "N", "name": "Asn", + "naturalAnalogShort": "N", "attachmentPoints": [ { "attachmentAtom": 0, @@ -15745,6 +15764,7 @@ "classHELM": "PEPTIDE", "alias": "C", "name": "Cys", + "naturalAnalogShort": "C", "attachmentPoints": [ { "attachmentAtom": 8, diff --git a/core/indigo-core/molecule/monomer_commons.h b/core/indigo-core/molecule/monomer_commons.h index 3bfaf854ba..950487310d 100644 --- a/core/indigo-core/molecule/monomer_commons.h +++ b/core/indigo-core/molecule/monomer_commons.h @@ -84,6 +84,8 @@ namespace indigo std::string monomerNameByAlias(const std::string& monomer_class, const std::string& alias); + bool isBasicAminoAcid(const std::string& monomer_class, const std::string& alias); + std::string monomerAliasByName(const std::string& monomer_class, const std::string& name); std::string normalizeMonomerName(const std::string& monomer_class, const std::string& name); diff --git a/core/indigo-core/molecule/src/molecule_json_saver.cpp b/core/indigo-core/molecule/src/molecule_json_saver.cpp index 5560ce545b..1b7b39aa3d 100644 --- a/core/indigo-core/molecule/src/molecule_json_saver.cpp +++ b/core/indigo-core/molecule/src/molecule_json_saver.cpp @@ -1174,9 +1174,19 @@ void MoleculeJsonSaver::saveMonomerTemplate(TGroup& tg, JsonWriter& writer) writer.String(tg.tgroup_name.ptr()); } - if (tg.tgroup_natreplace.size()) + std::string natreplace; + if (tg.tgroup_natreplace.size() == 0) { - auto analog = naturalAnalog(tg.tgroup_natreplace.ptr()); + auto alias = monomerAlias(tg); + if (isBasicAminoAcid(template_class, alias)) + natreplace = alias; + } + else + natreplace = tg.tgroup_natreplace.ptr(); + + if (natreplace.size()) + { + auto analog = naturalAnalog(natreplace); auto nat_alias = monomerAliasByName(template_class, analog); writer.Key("naturalAnalogShort"); writer.String(nat_alias.c_str()); diff --git a/core/indigo-core/molecule/src/monomer_commons.cpp b/core/indigo-core/molecule/src/monomer_commons.cpp index dd7b351b0f..08559cd661 100644 --- a/core/indigo-core/molecule/src/monomer_commons.cpp +++ b/core/indigo-core/molecule/src/monomer_commons.cpp @@ -44,6 +44,16 @@ namespace indigo return ""; } + bool isBasicAminoAcid(const std::string& monomer_class, const std::string& alias) + { + if (isAminoAcidClass(monomer_class)) + { + auto it = kAliasToAminoAcid.find(alias); + return it != kAliasToAminoAcid.end(); + } + return false; + } + std::string monomerNameByAlias(const std::string& monomer_class, const std::string& alias) { if (isAminoAcidClass(monomer_class))