Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2361 - Wrong error message if SMILES phosphate has lack of attachemt point #2715

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 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 @@ -13,6 +13,7 @@ helm_peptide.ket:SUCCEED
helm_rna_without_base.ket:SUCCEED
helm_simple_rna.ket:SUCCEED
helm_smiles.ket:SUCCEED
helm_smiles_no_ap.ket:SUCCEED
helm_smiles_sugar.ket:SUCCEED
helm_unsplit.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.'
Expand All @@ -27,3 +28,4 @@ Test 'PEPTIDE1{A'2'}$$$$V2.0': got expected error 'Repeating not supported now.'
Test 'PEPTIDE1{D-gGlu}$$$$V2.0': got expected error 'Unexpected symbol. Expected '.' or '}' but found '-'.'
Test 'RNA1{R(A).R(A)p}$$$$V2.0': got expected error 'Monomer template with class 'Phosphate' and alias 'R' not found in monomer librarys'
Test 'RNA1{R(bla-bla-bla)p}$$$$V2.0': got expected error 'Unexpected symbol. Expected ')' but found 'l'.'
Test 'RNA1{R[P(O)(O)(=O)O]}$$$$V2.0': got expected error 'Unknown attachment point 'R1' in monomer Mod0'
2 changes: 2 additions & 0 deletions api/tests/integration/tests/formats/helm_to_ket.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def find_diff(a, b):
"helm_fractional_ratio": "PEPTIDE1{(A:1.5+C:0.1+G:3)}$$$$V2.0",
"helm_chem_rna_hydro": "CHEM1{[MCC]}|RNA1{R(U)P}$CHEM1,RNA1,1:pair-3:pair$$$V2.0",
"helm_unsplit": "RNA1{[5Br-dU]}$$$$V2.0",
"helm_smiles_no_ap": "CHEM1{[P(O)(O)(=O)O]}$$$$V2.0",
}

lib = indigo.loadMonomerLibraryFromFile(
Expand Down Expand Up @@ -78,6 +79,7 @@ def find_diff(a, b):
"PEPTIDE1{(A:+C:0.1)}$$$$V2.0": "Unexpected symbol. Expected digit but found '+'",
"RNA1{R(A).R(A)p}$$$$V2.0": "Monomer template with class 'Phosphate' and alias 'R' not found in monomer librarys",
"PEPTIDE1{(A:1.5.+C:0.1)}$$$$V2.0": "Enexpected symbol. Second dot in number",
"RNA1{R[P(O)(O)(=O)O]}$$$$V2.0": "Unknown attachment point 'R1' in monomer Mod0",
}
for helm_seq in sorted(helm_errors.keys()):
error = helm_errors[helm_seq]
Expand Down
103 changes: 103 additions & 0 deletions api/tests/integration/tests/formats/ref/helm_smiles_no_ap.ket
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"root": {
"nodes": [
{
"$ref": "monomer0"
}
],
"templates": [
{
"$ref": "monomerTemplate-Mod0"
}
]
},
"monomer0": {
"type": "monomer",
"id": "0",
"seqid": 1,
"position": {
"x": 0.000000,
"y": -0.000000
},
"alias": "Mod0",
"templateId": "Mod0"
},
"monomerTemplate-Mod0": {
"type": "monomerTemplate",
"id": "Mod0",
"class": "CHEM",
"alias": "Mod0",
"atoms": [
{
"label": "P",
"location": [
0.000000,
0.000000,
0.000000
]
},
{
"label": "O",
"location": [
-0.500000,
-0.866025,
0.000000
]
},
{
"label": "O",
"location": [
0.866025,
-0.500000,
0.000000
]
},
{
"label": "O",
"location": [
-0.866025,
0.500000,
0.000000
]
},
{
"label": "O",
"location": [
0.500000,
0.866025,
0.000000
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
0,
1
]
},
{
"type": 1,
"atoms": [
0,
2
]
},
{
"type": 2,
"atoms": [
0,
3
]
},
{
"type": 1,
"atoms": [
0,
4
]
}
]
}
}
19 changes: 18 additions & 1 deletion core/indigo-core/molecule/src/sequence_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,24 @@ std::string SequenceLoader::readHelmMonomerAlias(KetDocument& document, MonomerC
throw Error(unexpected_eod);
if (ch != ']')
throw Error("Unexpected symbol. Expected ']' but found '%c'.", ch);
if (smiles)
bool found = false;
if (_library.getMonomerTemplateIdByAlias(monomer_class, monomer_alias).size() > 0)
{
found = true;
}
else if (monomer_class == MonomerClass::Sugar) // In place of sugar can be phosphate or unsplit rna
{
if (_library.getMonomerTemplateIdByAlias(MonomerClass::Phosphate, monomer_alias).size() > 0)
{
found = true;
}
else
{
if (_library.getMonomerTemplateIdByAlias(MonomerClass::RNA, monomer_alias).size() > 0)
found = true;
}
}
if (smiles || !found) // Monomer alias not found in library - try read as smiles
{
// Convert smiles to molecule
BufferScanner scanner(monomer_alias.c_str());
Expand Down
Loading