Skip to content

Commit

Permalink
Catch TypeError exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
yokochi47 committed Apr 5, 2024
1 parent 78e9d6c commit c2dc8e7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
14 changes: 7 additions & 7 deletions wwpdb/utils/nmr/NEFTranslator/NEFTranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ def skip_empty_value_error(lp, idx):
for idx, row in enumerate(seq_data):
try:
int(row[0])
except ValueError:
except (ValueError, TypeError):
if idx < len_loop_data:
if skip_empty_value_error(loop, idx):
continue
Expand Down Expand Up @@ -1603,7 +1603,7 @@ def skip_empty_value_error(lp, idx):
for idx, row in enumerate(seq_data):
try:
int(row[0])
except ValueError:
except (ValueError, TypeError):
if idx < len_loop_data:
if skip_empty_value_error(loop, idx):
continue
Expand Down Expand Up @@ -1828,7 +1828,7 @@ def skip_empty_value_error(lp, idx):
for idx, row in enumerate(seq_data):
try:
int(row[seq_id_col])
except ValueError:
except (ValueError, TypeError):
if idx < len_loop_data:
if skip_empty_value_error(loop, idx):
continue
Expand Down Expand Up @@ -2094,7 +2094,7 @@ def get_atom_type_from_cs_loop(self, star_data, lp_category, atom_type, isotope_
for idx, row in enumerate(a_type_data):
try:
int(row[1])
except ValueError:
except (ValueError, TypeError):
if idx < len_loop_data:
r = {}
for j, t in enumerate(loop.tags):
Expand Down Expand Up @@ -2217,7 +2217,7 @@ def get_star_ambig_code_from_cs_loop(self, star_data, lp_category='Atom_chem_shi
else:
try:
int(row[3])
except ValueError:
except (ValueError, TypeError):
if idx < len_loop_data:
r = {}
for j, t in enumerate(loop.tags):
Expand Down Expand Up @@ -2317,7 +2317,7 @@ def get_index(self, star_data, lp_category, index_id, row_limit=10000): # pylin
else:
try:
int(i)
except ValueError:
except (ValueError, TypeError):
if idx < len_loop_data:
r = {}
for j, t in enumerate(loop.tags):
Expand Down Expand Up @@ -2624,7 +2624,7 @@ def skip_empty_value_error(lp, idx):
if len(dup_idxs) > 0:
raise KeyError(f"{tags[idx_tag_id]} must be unique in loop. {dup_idxs} are duplicated.")

except ValueError:
except (ValueError, TypeError):
r = {}
for j, t in enumerate(loop.tags):
r[t] = loop.data[idx][j]
Expand Down
40 changes: 31 additions & 9 deletions wwpdb/utils/nmr/NmrDpUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -20762,6 +20762,9 @@ def __testNmrCovalentBond(self):
comp_id_2 = row[comp_id_2_name]
atom_id_2 = row[atom_id_2_name]

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

atom_id_1_ = atom_id_1[0]
atom_id_2_ = atom_id_2[0]

Expand Down Expand Up @@ -27974,6 +27977,9 @@ def __testRdcVector__(self, file_name, file_type, content_subtype, sf_framecode,
comp_id_2 = row[comp_id_2_name]
atom_id_2 = row[atom_id_2_name]

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

if (atom_id_1[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS) or (atom_id_2[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS):

idx_msg = f"[Check row of {index_tag} {row[index_tag]}] " if index_tag in row else ''
Expand Down Expand Up @@ -30197,7 +30203,7 @@ def get_auth_seq_scheme(chain_id, seq_id):
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]

if atom_id_1 is None or atom_id_2 is None:
if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

atom_id_1_ = atom_id_1[0]
Expand Down Expand Up @@ -52413,7 +52419,8 @@ def __mergeLegacyCsAndMr(self):
comp_id_2 = row[comp_id_2_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None or _id == prev_id:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue
# """
# if (member_logic_code is not None and member_logic_code == 'OR') or _id == prev_id:
Expand Down Expand Up @@ -52571,7 +52578,8 @@ def __mergeLegacyCsAndMr(self):
comp_id_2 = row[comp_id_2_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None or _id == prev_id:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue
# """
# if (member_logic_code is not None and member_logic_code == 'OR') or _id == prev_id:
Expand Down Expand Up @@ -53023,8 +53031,10 @@ def __mergeLegacyCsAndMr(self):
comp_id_1 = row[comp_id_1_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

combination_id = row[combination_id_col] if combination_id_col != -1 else None

vector = {atom_id_1, atom_id_2}
Expand Down Expand Up @@ -53144,8 +53154,10 @@ def __mergeLegacyCsAndMr(self):
comp_id_2 = row[comp_id_2_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

if atom_id_1[0] in protonBeginCode:
if self.__ccU.updateChemCompDict(comp_id_1):
bonded_atom_id_1 = self.__ccU.getBondedAtoms(comp_id_1, atom_id_1)
Expand Down Expand Up @@ -53216,8 +53228,10 @@ def __mergeLegacyCsAndMr(self):
comp_id_2 = row[comp_id_2_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

if atom_id_1[0] in protonBeginCode:
if self.__ccU.updateChemCompDict(comp_id_1):
bonded_atom_id_1 = self.__ccU.getBondedAtoms(comp_id_1, atom_id_1)
Expand Down Expand Up @@ -54242,6 +54256,10 @@ def __updateConstraintStats(self):
comp_id_2 = row[comp_id_2_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

atom_id_1_ = atom_id_1[0]
atom_id_2_ = atom_id_2[0]
if comp_id_1 == atom_id_1 or comp_id_2 == atom_id_2:
Expand Down Expand Up @@ -54363,7 +54381,8 @@ def __updateConstraintStats(self):
comp_id_2 = row[comp_id_2_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None or _id == prev_id:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue
# """
# if (member_logic_code is not None and member_logic_code == 'OR') or _id == prev_id:
Expand Down Expand Up @@ -54525,7 +54544,8 @@ def __updateConstraintStats(self):
comp_id_2 = row[comp_id_2_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None or _id == prev_id:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue
# """
# if (member_logic_code is not None and member_logic_code == 'OR') or _id == prev_id:
Expand Down Expand Up @@ -55026,8 +55046,10 @@ def __updateConstraintStats(self):
comp_id_1 = row[comp_id_1_col]
atom_id_1 = row[atom_id_1_col]
atom_id_2 = row[atom_id_2_col]
if atom_id_1 is None or atom_id_2 is None:

if atom_id_1 in emptyValue or atom_id_2 in emptyValue:
continue

combination_id = row[combination_id_col] if combination_id_col != -1 else None

vector = {atom_id_1, atom_id_2}
Expand Down

0 comments on commit c2dc8e7

Please sign in to comment.