<jupyter_start><jupyter_text>DriverDB_v3<jupyter_code>from typing import List

import pandas as pd
DATA_PATH = "mutation_download_tab.txt"
driver_data = pd.read_csv(DATA_PATH, sep="\t")
driver_data
def get_genes(cancer_type, data, tool=None) -> List[str]:
    if tool is None:
        if cancer_type == "all":
            genes = set(data["driver_gene"].apply(lambda x: [gene.strip() for gene in x.split(",")]).explode())
        else:
            data_filtered = data[data["cancer_type_abbr"] == cancer_type].copy()
            genes = set(data_filtered["driver_gene"].apply(lambda x: [gene.strip() for gene in x.split(",")]).explode())

    else:
        assert tool in list(driver_data["tool"].unique())
        data_tool = data[data["tool"] == tool]
        if cancer_type == "all":
            genes = set(data_tool["driver_gene"].apply(lambda x: [gene.strip() for gene in x.split(",")]).explode())
        else:
            data_filtered = data_tool[data_tool["cancer_type_abbr"] == cancer_type].copy()
            genes = set(data_filtered["driver_gene"].apply(lambda x: [gene.strip() for gene in x.split(",")]).explode())

    return sorted(genes)
brca_genes = get_genes("BRCA", driver_data)
len(brca_genes)
all_genes = get_genes("all", driver_data)
len(all_genes)<jupyter_output><empty_output><jupyter_text>**dawnrank**<jupyter_code>brca_genes_dawnrank = get_genes("BRCA", driver_data, "dawnrank")
len(brca_genes_dawnrank)
all_genes_dawnrank = get_genes("all", driver_data, "dawnrank")
len(all_genes_dawnrank)<jupyter_output><empty_output><jupyter_text>**drivernet**<jupyter_code>brca_genes_drivernet = get_genes("BRCA", driver_data, "drivernet")
print(len(brca_genes_drivernet))

all_genes_drivernet = get_genes("all", driver_data, "drivernet")
len(all_genes_drivernet)<jupyter_output>119<jupyter_text>**Mutex**<jupyter_code>brca_genes_mutex = get_genes("BRCA", driver_data, "mutex")
print(len(brca_genes_mutex))

all_genes_mutex = get_genes("all", driver_data, "mutex")
len(all_genes_mutex)<jupyter_output>18<jupyter_text>Extracting the genes<jupyter_code>from datetime import datetime
def extract_genes(genes: List, cancer_type):
    file_date = datetime.today().strftime('%Y-%m-%d')
    file_name = f"{cancer_type}_genes_{file_date}.txt"
    with open(file_name, "w") as file:
        for gene in genes:
            file.write(f"{gene}\n")

    print(f"{cancer_type} genes are extracted successfully.")

extract_genes(all_genes, "all")
extract_genes(brca_genes, "BRCA")
extract_genes(all_genes_dawnrank, "all_dawnrank")
extract_genes(brca_genes_dawnrank, "BRCA_dawnrank")
extract_genes(all_genes_drivernet, "all_drivernet")
extract_genes(brca_genes_drivernet, "BRCA_drivernet")
extract_genes(all_genes_mutex, "all_mutex")
extract_genes(brca_genes_mutex, "BRCA_mutex")<jupyter_output>all_mutex genes are extracted successfully.
BRCA_mutex genes are extracted successfully.
{'fraction_non_alphanumeric': 0.1407766990291262, 'fraction_numerical': 0.0020804438280166435, 'mean_word_length': 6.2125, 'pattern_counts': {'":': 2, '<': 18, '<?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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '613106', 'license': 'MIT', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1016, 'n_words': 167, 'path': 'data/driver_db_v3_genes/see.ipynb', 'repo_name': 'ibrahimberb/Predicting-Mutation-Effects', 'size': '2884'}