AnnotationPreprocessor.register_feature

AnnotationPreprocessor.register_feature(key, subcategory=None, normalization=None)[source]

Register (or override) an open-vocabulary Functional-sites key.

Adds a new feature_type label to the per-instance registry so that encode() knows how many output dimensions to allocate and which normalization recipe to apply. Unknown keys that arrive during ingest() are auto-registered with default settings; call this method first to supply a custom subcategory or normalization function.

Added in version 1.1.0.

Parameters:
  • key (str) – The feature key (the user/predictor feature_type).

  • subcategory (str, optional) – Fine-grained label; defaults to 'FUNC_<key>'.

  • normalization (callable, optional) – Recipe applied to the raw per-residue values; defaults to a clip to [0, 1] (values must already lie in that range).

Return type:

None

Raises:

ValueError – If key is not a non-empty string.

Examples

register_feature explicitly registers (or overrides) an open-vocabulary Functional sites key before ingest — giving it a subcategory label and an optional custom normalization callable (default: identity, values must already lie in [0, 1]). Use it when you want a predictor channel named and normalized your way rather than auto-registered.

import warnings
import numpy as np
import pandas as pd
import aaanalysis as aa
import aaanalysis.utils as ut
aa.options['verbose'] = False
warnings.filterwarnings('ignore')

ap = aa.AnnotationPreprocessor(verbose=False)
df_seq = pd.DataFrame({'entry': ['AF_TINY'],
                       'sequence': ['ACDEFGHIKLMNPQRSTVWYACDEFGHIKL']})

ap.register_feature(key='kinase_site',
                    subcategory='Kinase site (predictor)')
print('registered:', 'kinase_site' in ap._registry)
print(ap._registry['kinase_site'])
registered: True
{'method': 'encode', 'num_dims': 1, 'dim_names': ['kinase_site'], 'category': 'Functional sites', 'subcategory': 'Kinase site (predictor)'}