|
35 | 35 | from functools import partial |
36 | 36 | from typing import Dict |
37 | 37 | import logging |
| 38 | +import pathlib |
38 | 39 |
|
39 | 40 | ismac = lambda x: True if re.search(":\D+", x) else False |
40 | 41 |
|
@@ -79,7 +80,8 @@ class ARD(object): |
79 | 80 | def __init__(self, dbversion: str='Latest', |
80 | 81 | download_mac: bool=True, |
81 | 82 | verbose: bool=False, |
82 | | - remove_invalid: bool=True): |
| 83 | + remove_invalid: bool=True, |
| 84 | + data_dir: str=None): |
83 | 85 | """ |
84 | 86 | ARD - |
85 | 87 | :param dbversion: |
@@ -117,14 +119,20 @@ def __init__(self, dbversion: str='Latest', |
117 | 119 |
|
118 | 120 | # List of expression characters |
119 | 121 | expre_chars = ['N', 'Q', 'L', 'S'] |
120 | | - data_dir = os.path.dirname(__file__) |
121 | | - ars_url = 'https://raw.githubusercontent.com/ANHIG/IMGTHLA/' \ |
122 | | - + dbversion + '/wmda/hla_nom_g.txt' |
| 122 | + |
| 123 | + # Set data directory where all the downloaded files will go |
| 124 | + if data_dir is None: |
| 125 | + data_dir = os.path.dirname(__file__) |
| 126 | + else: |
| 127 | + pathlib.Path(data_dir).mkdir(exist_ok=True) |
| 128 | + |
| 129 | + imgt_hla_url = 'https://raw.githubusercontent.com/ANHIG/IMGTHLA/' |
| 130 | + ars_url = imgt_hla_url + dbversion + '/wmda/hla_nom_g.txt' |
123 | 131 | ars_file = data_dir + '/hla_nom_g.' + str(dbversion) + ".txt" |
124 | 132 | allele_file = data_dir + '/AlleleList.' + str(dbversion) + ".txt" |
125 | 133 | mac_file = data_dir + "/mac.txt" |
126 | 134 | mac_pickle = data_dir + "/mac.pickle" |
127 | | - broad_file = data_dir + "/dna_relshp.csv" |
| 135 | + broad_file = os.path.dirname(__file__) + "/dna_relshp.csv" |
128 | 136 | #print("mac_file:", mac_file) |
129 | 137 |
|
130 | 138 | allele_url = "https://raw.githubusercontent.com/ANHIG/IMGTHLA/" \ |
|
0 commit comments