|
1 | 1 | import gzip
|
2 | 2 | import os
|
3 | 3 | import shutil
|
4 |
| -import subprocess |
5 | 4 | import tempfile
|
6 | 5 | import urllib
|
7 | 6 |
|
|
50 | 49 | logger = get_logger(__name__)
|
51 | 50 |
|
52 | 51 |
|
53 |
| -def safely_move_to_gcs(tmp_file_name, gcs_tmp_file_name): |
54 |
| - try: |
55 |
| - subprocess.run( |
56 |
| - [ # noqa: S603, S607 |
57 |
| - 'gsutil', |
58 |
| - 'cp', |
59 |
| - tmp_file_name, |
60 |
| - gcs_tmp_file_name, |
61 |
| - ], |
62 |
| - check=True, |
63 |
| - ) |
64 |
| - except subprocess.CalledProcessError: |
65 |
| - logger.exception(f'Failed to move local tmp file {tmp_file_name} to gcs') |
66 |
| - |
67 |
| - |
68 | 52 | def parsed_clnsig(ht: hl.Table):
|
69 | 53 | return (
|
70 | 54 | hl.delimit(ht.info.CLNSIG)
|
@@ -138,13 +122,13 @@ def download_and_import_latest_clinvar_vcf(
|
138 | 122 | ) -> hl.Table:
|
139 | 123 | with tempfile.NamedTemporaryFile(suffix='.vcf.gz', delete=False) as tmp_file:
|
140 | 124 | urllib.request.urlretrieve(clinvar_url, tmp_file.name) # noqa: S310
|
141 |
| - gcs_tmp_file_name = os.path.join( |
| 125 | + cached_tmp_file_name = os.path.join( |
142 | 126 | Env.HAIL_TMP_DIR,
|
143 | 127 | os.path.basename(tmp_file.name),
|
144 | 128 | )
|
145 |
| - safely_move_to_gcs(tmp_file.name, gcs_tmp_file_name) |
| 129 | + hfs.copy(tmp_file.name, cached_tmp_file_name) |
146 | 130 | mt = hl.import_vcf(
|
147 |
| - gcs_tmp_file_name, |
| 131 | + cached_tmp_file_name, |
148 | 132 | reference_genome=reference_genome.value,
|
149 | 133 | drop_samples=True,
|
150 | 134 | skip_invalid_loci=True,
|
@@ -201,13 +185,12 @@ def download_and_import_clinvar_submission_summary() -> hl.Table:
|
201 | 185 | 'wb',
|
202 | 186 | ) as f_out:
|
203 | 187 | shutil.copyfileobj(f_in, f_out)
|
204 |
| - |
205 |
| - gcs_tmp_file_name = os.path.join( |
| 188 | + cached_tmp_file_name = os.path.join( |
206 | 189 | Env.HAIL_TMP_DIR,
|
207 | 190 | os.path.basename(unzipped_tmp_file.name),
|
208 | 191 | )
|
209 |
| - safely_move_to_gcs(unzipped_tmp_file.name, gcs_tmp_file_name) |
210 |
| - return import_submission_table(gcs_tmp_file_name) |
| 192 | + hfs.copy(unzipped_tmp_file.name, cached_tmp_file_name) |
| 193 | + return import_submission_table(cached_tmp_file_name) |
211 | 194 |
|
212 | 195 |
|
213 | 196 | def import_submission_table(file_name: str) -> hl.Table:
|
|
0 commit comments