-
Notifications
You must be signed in to change notification settings - Fork 1
MRG: fix gbsketch NCBI downloads by using dehydrate-rehydrate approach
#222
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
Merged
Conversation
This file contains hidden or 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
gbsketch NCBI downloads by using dehydrate-rehydrate approach
gbsketch NCBI downloads by using dehydrate-rehydrate approachgbsketch NCBI downloads by using dehydrate-rehydrate approach
gbsketch NCBI downloads by using dehydrate-rehydrate approachgbsketch NCBI downloads by using dehydrate-rehydrate approach
|
@ctb ready for review! Should make |
ctb
approved these changes
Apr 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, that's a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes:
NCBI may block IP address due to gbsketch #215
ideas for improving retrieval through NCBI REST API #216
suggestion: name output .zip files from batches
.sig.zipinstead of.zip#191more output desired #174
gbsketchnow uses the dehydrate -> rehydrate approach. It first uses the NCBI API to download "dehydrated" file containing direct fetch links for all accessions. Then, we proceed to download gzipped FASTAs from fetch links, checking that downloads execute properly along the way.Since it is not possible to get the gzipped md5sums from the dehydrated file, for gbsketch only we switch to relying on internal checksums (crc32) in the gz files, which are automatically checked by needletail as we process the file. To make sure we retry if something fails, I've moved the file parsing inside of the retry logic. This means that if needletail encounters an error with the file, we retry up to the number of max retries, logging the final error if it does not succeed. Unfortunately since needletail is sync, we still need to download all data for a given file, THEN parse to write/sketch (i.e. we cannot parse while streaming).
Since we are using direct download links, we can enable a much larger number of simultaneous downloads. Here I've enabled 1-30, following the max used by the NCBI datasets application. I've set the new default for both
gbsketchandurlsketchto 10, since limiting to 3 before was not actually necessary.For missing protein files (files where NCBI does not have a download fetch link because they do not exist), we now write empty URLs in the failures file. To continue to allow running
urlsketchfrom agbsketchfailures file, I've added--forcetourlsketchto skip past entries with empty URLs. However, since we can re-rungbsketchfrom thegbsketchfailure file, that is the preferred/recommended approach.Notes:
final fixes/clean up:
async_write_sigs_to_zip)*.sig.zipbatched outputs + restart. Batches will be:filename.N.sig.zip--verboseoption to report for every accessionFuture: if getting the dehydrated file takes a while for large databases, we may want to consider writing an intermediate file with the download links to prevent needing to get the fetch links twice. see #228.