fasta_lake.config#
fasta_lake.config
#
JSON configuration system for FASTA Lake v3 (SAGE-inspired).
Supports 5 use cases from a single config format:
- Metaproteomics (UHGG + GMGC + assemblies, 233M proteins)
- Clinical proteomics (SwissProt + TrEMBL + gnomAD variants)
- Strain-level resolution (variant-specific peptides from WGS)
- Environmental (GMSC + custom assemblies, unknown organisms)
- Single-species DDA (UniProt organism, standard proteomics)
Only 3 fields required: database.sources, peptide_evidence.predictions_dir,
and output.directory. Everything else has sensible defaults.
Design Principles
- No hidden transformations: every sequence decision is logged
- I/L normalization is the ONLY sequence modification (documented, configurable)
- Provenance tracking: every protein in output traceable to source DB + evidence
- Entrapment is orthogonal: real proteins from known-absent organisms, not decoys (SAGE handles target-decoy FDR internally)
DatabaseSource
dataclass
#
A single protein database source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Short identifier for this source (e.g., |
required |
path
|
str
|
Path to FASTA file (plain or gzipped). |
required |
priority
|
int
|
Priority for deduplication (lower = higher priority). When the same sequence appears in multiple sources, the highest-priority source header is kept. |
1
|
type
|
str
|
Source type for inference logic. One of:
|
'reference'
|
Source code in fasta_lake/config.py
__post_init__
#
Normalize the source path and reject unsupported source categories.
Source code in fasta_lake/config.py
DatabaseConfig
dataclass
#
Database configuration section.
Supports multiple source types for different use cases:
reference: canonical protein databases (SwissProt, UHGG, GMGC)variant: protein variants (gnomAD SAVs, patient WGS, TrEMBL isoforms)assembly: de novo assemblies (metagenomic, transcriptomic)contaminant: known contaminants (cRAP, keratin, trypsin)entrapment: known-absent proteins for FDR validation
Source code in fasta_lake/config.py
__post_init__
#
Convert source dictionaries into validated DatabaseSource objects.
SequenceQualityConfig
dataclass
#
Protein sequence quality filters (all optional).
These filters remove low-quality sequences BEFORE peptide matching. Each filter can be independently enabled/disabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_length
|
int
|
Minimum protein length in amino acids. Proteins shorter than this are excluded. Default: 30. |
30
|
max_length
|
int
|
Maximum protein length. Proteins longer than this are excluded. Default: 50000 (titin is ~34,000 aa). |
50000
|
reject_poly_runs
|
bool
|
If True, reject proteins with homopolymeric runs (e.g., AAAAAAAAAA). These are typically assembly artifacts. Default: True. |
True
|
poly_run_length
|
int
|
Minimum consecutive identical amino acids to trigger rejection. Default: 10 (e.g., 10 consecutive A's). |
10
|
reject_low_complexity
|
bool
|
If True, reject sequences dominated by a small number of amino acids. Uses a simple entropy-based filter. Default: False. |
False
|
low_complexity_threshold
|
float
|
Shannon entropy threshold (0-1 normalized). Sequences below this are rejected. 0.0 = completely uniform, 1.0 = maximum diversity. Default: 0.3 (~sequences where >70% is one amino acid). |
0.3
|
reject_fragments
|
bool
|
If True, flag likely protein fragments: sequences that don't start
with M and are shorter than |
False
|
fragment_length_threshold
|
int
|
Proteins without M-start shorter than this are flagged as fragments. Default: 100. |
100
|
Source code in fasta_lake/config.py
PeptideEvidenceConfig
dataclass
#
Peptide evidence configuration.
Controls how AlphaNovo predictions are filtered before mapping to the protein database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions_dir
|
str
|
Path to directory containing AlphaNovo prediction CSVs. |
''
|
min_length
|
int
|
Minimum peptide length (amino acids). Default: 9. |
9
|
max_length
|
int
|
Maximum peptide length (amino acids). Default: 50. |
50
|
min_score
|
float
|
Minimum AlphaNovo confidence score. Peptides below this are discarded. Default: 0.0 (keep all non-zero scores). |
0.0
|
top_percent
|
float
|
Keep only the top N% of peptides per sample by score. Set to 1.0 to disable. Default: 0.30 (top 30%). |
0.3
|
normalize_il
|
bool
|
Replace I with L for mass spec equivalence. This is the ONLY sequence transformation applied. Default: True. |
True
|
Source code in fasta_lake/config.py
ComplexityConfig
dataclass
#
Sample complexity estimation from de novo results.
Maps de novo peptides to the reference database to estimate sample complexity BEFORE building the per-sample database. This helps choose optimal parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Enable complexity estimation. Default: False. |
False
|
reference_db
|
str
|
Path to a reference database for complexity estimation. If empty, uses the first database source. |
''
|
auto_recommend
|
bool
|
If True, recommend optimal strategy and parameters based on detected complexity. Default: True. |
True
|
report_metrics
|
list[str]
|
Metrics to compute: |
(lambda: ['hit_rate', 'species_richness', 'peptide_diversity'])()
|
Source code in fasta_lake/config.py
InferenceConfig
dataclass
#
Protein inference strategy configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategy
|
str
|
Inference strategy. One of:
|
'species_budget'
|
min_peptides
|
int
|
Minimum peptides per protein for uniform_2pep. Default: 1. |
1
|
strain_resolution
|
bool
|
If True, treat variant proteins as distinct strains. Variant-specific peptides are used to distinguish between canonical and variant forms. Relevant for clinical proteomics with gnomAD/WGS data. Default: False. |
False
|
keep_contaminants
|
bool
|
If True, always include contaminant-tagged proteins in output regardless of peptide evidence. Standard practice for proteomics search. Default: True. |
True
|
keep_entrapment
|
bool
|
If True, include entrapment-tagged proteins in output for FDR validation. Entrapment hits in SAGE results indicate false discoveries. Default: True. |
True
|
Source code in fasta_lake/config.py
__post_init__
#
Reject an inference strategy absent from the supported strategy registry.
Source code in fasta_lake/config.py
EntrapmentConfig
dataclass
#
Entrapment database configuration for FDR validation.
Entrapment proteins are real proteins from organisms guaranteed to be absent from the sample. Any SAGE hits to entrapment proteins indicate false discoveries, providing an orthogonal FDR estimate independent of the target-decoy approach.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Enable entrapment. Default: False. |
False
|
method
|
str
|
How to generate/source entrapment proteins:
|
'phylogenetic'
|
source
|
str
|
Path to entrapment FASTA (for method |
''
|
n_proteins
|
int
|
Number of entrapment proteins to include. Default: 1000.
For |
1000
|
expected_fdr
|
float
|
Expected false discovery rate. Used for reporting -- if entrapment hit rate exceeds this, a warning is raised. Default: 0.01 (1%). |
0.01
|
entrap_class
|
str
|
Entrapment class from |
''
|
stage
|
str
|
Where entrapment is injected. One of, earliest first:
The first three measure database-construction error and differ by how
much curation entrapment had to survive; |
'preselect'
|
seed
|
int
|
Random seed for entrapment generation. Default: 42. Zero is rejected (it is a fixed point of the xorshift64 generator in the Rust extractor). |
42
|
Source code in fasta_lake/config.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
__post_init__
#
Normalize the injection stage and validate seed, count and FDR settings.
Source code in fasta_lake/config.py
ClusteringConfig
dataclass
#
Clustering configuration section.
The configured identity is the single source of truth for the MMseqs2
--min-seq-id value the pipeline runs. Supported sweep values are
0.90, 0.95, 0.97, 0.99, 1.0. A value of 1.0 means exact dedup /
skip clustering, matching the historical pipeline semantics (clustering at
100% identity is degenerate, so it is treated as a no-op pass-through of
the input FASTA).
Source code in fasta_lake/config.py
skip_clustering
property
#
True when clustering is a no-op for this config.
Clustering is skipped when explicitly disabled, or when identity
is 1.0 (exact-dedup / pass-through), matching current semantics.
__post_init__
#
Require identity and coverage fractions in the interval (0, 1].
Source code in fasta_lake/config.py
mmseqs_args
#
The MMseqs2 easy-cluster argument list driven by this config.
Returns the flags appended after easy-cluster <in> <out> <tmp>.
Default (identity=0.97, coverage=0.8) reproduces the historical
hardcoded command exactly:
--min-seq-id 0.97 -c 0.8 --cov-mode 0 --threads 16 --remove-tmp-files 1.
Source code in fasta_lake/config.py
OutputConfig
dataclass
#
Output configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
Output directory path. Created if it doesn't exist. |
'./output'
|
write_stats
|
bool
|
Write JSON stats file alongside output FASTA. Default: True. |
True
|
write_hits_tsv
|
bool
|
Write peptide-protein hits TSV. Default: True. |
True
|
write_audit_log
|
bool
|
Write a detailed audit log tracking every protein decision (included/excluded, reason, source DB, evidence). Default: False. |
False
|
provenance_tracking
|
bool
|
Tag output FASTA headers with source database and evidence count. Enables full traceability from output back to input. Default: True. |
True
|
Source code in fasta_lake/config.py
RustConfig
dataclass
#
FastaLakeConfig
dataclass
#
Complete FASTA Lake v3 configuration.
Supports all proteomics use cases from a single config format.
Only 3 fields required: database.sources,
peptide_evidence.predictions_dir, and output.directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acquisition
|
str
|
Data acquisition mode. Determines de novo engine expectations and search engine compatibility:
|
'dda'
|
search_engine
|
str
|
Target search engine. Determines FASTA export format:
|
'sage'
|
database
|
DatabaseConfig
|
Reference database sources (target + variant + contaminant + entrapment). |
DatabaseConfig()
|
sequence_quality
|
SequenceQualityConfig
|
Protein sequence quality filters (optional, all off by default). |
SequenceQualityConfig()
|
peptide_evidence
|
PeptideEvidenceConfig
|
Peptide evidence filtering parameters. |
PeptideEvidenceConfig()
|
complexity
|
ComplexityConfig
|
Sample complexity estimation (optional). |
ComplexityConfig()
|
inference
|
InferenceConfig
|
Protein inference strategy configuration. |
InferenceConfig()
|
entrapment
|
EntrapmentConfig
|
Entrapment database for FDR validation (optional). |
EntrapmentConfig()
|
clustering
|
ClusteringConfig
|
MMseqs2 clustering parameters. |
ClusteringConfig()
|
output
|
OutputConfig
|
Output directory and format options. |
OutputConfig()
|
rust
|
RustConfig
|
Rust binary paths and thread configuration. |
RustConfig()
|
Source code in fasta_lake/config.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
__post_init__
#
Normalize and validate acquisition and search-engine names.
Source code in fasta_lake/config.py
validate
#
Validate that required fields are set and paths are sensible.
Source code in fasta_lake/config.py
get_sources_by_type
#
get_sources_by_type(source_type: str) -> list[DatabaseSource]
has_entrapment
#
Check if entrapment is configured (via config or source tags).
has_variants
#
normalize_stage
#
Map an accepted spelling onto a canonical stage name.
Raises ValueError on anything unrecognised -- the stage determines what a
number means and is never guessed.
Source code in fasta_lake/entrapment_stages.py
load_config
#
load_config(config_path: str | Path) -> FastaLakeConfig
Load a FASTA Lake configuration from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str or Path
|
Path to JSON configuration file. |
required |
Returns:
| Type | Description |
|---|---|
FastaLakeConfig
|
Parsed and validated configuration. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If config file does not exist. |
JSONDecodeError
|
If config file is not valid JSON. |
Source code in fasta_lake/config.py
create_example_config
#
Generate an example JSON configuration string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Template type: |
'full'
|
Returns:
| Type | Description |
|---|---|
str
|
JSON configuration string. |
Source code in fasta_lake/config.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 | |