Skip to content

Commit 70a34e8

Browse files
polinabinder1claude
andcommitted
refactor(eval): reuse shared evo2_sae.fasta.read_fasta in evo2_buffer
Drop evo2_buffer's local read_fasta — it already imports evo2_sae, so reuse the shared reader (also handles .gz). Kingdom check uses the id prefix, which the shared reader preserves. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Polina Binder <pbinder@nvidia.com>
1 parent 942071d commit 70a34e8

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

  • bionemo-recipes/interpretability/sparse_autoencoders/recipes/evo2/scripts

bionemo-recipes/interpretability/sparse_autoencoders/recipes/evo2/scripts/evo2_buffer.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,13 @@
2828
import labelers as L
2929
import numpy as np
3030
import torch
31+
from evo2_sae.fasta import read_fasta # shared reader (also handles .gz); kingdom check uses the id prefix
3132
from sae.eval.probing import ActivationBuffer
3233

3334

3435
KINGDOM_TAGS = {"prok": "|d__Bacteria|", "euk": "|d__Eukaryota|"}
3536

3637

37-
def read_fasta(path): # noqa: D103
38-
header, chunks = None, []
39-
with open(path) as fh:
40-
for line in fh:
41-
line = line.rstrip("\n")
42-
if line.startswith(">"):
43-
if header is not None:
44-
yield header, "".join(chunks)
45-
header, chunks = line[1:], []
46-
else:
47-
chunks.append(line)
48-
if header is not None:
49-
yield header, "".join(chunks)
50-
51-
5238
def sample_sequences(fasta, max_tokens, seq_len, kingdoms=("prok", "euk"), seed=0): # noqa: D103
5339
from evo2_sae.core import clean_dna
5440

0 commit comments

Comments
 (0)