Skip to content

Commit

Permalink
Fix exception for empty structures
Browse files Browse the repository at this point in the history
  • Loading branch information
padix-key committed Nov 20, 2024
1 parent 38cfd55 commit e2be956
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/biotite/structure/alphabet/i3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
__author__ = "Martin Larralde"
__all__ = ["I3DSequence", "to_3di"]

import warnings
from biotite.sequence.alphabet import LetterAlphabet
from biotite.sequence.sequence import Sequence
from biotite.structure.alphabet.encoder import Encoder
Expand Down Expand Up @@ -95,12 +96,15 @@ def to_3di(atoms):
stop = chain_start_indices[i + 1]
chain = atoms[start:stop]
sequence = I3DSequence()
sequence.code = (
Encoder()
.encode(
*coord_for_atom_name_per_residue(chain, ["CA", "CB", "N", "C"]),
if chain.array_length() == 0:
warnings.warn("Ignoring empty chain")
else:
sequence.code = (
Encoder()
.encode(
*coord_for_atom_name_per_residue(chain, ["CA", "CB", "N", "C"]),
)
.filled()
)
.filled()
)
sequences.append(sequence)
return sequences, chain_start_indices[:-1]

0 comments on commit e2be956

Please sign in to comment.