Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3di encoding to biotite.structure #665

Merged
merged 13 commits into from
Nov 4, 2024
Merged
Prev Previous commit
Next Next commit
Add to_3di helper function to obtain a StructureSequence from an …
…`AtomArray`
  • Loading branch information
althonos authored and padix-key committed Nov 2, 2024
commit 9c25dbb32bec0ae9d7ee47e0f6160251ec172d9b
32 changes: 29 additions & 3 deletions src/biotite/structure/alphabet/__init__.py
Original file line number Diff line number Diff line change
@@ -6,8 +6,34 @@
NumPy port of the ``foldseek`` code for encoding structures to 3di.
"""

__all__ = ["Encoder", "FeatureEncoder", "PartnerIndexEncoder", "VirtualCenterEncoder"]
__author__ = "Martin Larralde <martin.larralde@embl.de>"
__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