<jupyter_start><jupyter_text>Creating ApoE Bundles from HGVSHGVS is the de facto standard for manipulating human-readable variation data. This notebook demonstrates the VMC BundleManager, which facilitates translating HGVS expressions to Alleles, Haplotypes, and Genotypes.```                             rs7412                              NC_000019.10:g.44908822                             NM_000041.3:c.526                             C          Trs429358                 C   APOE-ε4    APOE-ε1NC_000019.10:g.44908684  T   APOE-ε3    APOE-ε2NM_000041.3:c.388```<jupyter_code>apoe_alleles = {
    'rs7412C': {'g37': 'NC_000019.9:g.45412079=',
                'g38': 'NC_000019.10:g.44908822=',
                'c': 'NM_000041.3:c.526=',
                'p': 'NP_000032.1:p.Arg176='},
    'rs7412T': {'g37': 'NC_000019.9:g.45412079C>T',
                'g38': 'NC_000019.10:g.44908822C>T',
                'c': 'NM_000041.3:c.526C>T',
                'p': 'NP_000032.1:p.Arg176Cys'},
    'rs429358T': {'g37': 'NC_000019.9:g.45411941=',
                  'g38': 'NC_000019.10:g.44908684=',
                  'c': 'NM_000041.3:c.388=',
                  'p': 'NP_000032.1:p.Cys130='},
    'rs429358C': {'g37': 'NC_000019.9:g.45411941T>C',
                  'g38': 'NC_000019.10:g.44908684T>C',
                  'c': 'NM_000041.3:c.388T>C',
                  'p': 'NP_000032.1:p.Cys130Arg'}
}
apoe_haplotypes = {
    "ε1": ["rs429358C", "rs7412T"],
    "ε2": ["rs429358T", "rs7412T"],
    "ε3": ["rs429358T", "rs7412C"],
    "ε4": ["rs429358C", "rs7412C"],
}
id_function = "serial"   # or: "computed" (default) or "uuid"
from vmc.extra.bundlemanager import BundleManager
bm = BundleManager(id_function=id_function)<jupyter_output><empty_output><jupyter_text>Alleles<jupyter_code>for vname, alleles in apoe_alleles.items():
    for h in alleles.values():
        a = bm.add_hgvs_allele(h)<jupyter_output><empty_output><jupyter_text>Haplotypes<jupyter_code>haplotypes_hgvs = {
    t: {name: [apoe_alleles[vname][t] for vname in vnames] for name, vnames in apoe_haplotypes.items()}
    for t in "g37 g38 c p".split()
}
haplotypes_hgvs
# create protein haplotypes
for t in "g37 g38 c p".split():
    for name, hs in haplotypes_hgvs[t].items():
        h = bm.add_hgvs_haplotype(hs)
for t in "g37 g38 c p".split():
    hht = haplotypes_hgvs[t]
    for h1 in "ε3 ε4".split():
        for h2 in "ε3 ε4".split():
            gt_alleles = (hht[h1], hht[h2])
            g = bm.add_hgvs_genotype(gt_alleles)
bm.as_bundle().as_dict()
bm.as_hgvs()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15321637426900586, 'fraction_numerical': 0.1442495126705653, 'mean_word_length': 2.573816155988858, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '292582', 'license': 'Apache-2.0', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1016, 'n_words': 177, 'path': 'notebooks/archive/02 - BundleManager.ipynb', 'repo_name': 'GenomicMedLab/vrs-python', 'size': '2565'}