Metadata-Version: 2.4
Name: hitlist
Version: 2.51.0
Summary: Verified, source-preserving evidence for immune and nonimmune training data
Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/pirl-unc/hitlist
Project-URL: Repository, https://github.com/pirl-unc/hitlist
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas[pyarrow]>=3
Requires-Dist: pyarrow
Requires-Dist: numpy>=1.22
Requires-Dist: PyYAML
Requires-Dist: tqdm
Requires-Dist: datacache>=1.27.1
Requires-Dist: orfdata>=0.40.0
Requires-Dist: packaging>=21
Requires-Dist: filelock>=3.13
Requires-Dist: pyensembl
Requires-Dist: mhcgnomes>=3.91.0
Requires-Dist: mhcseqs>=2.14.0
Requires-Dist: oncoref>=1.8.207
Provides-Extra: cta
Provides-Extra: alleles
Provides-Extra: curation
Requires-Dist: openpyxl>=3.1.5; extra == "curation"
Provides-Extra: dev
Requires-Dist: openpyxl>=3.1.5; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: pytest-xdist; extra == "dev"
Requires-Dist: ruff<0.17,>=0.16; extra == "dev"
Dynamic: license-file

# hitlist

Hitlist 2.0 is a verified evidence store for immune and nonimmune training data.
The [evidence store guide](https://github.com/pirl-unc/hitlist/blob/main/docs/evidence-store.md) describes one catalog, query
and recipe API across MHC, T-cell, bulk MS, expression, source claims and lineage.
Assay results, numeric measurements and contextual claims keep their own grains.

[![Tests](https://github.com/pirl-unc/hitlist/actions/workflows/tests.yml/badge.svg)](https://github.com/pirl-unc/hitlist/actions/workflows/tests.yml)
[![PyPI](https://img.shields.io/pypi/v/hitlist.svg)](https://pypi.org/project/hitlist/)

A curated, source-preserving evidence system for model training.

Requires Python 3.11+ and pandas 3+. Hitlist uses pandas' default string dtype
without changing global pandas options. CI checks both pandas 3.0.0 and current
compatible releases.

```python
from hitlist import EvidenceStore

store = EvidenceStore.open("/path/to/verified-evidence-package")
print(store.catalog()["schema_version"])
print(store.query("arm_factor", select=["arm_id", "factor_type", "factor_value"],
                  where={"factor_type": "knockout_genes"}, limit=5).table)
print(store.query("bulk_numeric_measurement",
                  select=["measurement_id", "quantity_scale", "quantitative_value"],
                  where={"quantity_scale": "abundance_percentile"}, limit=5).table)
store.materialize("training-recipe.yaml", "/path/to/training-output")
```

The matching CLI is `hitlist evidence catalog`, `hitlist evidence query`,
`hitlist evidence materialize` and `hitlist evidence verify`. Each command takes
the same package path. Queries expose logical fields when source meaning and
grain match; every physical typed column is also accessible as `native.<column>`.
Related values require named joins, and many-valued relations remain separate
evidence rows. The catalog reports direct, related and unavailable fields,
source scope, row counts and ingest requirements. A recipe writes accepted,
excluded and ambiguous rows with counts, reasons, lineage, contributor keys
and a hash-bound manifest. It never rewrites source evidence.
The reference-augmented package adds source-backed mouse species roles and
exact peptide-to-parent alternatives while retaining every original assay and
numeric cell.

## Start here

- [Original perturbation quantities](https://github.com/pirl-unc/hitlist/blob/main/docs/perturbation-quantities.md):
  same-plex treatment/control reporter signals, source-qualified contrasts and Presto admission boundaries.
- [Evidence store guide](https://github.com/pirl-unc/hitlist/blob/main/docs/evidence-store.md): catalog, grain-safe queries,
  named relationships, recipes and verification.
- [Pinned source and count audit](https://github.com/pirl-unc/hitlist/blob/main/tasks/evidence-store-results/README.md): 53
  materialized evidence types, 32 reconciled baselines and field disposition.
- [Migration history](https://github.com/pirl-unc/hitlist/blob/main/docs/evidence-catalog.md): source generations and
  scientific decisions behind the current package.
- [Purified digestion evidence](https://github.com/pirl-unc/hitlist/blob/main/docs/digestion-evidence.md):
  original MS1, acquisition, substrate and conflict relations with training admission limits.
- [Binding protocol review](https://github.com/pirl-unc/hitlist/blob/main/tasks/binding-assay-context-210-results/README.md):
  source-scoped assay conditions, explicit unknowns, and complete binding-row reconciliation.
- [Legacy 1.x README](https://github.com/pirl-unc/hitlist/blob/main/docs/legacy-1x.md): historical indexes and commands.
  Its sample-level and training-readiness descriptions were superseded by
  the verified corpus audits and should not be used as current labels.

## Breaking release

2.0.0 removes several top-level loaders, exporters and static catalog helpers.
Open a verified package through `EvidenceStore` for current evidence requests;
use the catalog to see each field's actual readiness and required assay fields.
The original source records and typed relation files remain in the verified
evidence package; older module-level APIs remain in the Python distribution
for migration and audit. Training recipes
retain candidate decisions, source contributors and unresolved context, so a
new task does not silently turn evidence into a label.

## Locating the MHC ligand MS table

Starting with Hitlist 2.50.0, new dataset generations store positive MHC
ligand MS observations in `mhc_ligand_ms_observations.parquet`. Each
generation's `.datacache-manifest.json` lists its physical file and SHA-256.
Previous dated generations use `observations.parquet`. Resolve the table
with `hitlist.bundle_path("ms", bundle=directory, must_exist=True)` or
`hitlist path ms` for the active generation. Both versions store one copy.
Readers that construct a filename directly must switch to the resolver
before opening new generations. Frozen evidence packages retain their own
versioned native partition names.

## Querying MS observations

`load_observations` and `load_binding` accept the same filters and column
projections for a local bundle and a verified MHC evidence package. Pass
`package=path` or set `HITLIST_EVIDENCE_PACKAGE`. Gene queries use the
selected source's peptide mappings. Package results carry the manifest SHA-256
in `df.attrs["evidence_package_manifest_sha256"]`. To refresh the local bundle
before querying, call `ensure_observations_built(quiet=True)`.

| Query need | Observation fields |
| --- | --- |
| Peptide and assay | `peptide`, `peptide_modifications`, `has_ptm`, `assay_modality`, `ms_outcome_status`, `is_ms_observation` |
| Study and source | `pmid`, `source`, `assay_iri`, `provenance_id`, `epitope_mutation_raw` |
| MHC restriction | `mhc_class`, `mhc_species`, `mhc_restriction`, `mhc_allele_set`, `mhc_allele_provenance`, `restriction_evidence`, `serotypes`, `serotype_source`, `is_monoallelic` |
| Sample context | `source_tissue`, `cell_line_name`, `cell_type`, `disease`, `src_cancer`, `src_ex_vivo`, `src_cell_line`, `src_healthy_tissue`, `src_healthy_thymus`, `src_healthy_reproductive`, `antigen_expression_mode` |

Use `serotypes` for the ordered semicolon-delimited memberships. The loader
also serves the first membership as `serotype`. The writer retains the singular
field if any source row would lose information. Raw PTM text, reported MHC
class, host species and antigen-source species retain independent meanings.
Antigen expression mode describes the experimental sample. When a sample
index predates this field, rebuild the bundle to populate its curated modes.
Observation queries can recover the reviewed arms from older native row fields.

`find_mutant_ligands("TP53:R175H")` returns measured ligands for a requested
substitution. With no mutations, it searches host-reference mismatches seen in
cancer in at least two PMIDs and excludes peptides observed in healthy
compartments. Each row includes the wild-type sequence, flanks, one-based
protein position, zero-based peptide offset and separate mutant and wild-type
MS counts. A sequence match is a candidate origin. A CEDAR mutation claim
requires an explicit source field. In an older export without that field, an
empty claim gives no information about mutation status.

```sh
hitlist qc mutant-ligands --mutations TP53:R175H,KRAS:G12D
```


### Host protein coordinates

For bundles built with mappings in 2.51.0, `hitlist.host_flanks.load_host_protein_context(peptides, proteome_id="Homo sapiens", bundle=directory)` reads the reference sequence captured by the mapping worker. Each distinct mapped vertebrate protein is stored once in `host_protein_sequences.parquet`. The loader checks its SHA-256 and the peptide at the recorded zero-based position. It reports `reference_status`, nullable N/C terminal flags and `n_mappings`. Older generations expose their mapping coordinates and mark the sequence as unavailable.
