"""Nat Commun 2025, doi 10.1038/s41467-025-56363-2 (GSE269661): autoimmune hepatitis, 4 patients (V1-V4 = Sample 1-4 of the series matrix), blood PD-1+ CD45RA- CXCR5- memory CD4 T cells,
10x 5' TCR libraries (the GEO record labels the samples "PBMCs", the paper states the PD-1+ CXCR5- memory CD4 sort for the 10x experiment). Filtered contig annotations; filter is_cell,
high_confidence, productive; top-UMI TRA and TRB per cell. The `_clonotypes` files are not used (same cells). No antigen: the paper infers autoreactivity from clonal sharing with the liver,
which needs the liver TCR data that is not in these files, so no per-clonotype liver-match flag is available."""
import pandas as pd
from atlas import SRC, clones, pair_contigs


def parse():
    out = []
    for f in sorted((SRC / "Cardon2025").glob("*_V?_filtered_contig_annotations.csv.gz")):
        c = pd.read_csv(f)
        c = c[c.is_cell & c.high_confidence & c.productive]
        d = pair_contigs(c, ["barcode"])
        d["donor"] = f.name.split("_")[1]
        out.append(d)
    d = clones(pd.concat(out), ["donor"], context="autoimmune hepatitis patient, blood PD-1+ CD45RA- CXCR5- memory CD4+ T cell")
    return d.assign(source="Cardon 2025 (Nat Commun)", study="doi:10.1038/s41467-025-56363-2", species="human", cd4_evidence="sorted CD4+ memory",
                    specificity_evidence="none", annotation_level="none")
