fasta_lake.headers.fasta_io#
fasta_lake.headers.fasta_io
#
FastaLake v4 — FASTA I/O with full header preservation.
This module provides header-preserving alternatives to the functions in helpers.py. The original helpers.py functions are kept unchanged for backward compatibility.
Key difference from v3 helpers.py: - load_fasta_proteins() in helpers.py truncates headers to first token - load_fasta_full() here preserves the complete header line - write_fasta_proteins() here writes full headers, not just protein IDs
load_fasta_full
#
Load FASTA file preserving full headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fasta_file
|
path
|
Input FASTA file. |
required |
Returns:
| Type | Description |
|---|---|
dict mapping protein_id → (sequence, full_header)
|
protein_id is the first whitespace-delimited token (accession). full_header is the complete header line without '>'. sequence is the concatenated sequence. |
Source code in fasta_lake/headers/fasta_io.py
load_fasta_proteins
#
Load FASTA file returning protein_id → sequence (backward compatible).
This is equivalent to helpers.load_fasta_proteins() but uses the full loader internally. Provided for drop-in compatibility.
Source code in fasta_lake/headers/fasta_io.py
write_fasta
#
write_fasta(proteins: dict[str, tuple[str, str]], output_path: str | Path, line_width: int = 60) -> int
Write FASTA file with full headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proteins
|
dict
|
Mapping protein_id → (sequence, full_header). |
required |
output_path
|
path
|
Output file path. |
required |
line_width
|
int
|
Sequence line width (default 60). |
60
|
Returns:
| Type | Description |
|---|---|
int
|
Number of proteins written. |
Source code in fasta_lake/headers/fasta_io.py
write_fasta_simple
#
write_fasta_simple(protein_ids: list[str], proteins: dict[str, tuple[str, str]], output_path: str | Path, line_width: int = 60) -> int
Write a subset of proteins to FASTA with full headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protein_ids
|
list
|
List of protein IDs to write (order preserved). |
required |
proteins
|
dict
|
Full protein dict from load_fasta_full(). |
required |
output_path
|
path
|
Output file path. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of proteins written. |