Skip to content

Commit

Permalink
Backmerge: #2064 System establishes connection between monomers even …
Browse files Browse the repository at this point in the history
…if data is wrong (#2095)
  • Loading branch information
AliaksandrDziarkach authored Jul 8, 2024
1 parent 8147b45 commit 51d5876
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions api/tests/integration/ref/formats/helm_to_ket.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ helm_multi_char_rna.ket:SUCCEED
helm_peptide.ket:SUCCEED
helm_rna_without_base.ket:SUCCEED
helm_simple_rna.ket:SUCCEED
Test 'CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM1,PEPTIDE1,1:R2-3:R1$$$V2.0': got expected error 'Polymer 'PEPTIDE1' does not contains monomer with number 3.'
Test 'CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM10,PEPTIDE1,1:R2-1:R1$$$V2.0': got expected error 'Polymer 'CHEM10' not found.'
Test 'CHEM1{[MCC]}|RNA1{R(A)P.R(C)P.R(G)P.R(T)P.R(U)P}$RNA1,PEPTIDE1,15:R2-1:R1$$$V2.0': got expected error 'Polymer 'PEPTIDE1' not found.'
Test 'PEPTIDE1{A'2'}$$$$V2.0': got expected error 'Repeating do not supported now.'
7 changes: 6 additions & 1 deletion api/tests/integration/tests/formats/helm_to_ket.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def find_diff(a, b):
print(filename + ".ket:FAILED")
print(diff)

helm_errors = {"PEPTIDE1{A'2'}$$$$V2.0": "Repeating do not supported now."}
helm_errors = {
"PEPTIDE1{A'2'}$$$$V2.0": "Repeating do not supported now.",
"CHEM1{[MCC]}|RNA1{R(A)P.R(C)P.R(G)P.R(T)P.R(U)P}$RNA1,PEPTIDE1,15:R2-1:R1$$$V2.0": "Polymer 'PEPTIDE1' not found.",
"CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM10,PEPTIDE1,1:R2-1:R1$$$V2.0": "Polymer 'CHEM10' not found.",
"CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM1,PEPTIDE1,1:R2-3:R1$$$V2.0": "Polymer 'PEPTIDE1' does not contains monomer with number 3.",
}
for helm_seq in sorted(helm_errors.keys()):
error = helm_errors[helm_seq]
try:
Expand Down
16 changes: 14 additions & 2 deletions core/indigo-core/molecule/src/sequence_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,11 +1059,17 @@ void SequenceLoader::loadHELM(BaseMolecule& mol)
// CHEM1,RNA1,32:R1-12:R2"annotation"|.....
std::string left_polymer, right_polymer;
std::ignore = readHelmSimplePolymerName(left_polymer);
auto left_polymer_nums = used_polymer_nums.find(left_polymer);
if (left_polymer_nums == used_polymer_nums.end())
throw Error("Polymer '%s' not found.", left_polymer.c_str());
ch = _scanner.lookNext();
if (ch != ',')
throw Error("Unexpected symbol. Expected ',' but found '%c'.", _scanner.lookNext());
_scanner.skip(1);
std::ignore = readHelmSimplePolymerName(right_polymer);
auto right_polymer_nums = used_polymer_nums.find(right_polymer);
if (right_polymer_nums == used_polymer_nums.end())
throw Error("Polymer '%s' not found.", right_polymer.c_str());
ch = _scanner.lookNext();
if (ch != ',')
throw Error("Unexpected symbol. Expected ',' but found '%c'.", _scanner.lookNext());
Expand All @@ -1087,8 +1093,14 @@ void SequenceLoader::loadHELM(BaseMolecule& mol)
if (error_pos != position.size() - 1) // arrray contains 0 at the end
throw Error("Only direct connections supported now.");
_scanner.readWord(right_ap, "\"|$");
int left_templ_atom_idx = used_polymer_nums[left_polymer][left_monomer_idx];
int right_templ_atom_idx = used_polymer_nums[right_polymer][right_monomer_idx];
auto left_mon_it = left_polymer_nums->second.find(left_monomer_idx);
if (left_mon_it == left_polymer_nums->second.end())
throw Error("Polymer '%s' does not contains monomer with number %d.", left_polymer.c_str(), left_monomer_idx);
int left_templ_atom_idx = left_mon_it->second;
auto right_mon_it = right_polymer_nums->second.find(right_monomer_idx);
if (right_mon_it == right_polymer_nums->second.end())
throw Error("Polymer '%s' does not contains monomer with number %d.", right_polymer.c_str(), right_monomer_idx);
int right_templ_atom_idx = right_mon_it->second;
mol.asMolecule().addBond_Silent(left_templ_atom_idx, right_templ_atom_idx, BOND_SINGLE);
mol.setTemplateAtomAttachmentOrder(left_templ_atom_idx, right_templ_atom_idx, convertAPFromHELM(left_ap.ptr()).c_str());
mol.setTemplateAtomAttachmentOrder(right_templ_atom_idx, left_templ_atom_idx, convertAPFromHELM(right_ap.ptr()).c_str());
Expand Down

0 comments on commit 51d5876

Please sign in to comment.