Prevent PLINK filename collisions by hashing content-affecting selection parameters#1114
Open
rehanxt5 wants to merge 1 commit intomalariagen:masterfrom
Open
Prevent PLINK filename collisions by hashing content-affecting selection parameters#1114rehanxt5 wants to merge 1 commit intomalariagen:masterfrom
rehanxt5 wants to merge 1 commit intomalariagen:masterfrom
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
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.
Issue Summary
biallelic_snps_to_plinkgenerates a filename prefix from a subset of arguments (region and SNP filtering parameters), while other arguments that also change exported content were excluded from the path. This could cause two semantically different export requests to resolve to the same .bed/.bim/.fam prefix and overwrite or reuse incorrect files.Proposed solution
Include a deterministic hash in the PLINK filename prefix derived from the parameters that affect output content but are not suitable to place directly in filenames.
sample_sets,sample_queryetc)_hash_params()utility.This keeps filenames short while preventing collisions from distinct sample-selection inputs.
Implementation
biallelic_snps_to_plink()into_plink.pyto hash excluded parameters and append the 8-character suffix to the filename.test_plink_converter.pyto use the returned file prefix frombiallelic_snps_to_plink()rather than reconstructing the filename pattern, ensuring tests validate the actual behavior.Why hashing is preferable
sample_setscan be long lists.sample_queryandsample_query_optionscan contain arbitrary expressions and structured values._hash_params()for deterministic parameter hashing, so this follows an existing internal pattern.Proposed filename change
Current style:
Proposed style:
Validation
Compatibility note
This will change the output filenames generated by these methods. That is intentional, because the current naming scheme can alias distinct exports to the same path.
closes #1113