Louis BECQUEY

solved issue if duplicate nt_resnum at the end of the chain

...@@ -273,7 +273,8 @@ class Chain: ...@@ -273,7 +273,8 @@ class Chain:
273 if self.mapping is not None: 273 if self.mapping is not None:
274 self.mapping.log(f"Shifting nt_resnum numbering because of {n_dup} duplicate residues {df.iloc[i,1]}") 274 self.mapping.log(f"Shifting nt_resnum numbering because of {n_dup} duplicate residues {df.iloc[i,1]}")
275 275
276 - if df.iloc[i,1] == df.iloc[i-1,1] and df.iloc[index_last_dup + 1, 1] - 1 > df.iloc[index_last_dup, 1]: 276 + try:
277 + if i > 0 and index_last_dup +1 < len(df.index) and df.iloc[i,1] == df.iloc[i-1,1] and df.iloc[index_last_dup + 1, 1] - 1 > df.iloc[index_last_dup, 1]:
277 # The redundant nts are consecutive in the chain (at the begining at least), and there is a gap at the end 278 # The redundant nts are consecutive in the chain (at the begining at least), and there is a gap at the end
278 279
279 if duplicates.iloc[n_dup-1, 0] - duplicates.iloc[0, 0] + 1 == n_dup: 280 if duplicates.iloc[n_dup-1, 0] - duplicates.iloc[0, 0] + 1 == n_dup:
...@@ -299,6 +300,12 @@ class Chain: ...@@ -299,6 +300,12 @@ class Chain:
299 # Solution : set nt_resnum[i] to nt_resnum[i-1] + 1, and shift the following by 1. 300 # Solution : set nt_resnum[i] to nt_resnum[i-1] + 1, and shift the following by 1.
300 df.iloc[i, 1] = 1 + df.iloc[i-1, 1] 301 df.iloc[i, 1] = 1 + df.iloc[i-1, 1]
301 df.iloc[i+1:, 1] += 1 302 df.iloc[i+1:, 1] += 1
303 + except:
304 + warn(f"Error with parsing of {self.chain_label} duplicate residue numbers. Ignoring it.")
305 + self.delete_me = True
306 + self.error_messages = f"Error with parsing of duplicate residues numbers."
307 + return None
308 +
302 309
303 # Search for ligands at the end of the selection 310 # Search for ligands at the end of the selection
304 # Drop ligands detected as residues by DSSR, by detecting several markers 311 # Drop ligands detected as residues by DSSR, by detecting several markers
......