"""
ciffy - Fast CIF file parsing for molecular structures.

A Python package for loading and manipulating molecular structures from
CIF (Crystallographic Information File) format files.
"""

from importlib.metadata import version, PackageNotFoundError

try:
    __version__ = version("ciffy")
except PackageNotFoundError:
    __version__ = "0.0.0.dev0"  # Fallback for editable installs without scm

# Core types
from .polymer import Polymer
from .types import Scale, Molecule

# Operations
from .operations.reduction import Reduction
from .operations.alignment import kabsch_distance as rmsd, align
from .operations.metrics import tm_score, lddt

# I/O
from .io.loader import load, load_metadata
from .io.writer import write_cif

# Template generation
from .template import from_sequence

# Vocabulary sizes (for embedding layers)
from .biochemistry import NUM_ELEMENTS, NUM_RESIDUES, NUM_ATOMS

# Neural network utilities (requires PyTorch)
from . import nn

# Visualization utilities
from . import visualize
from .visualize import to_defattr, plot_profile, contact_map

# Expose profiling function if available (when built with CIFFY_PROFILE=1)
try:
    from ._c import _get_profile
except (ImportError, AttributeError):
    pass  # Profiling not enabled in this build

# Convenience aliases
ATOM = Scale.ATOM
RESIDUE = Scale.RESIDUE
CHAIN = Scale.CHAIN
MOLECULE = Scale.MOLECULE

PROTEIN = Molecule.PROTEIN
RNA = Molecule.RNA
DNA = Molecule.DNA
LIGAND = Molecule.LIGAND
ION = Molecule.ION
WATER = Molecule.WATER

__all__ = [
    # Version
    "__version__",
    # Core types
    "Polymer",
    "Scale",
    "Molecule",
    "Reduction",
    # Functions
    "load",
    "load_metadata",
    "write_cif",
    "from_sequence",
    "rmsd",
    "align",
    "tm_score",
    "lddt",
    # Vocabulary sizes
    "NUM_ELEMENTS",
    "NUM_RESIDUES",
    "NUM_ATOMS",
    # Convenience aliases
    "ATOM",
    "RESIDUE",
    "CHAIN",
    "MOLECULE",
    "PROTEIN",
    "RNA",
    "DNA",
    "LIGAND",
    "ION",
    "WATER",
    # Submodules
    "nn",
    "visualize",
    # Visualization functions
    "to_defattr",
    "plot_profile",
    "contact_map",
]
