From e7ca93b15a8efc9b613e93b3ff57749a7a5fd03a Mon Sep 17 00:00:00 2001 From: Luca Babetto Date: Wed, 27 Apr 2022 11:47:16 +0200 Subject: [PATCH] Added try/except in Library.read() method --- pubchemtools/datastructures.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pubchemtools/datastructures.py b/pubchemtools/datastructures.py index 46330b2..ed39625 100644 --- a/pubchemtools/datastructures.py +++ b/pubchemtools/datastructures.py @@ -817,7 +817,11 @@ def read(self, sdf_filepath: str) -> None: compound: Compound for mol in suppl: - self.compounds_list.append(Compound(rdkitmol=mol, autofetch=False)) + try: + self.compounds_list.append(Compound(rdkitmol=mol, autofetch=False)) + except ValueError: + print("ERROR: rdkit could not parse the current molecule. Skipping.") + continue for compound in self.compounds_list: compound._linked_libraries.append(self)