From c9785128fdc13226c888c7d9cb06157ee7bdb46c Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Thu, 20 Apr 2023 10:58:16 +0200
Subject: [PATCH] be more permissive when reading atom serial number

OST writes invalid atom serial numbers if they exceed the PDB format limits.
That's a feature not a bug. The new behaviour is that invalid serial numbers
don't get parsed. Any processing function working with these serial numbers
need to manually check for that. The only current effect is when reading
CONECT statements. Atoms with invalid serial numbers are not connected.
---
 modules/io/src/mol/pdb_reader.cc | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc
index 64bd77742..3b69915de 100644
--- a/modules/io/src/mol/pdb_reader.cc
+++ b/modules/io/src/mol/pdb_reader.cc
@@ -614,13 +614,10 @@ bool PDBReader::ParseAtomIdent(const StringRef& line, int line_num,
   resnum=to_res_num(res_num.second, ins_c);
 
   std::pair<bool, int> tmp = line.substr(6, 5).trim().to_int();
-  if(!tmp.first) {
-    if (profile_.fault_tolerant) {
-      return false;
-    }
-    throw IOException(str(format("invalid atom serial on line %d") % line_num));
+  if(tmp.first) {
+    // potentially not set - up to the caller to check for that
+    serial = tmp.second;
   }
-  serial = tmp.second;
 
   return true;
 }
-- 
GitLab