def _pdc_download(dataset, version, redownload):
    'Download data for the specified cancer type from the PDC.'
    dataset = str.lower(dataset)
    if (dataset == 'pdcall'):
        overall_result = True
        for dataset in STUDY_IDS_MAP.keys():
            if (not pdc_download(dataset, version, redownload)):
                overall_result = False
        return overall_result
    if (not dataset.startswith('pdc')):
        raise InvalidParameterError(f"pdc_download function can only be used for PDC datasets, which start with the prefix 'pdc'. You tried to download '{dataset}'.")
    if (dataset not in STUDY_IDS_MAP.keys()):
        raise InvalidParameterError(f'''PDC dataset must be one of the following:
{list(STUDY_IDS_MAP.keys())}
You passed '{dataset}'.''')
    dataset_ids = STUDY_IDS_MAP[dataset]
    path_here = os.path.abspath(os.path.dirname(__file__))
    cancer_dir = os.path.join(path_here, f'data_{dataset}')
    if os.path.isdir(cancer_dir):
        index_path = os.path.join(cancer_dir, 'index.txt')
        if (not os.path.isfile(index_path)):
            redownload = True
        else:
            with open(index_path, 'r') as index_file:
                first_line = index_file.readline()
            if first_line.startswith('#0.0'):
                redownload = True
        if redownload:
            shutil.rmtree(cancer_dir)
        else:
            return True
    os.mkdir(cancer_dir)
    data_dir = os.path.join(cancer_dir, f'{dataset}_v1.0')
    os.mkdir(data_dir)
    master_clin = pd.DataFrame()
    for data_type in dataset_ids.keys():
        download_msg = f'Downloading {dataset} {data_type} files...'
        print(download_msg, end='\r')
        (clin, quant) = download_pdc_id(dataset_ids[data_type], _download_msg=False)
        print((' ' * len(download_msg)), end='\r')
        save_msg = f'Saving {dataset} {data_type} files...'
        print(save_msg, end='\r')
        master_clin = master_clin.append(clin)
        quant.to_csv(os.path.join(data_dir, f'{data_type}.tsv.gz'), sep='\t')
        print((' ' * len(save_msg)), end='\r')
    save_msg = f'Saving {dataset} clinical file...'
    print(save_msg, end='\r')
    master_clin = master_clin.drop_duplicates(keep='first')
    master_clin.to_csv(os.path.join(data_dir, 'clinical.tsv.gz'), sep='\t')
    index_path = os.path.join(cancer_dir, 'index.txt')
    with open(index_path, 'w') as index_file:
        index_file.write('#1.0\n')
    print((' ' * len(save_msg)), end='\r')
    return True
Download data for the specified cancer type from the PDC.
def _pdc_download(dataset, version, redownload):
    
    dataset = str.lower(dataset)
    if (dataset == 'pdcall'):
        overall_result = True
        for dataset in STUDY_IDS_MAP.keys():
            if (not pdc_download(dataset, version, redownload)):
                overall_result = False
        return overall_result
    if (not dataset.startswith('pdc')):
        raise InvalidParameterError(f"pdc_download function can only be used for PDC datasets, which start with the prefix 'pdc'. You tried to download '{dataset}'.")
    if (dataset not in STUDY_IDS_MAP.keys()):
        raise InvalidParameterError(f'PDC dataset must be one of the following:
{list(STUDY_IDS_MAP.keys())}
You passed '{dataset}'.')
    dataset_ids = STUDY_IDS_MAP[dataset]
    path_here = os.path.abspath(os.path.dirname(__file__))
    cancer_dir = os.path.join(path_here, f'data_{dataset}')
    if os.path.isdir(cancer_dir):
        index_path = os.path.join(cancer_dir, 'index.txt')
        if (not os.path.isfile(index_path)):
            redownload = True
        else:
            with open(index_path, 'r') as index_file:
                first_line = index_file.readline()
            if first_line.startswith('#0.0'):
                redownload = True
        if redownload:
            shutil.rmtree(cancer_dir)
        else:
            return True
    os.mkdir(cancer_dir)
    data_dir = os.path.join(cancer_dir, f'{dataset}_v1.0')
    os.mkdir(data_dir)
    master_clin = pd.DataFrame()
    for data_type in dataset_ids.keys():
        download_msg = f'Downloading {dataset} {data_type} files...'
        print(download_msg, end='\r')
        (clin, quant) = download_pdc_id(dataset_ids[data_type], _download_msg=False)
        print((' ' * len(download_msg)), end='\r')
        save_msg = f'Saving {dataset} {data_type} files...'
        print(save_msg, end='\r')
        master_clin = master_clin.append(clin)
        quant.to_csv(os.path.join(data_dir, f'{data_type}.tsv.gz'), sep='\t')
        print((' ' * len(save_msg)), end='\r')
    save_msg = f'Saving {dataset} clinical file...'
    print(save_msg, end='\r')
    master_clin = master_clin.drop_duplicates(keep='first')
    master_clin.to_csv(os.path.join(data_dir, 'clinical.tsv.gz'), sep='\t')
    index_path = os.path.join(cancer_dir, 'index.txt')
    with open(index_path, 'w') as index_file:
        index_file.write('#1.0\n')
    print((' ' * len(save_msg)), end='\r')
    return True