"""Hum Immunol 2002, doi 10.1016/S0198-8859(02)00406-8: Table 2, two TCR beta clonotypes of one atopic dermatitis patient found both in
the skin lesion and among PBMC T cells expanded with D. pteronyssinus antigen. Beta chain only; CD4 is NOT established in the paper
(bulk T cells), loaded because mite-reactive human TCRs are rare. The first CDR3 is printed incomplete (no leading C, J end missing):
the printed residues are kept as CDR3b and no core is derived beyond them. BV and BJ names are the 2002 nomenclature."""
import pandas as pd
from atlas import SRC


def parse():
    t = pd.read_csv(SRC / "Takahama2002/derived/takahama2002_table2.csv")
    whole = t.aa_printed.str.startswith("C")
    return pd.DataFrame({"source": "Takahama 2002 (Hum Immunol)", "study": "doi:10.1016/S0198-8859(02)00406-8", "species": "human",
                         "cd4_evidence": "not established (bulk T cells expanded with antigen)", "TRBV": t.TCRBV_printed + " (2002 name)", "TRBJ": t.TCRBJ_printed + " (2002 name)",
                         "CDR3b": t.aa_printed, "cdr3b_core": t.aa_printed.where(~whole),
                         "antigen": "house dust mite extract (D. pteronyssinus)", "organism": "Dermatophagoides pteronyssinus",
                         "context": "atopic dermatitis, clonotype in skin lesion and in mite-stimulated PBMC" + (~whole).map({True: "; CDR3 printed incomplete", False: ""}),
                         "specificity_evidence": "clonal expansion after 14 days culture with mite antigen (SSCP), same sequence in skin",
                         "annotation_level": "antigen", "donor": "patient " + t.patient.astype(str), "cells": None})
