diff --git a/projects/novelfams/translate2modelcif.py b/projects/novelfams/translate2modelcif.py index 2abf2040481a8d01c515e477fdbb97be469b4cc8..d4392f0857d13e9ab7ed223c7e2a0d49ab0f2ebf 100644 --- a/projects/novelfams/translate2modelcif.py +++ b/projects/novelfams/translate2modelcif.py @@ -262,7 +262,12 @@ def _get_sequence(chn, use_auth=False): class _InvalidCoordinateError(RuntimeError): - """Exception for weird coordinates ina PDB file, used internally to skip + """Exception for weird coordinates in a PDB file, used internally to skip + such PDB files.""" + + +class _NoEntitiesError(RuntimeError): + """Exception for PDB files w/o entities (empty?), used internally to skip such PDB files.""" @@ -270,6 +275,14 @@ def _get_entities(pdb_file, fam_name): """Gather data for the mmCIF (target) entities.""" try: ost_ent = io.LoadPDB(pdb_file) + except OSError as exc: + if str(exc).endswith(" doesn't contain any entities"): + _warn_msg( + f"PDB file '{pdb_file}' does not have entities (maybe empty)." + ) + raise _NoEntitiesError() from exc + _warn_msg(f"Exception for '{pdb_file}'") + raise except Exception as exc: if str(exc).startswith("invalid coordinate on line "): _warn_msg( @@ -599,7 +612,7 @@ def _main(): f_name, opts, ) - except _InvalidCoordinateError: + except (_InvalidCoordinateError, _NoEntitiesError): continue # report progress after a bit of time