Skip to content

Commit

Permalink
Add to_3di helper function to obtain a StructureSequence from an …
Browse files Browse the repository at this point in the history
…`AtomArray`
  • Loading branch information
althonos committed Sep 14, 2024
1 parent f1a8e4b commit b24a52b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3,225 deletions.
32 changes: 29 additions & 3 deletions src/biotite/structure/alphabet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,34 @@
NumPy port of the ``foldseek`` code for encoding structures to 3di.
"""

__all__ = ["Encoder", "FeatureEncoder", "PartnerIndexEncoder", "VirtualCenterEncoder"]
__author__ = "Martin Larralde <[email protected]>"
__name__ = "biotite.structure.alphabet"
__author__ = "Martin Larralde"
__all__ = ["Encoder", "StructureSequence", "to_3di"]

from .encoder import Encoder, FeatureEncoder, PartnerIndexEncoder, VirtualCenterEncoder
from .encoder import Encoder
from .sequence import StructureSequence

def to_3di(array):
r"""
Encode the atoms to the 3di structure alphabet.
Parameters
----------
atoms : AtomArray
The atom array to encode to 3di. All atoms must be part of
a single chain.
Returns
-------
sequence : StructureSequence
The encoded structure sequence.
Note
----
To encode atoms in different chains, use :func:`apply_chain_wise` to
return a list with one sequence per chain.
"""
encoder = Encoder()
sequence = StructureSequence()
sequence.code = encoder.encode_atoms(array).filled()
return sequence
Loading

0 comments on commit b24a52b

Please sign in to comment.