|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 |
|
| 3 | +import copy |
| 4 | +import re |
| 5 | +import urllib.request |
| 6 | +import zipfile |
3 | 7 | # |
4 | 8 | # pyard pyARD |
5 | 9 | # Copyright (c) 2018 Be The Match operated by National Marrow Donor Program. All Rights Reserved. |
|
21 | 25 | # > http://www.fsf.org/licensing/licenses/lgpl.html |
22 | 26 | # > http://www.opensource.org/licenses/lgpl-license.php |
23 | 27 | # |
24 | | -import os |
25 | | -import string |
26 | | -import random as r |
27 | 28 | from datetime import datetime, date |
28 | | -from six import integer_types, iteritems |
| 29 | + |
29 | 30 | import pandas as pd |
30 | | -import copy |
31 | | -import http.client |
32 | | -import pickle |
33 | | -import urllib.request |
34 | | -import zipfile |
35 | | -import re |
| 31 | +from six import integer_types, iteritems |
36 | 32 |
|
37 | 33 |
|
38 | | -# def all_macs(csv_file, url='hml.nmdp.org'): |
39 | | -# # conn = http.client.HTTPSConnection(url, 443) |
40 | | -# # conn.putrequest('GET', '/mac/api/codes') |
41 | | -# # conn.endheaders() |
42 | | -# # response = conn.getresponse().read().decode('utf8').splitlines() |
43 | | -# data = [l.split("\t")[1:3] for l in response] |
44 | | -# urllib.request.urlretrieve(url, 'numeric.v3.zip') |
45 | | -# df = pd.DataFrame(data, columns=['Code','Alleles']) |
46 | | -# df.to_csv(csv_file, header=True, index=False) |
47 | | -# df['Alleles'] = df['Alleles'].apply(lambda x: x.split("/")) |
48 | | -# mac_dict = df.set_index("Code").to_dict('index') |
49 | | -# return mac_dict |
50 | | - |
51 | | -def all_macs(csv_file, url='https://hml.nmdp.org/mac/files/numer.v3.zip', data_dir=os.path.dirname(__file__)): |
| 34 | +def all_macs(csv_file, data_dir, url='https://hml.nmdp.org/mac/files/numer.v3.zip'): |
52 | 35 | urllib.request.urlretrieve(url, 'numeric.v3.zip') |
53 | 36 | zip_ref = zipfile.ZipFile('numeric.v3.zip', 'r') |
54 | 37 | zip_ref.extractall(data_dir) |
|
0 commit comments