from typing import Literal
from aldepyde.data import get_store


def hydropathy(sequence: str, scale: Literal['kd'] = 'kd', window: int = 0) -> list:
    hydropathies = []
    if window < 0:
        return [sum([get_store().hydropathy(aa, scale=scale) for aa in sequence])/len(sequence)]
    for i in range(window, len(sequence) - window, 1):
        residue_window = sequence[i - window:i + window + 1]
        hydropathies.append(sum([get_store().hydropathy(aa, scale=scale) for aa in residue_window])/len(residue_window))
    if len(hydropathies) == 0:
        return [sum([get_store().hydropathy(aa, scale=scale) for aa in sequence])/len(sequence)]
    return hydropathies

def helical_prop(sequence: str, window: int = 0) -> list:
    propensities = []
    if window < 0:
        return [sum([get_store().helical_prop(aa) for aa in sequence])/len(sequence)]
    for i in range(window, len(sequence) - window, 1):
        residue_window = sequence[i - window:i + window + 1]
        propensities.append(sum([get_store().helical_prop(aa) for aa in residue_window])/len(residue_window))
    if len(propensities) == 0:
        return [sum([get_store().helical_prop(aa) for aa in sequence])/len(sequence)]
    return propensities
