fasta_lake.provenance#
fasta_lake.provenance
#
Per-protein provenance (v5.1).
Writes a JSONL sidecar alongside each per-sample FASTA. One line per selected protein, with enough metadata to answer:
- Which de novo peptides admitted this protein?
- What are their scores?
- Was this protein k-mer rescued or exact-matched?
- How many peptides support it?
- Which inference strategy selected it?
Output format: {sample_id}_{strategy}_provenance.jsonl
Each line: {"protein_id": "sp|P04637|P53_HUMAN", "n_peptides": 3, "peptides": ["MEEPQSDPSVEPPLSQ", "ETPPLGE...", ...], "scores": [0.97, 0.88, 0.85], "mean_score": 0.90, "best_score": 0.97, "admission": "exact", # "exact" | "kmer_rescue" "strategy": "species_budget", "contaminant": false}
Compact, grep-able, line-per-protein.
write_provenance
#
write_provenance(out_path: Path, selected_proteins: set[str], prot2pep: dict[str, set[str]], peptide_scores: dict[str, float], strategy: str, kmer_rescued_proteins: set[str] | None = None) -> int
Write per-protein provenance sidecar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_path
|
Path
|
Output JSONL file. |
required |
selected_proteins
|
set[str]
|
Protein IDs in the final inference output. |
required |
prot2pep
|
dict[str, set[str]]
|
Protein -> peptides mapping (I/L-normalized peptides). |
required |
peptide_scores
|
dict[str, float]
|
Peptide -> score (I/L-normalized keys). |
required |
strategy
|
str
|
Inference strategy name. |
required |
kmer_rescued_proteins
|
set[str] or None
|
Proteins added by k-mer rescue. If None, assumes none. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of provenance records written. |
Source code in fasta_lake/provenance.py
summarise_provenance
#
Aggregate a provenance JSONL into summary counts.
Useful for reports.