"""JCI Insight 2025, doi 10.1172/jci.insight.177373 (GSE293860; the link between the GEO record and the paper is by identical title only):
sorted CD4 T cells (comp = CD4), 10x, bladder cancer patients and healthy donors. Only the blood samples are loaded: the tumour and normal
tissue files are the same cells as Oh 2020 and are skipped. The three healthy-blood files hold every cell twice (same barcode and TCR), so cells
are deduplicated on Sample_ID + cell.barcode; these healthy cells are also in Oh 2020, which is not loaded for blood, so they appear once.
Donor = `patient` (h1 to h3 are the healthy replicates; whether they are three individuals or replicates of fewer is not stated, kept as given).
`treatment`: atezo (blood after anti-PD-L1, sample name 'post'), pre (before anti-PD-L1), healthy; soc (patients Chemo, Untreated A and B)
is kept as the raw label because its meaning is not stated in the files. No antigen specificity."""
import pandas as pd
from atlas import SRC, clones


def parse():
    d = pd.concat([pd.read_csv(f) for f in sorted((SRC / "Kwek2025/GSE293860_cd4_gex_tcr").glob("*blood*_gex_tcr.csv.gz"))])
    d = d[d.tissue.eq("blood") & d.comp.eq("CD4")].drop_duplicates(["Sample_ID", "cell.barcode"])
    d = d.rename(columns={"alphaCDR3": "CDR3a", "alphaVGene": "TRAV", "alphaJGene": "TRAJ", "betaCDR3": "CDR3b", "betaVGene": "TRBV", "betaJGene": "TRBJ", "patient": "donor"})
    lab = {"atezo": "after anti-PD-L1 (sample 'post')", "pre": "before anti-PD-L1 (sample 'pre')", "healthy": "healthy donor", "soc": "treatment label 'soc' (meaning not stated)"}
    d["context"] = "bladder cancer cohort, blood CD4, " + d.treatment.map(lab)
    d = clones(d, ["donor", "context"])
    return d.assign(source="Kwek 2025 (JCI Insight)", study="GEO:GSE293860", species="human", cd4_evidence="sorted CD4+", specificity_evidence="none", annotation_level="none")
