From 6024b6172e3c435e5cb10f0d6208da868071b15f Mon Sep 17 00:00:00 2001 From: Daniel Danciu Date: Sun, 21 Jun 2026 17:36:09 +0200 Subject: [PATCH] Import anarci lazily so kasearch imports without it anarci depends on the CC-licensed IMGT germline database, which makes it unsuitable for commercial use. Move the top-level `from anarci import anarci` into _number_chunk (the only place it is used) so `import kasearch` succeeds without anarci installed; it is only required if KA-Search's own ANARCI numbering path is actually called. Co-Authored-By: Claude Opus 4.8 (1M context) --- kasearch/anarci_numbering.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kasearch/anarci_numbering.py b/kasearch/anarci_numbering.py index 62f53c4..eec4fb4 100755 --- a/kasearch/anarci_numbering.py +++ b/kasearch/anarci_numbering.py @@ -1,8 +1,10 @@ -from anarci import anarci from multiprocessing import Pool from functools import partial def _number_chunk(sequences, scheme="imgt", database="ALL", allow=set(["H","K","L"]), allowed_species=['human','mouse'], strict = True, **kwargs): + # Imported lazily so `import kasearch` does not require anarci (which depends on the CC-licensed IMGT + # germline database). Only needed when KA-Search's own ANARCI numbering path is actually used. + from anarci import anarci try: numbered, _, _ = anarci(list(enumerate(sequences)), scheme=scheme, database=database, allow=allow, allowed_species=allowed_species, **kwargs) numbered = [x[0][0] if x else None for x in numbered]