Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed the get_ext file extension returning logic. #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions gdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import requests

GDC_API_BASE = 'https://api.gdc.cancer.gov'
_SUPPORTED_FILE_TYPES = {'txt', 'vcf', 'bam', 'tsv', 'xml', 'maf', 'xlsx',
_RECOGNIZED_FILE_TYPES = {'txt', 'vcf', 'bam', 'tsv', 'xml', 'maf', 'xlsx',
'tar', 'gz', 'md5', 'xls'}
_SUPPORTED_DATASETS = [
{'data_type': 'Copy Number Segment'},
Expand Down Expand Up @@ -260,11 +260,14 @@ def get_ext(file_name):
"""

# https://github.com/broadinstitute/gdctools/blob/master/gdctools/lib/meta.py
name_list = file_name.split('.')
for i in range(len(name_list)):
if name_list[i] in _SUPPORTED_FILE_TYPES:
break
return '.'.join(name_list[i:])
return_list = []
ext_list = file_name[file_name.find(".") + 1:len(file_name)].split(".")
for ext in ext_list:
if ext in _RECOGNIZED_FILE_TYPES:
return_list.append(ext)
if len(return_list) > 0:
return ".".join(return_list)
return ext_list[-1]


def mkdir_p(dir_name):
Expand Down