From aa4c41a50c65ab0c4bf201dbb877e03fb1f04522 Mon Sep 17 00:00:00 2001 From: Xavier Robin <xavier.robin@unibas.ch> Date: Fri, 22 Dec 2023 09:03:39 +0100 Subject: [PATCH] Fail cleanly for gaps in unknown polymer chain types This avoids silently creating invalid files if we have gaps in oligosaccharide chains, for instance. --- modules/io/src/mol/mmcif_writer.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/io/src/mol/mmcif_writer.cc b/modules/io/src/mol/mmcif_writer.cc index e14ff97d3..230e4e359 100644 --- a/modules/io/src/mol/mmcif_writer.cc +++ b/modules/io/src/mol/mmcif_writer.cc @@ -1344,7 +1344,7 @@ namespace { } } - if(entity_infos[entity_idx].poly_type == "polydeoxyribonucleotide") { + else if(entity_infos[entity_idx].poly_type == "polydeoxyribonucleotide") { entity_infos[entity_idx].mon_ids[mon_id_idx] = "DN"; entity_infos[entity_idx].seq_olcs[mon_id_idx] = "(DN)"; entity_infos[entity_idx].seq_can_olcs[mon_id_idx] = "N"; @@ -1355,7 +1355,7 @@ namespace { } } - if(entity_infos[entity_idx].poly_type == "polyribonucleotide" || + else if(entity_infos[entity_idx].poly_type == "polyribonucleotide" || entity_infos[entity_idx].poly_type == "polydeoxyribonucleotide/polyribonucleotide hybrid") { entity_infos[entity_idx].mon_ids[mon_id_idx] = "N"; entity_infos[entity_idx].seq_olcs[mon_id_idx] = "N"; @@ -1366,6 +1366,13 @@ namespace { comp_infos["N"] = info; } } + + else { + std::stringstream ss; + ss << "Gaps are not supported for polymer chains of type "; + ss << entity_infos[entity_idx].poly_type; + throw ost::io::IOException(ss.str()); + } } } } -- GitLab