-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate download for FASTA files via NCBI virus (#640)
* Separate download for FASTA files via NCBI virus * clean up imports * Separate sequence chunks for SARS2 Genbank workflow * Fix typo * Another typo * remove unused arg for chunk_data * Remove old metadata concat code * Migrate flu genbank workflow * Move status output to trigger redownloads of sequences every day * Retry downloads if they fail for whatever reason * Fix placeholder scrape date limit * Fix for mangled submission date formats * Fix typo in script name * Sequence quality for flu genbank workflow * Sequence quality for RSV workflow
- Loading branch information
Showing
20 changed files
with
1,034 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,9 +128,10 @@ | |
import argparse | ||
import requests | ||
|
||
RETRY_ATTEMPTS = 5 | ||
|
||
def main(): | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--start-time", | ||
|
@@ -218,7 +219,7 @@ def main(): | |
("authors", "Authors_csv"), | ||
# Authors_ss - array of authors | ||
("publications", "PubMed_csv"), | ||
("sequence", "Nucleotide_seq"), | ||
# ("sequence", "Nucleotide_seq"), | ||
# FastaMD5_s - MD5 of sequence | ||
# BioProjectCount_i - number of BioProjects | ||
# BioProject_csv - list of BioProjects - csv | ||
|
@@ -239,8 +240,22 @@ def main(): | |
"User-Agent": "https://github.com/vector-engineering/covid-cg ([email protected])", | ||
} | ||
|
||
response = requests.get(endpoint, params=params, headers=headers, stream=True) | ||
response.raise_for_status() | ||
for _ in range(RETRY_ATTEMPTS): | ||
try: | ||
response = requests.get( | ||
endpoint, params=params, headers=headers, stream=True | ||
) | ||
response.raise_for_status() | ||
break | ||
except requests.exceptions.RequestException as e: | ||
print(f"Error downloading metadata: {e}") | ||
|
||
if _ == RETRY_ATTEMPTS - 1: | ||
raise Exception( | ||
f"Failed to download metadata after {RETRY_ATTEMPTS} attempts" | ||
) | ||
else: | ||
print(f"Retrying download...") | ||
|
||
response_content = response.iter_content(chunk_size=1024, decode_unicode=True) | ||
|
||
|
Oops, something went wrong.