Skip to content

Fix parse_ml_filename() misparsing year/country-stratified filenames - #34

Open
eboyer221 wants to merge 1 commit into
mainfrom
dev-parse-ml-filename-stratified
Open

Fix parse_ml_filename() misparsing year/country-stratified filenames#34
eboyer221 wants to merge 1 commit into
mainfrom
dev-parse-ml-filename-stratified

Conversation

@eboyer221

Copy link
Copy Markdown
Contributor

##Description
parse_ml_filename() in R/merge_ml_results.R expected the stratification token (year/country) to appear after the drug value in a filename, but the actual filenames written by the matrix-generation code place it before the drug value (e.g. Csp_drug_year_AMX_2010-2015_genes_binary_year_42_performance.tsv). This caused stratified filenames to be parsed with the wrong drug and a missing seed, with no error.

Why it matters

parse_ml_filename() is exported and documented as supporting stratified filenames, so any code parsing a stratified result filename with it gets silently wrong metadata.

Fix

Reordered the token-parsing logic so the strat label is read immediately after drug/drug_class, before the drug value, matching the grammar already used by buildPerfPqYearCountry().

Testing

Added tests/testthat/test-merge-ml-results.R covering: unstratified drug, unstratified drug_class, shuffled, year-stratified drug, and country-stratified drug_class filenames. Full suite passes (230/230).

Found while reviewing #32. Resolves PR1) of Issue #33.

…t filenames, not after the drug value so there was mislabeling. Corrected the token order to match was regex expects, and added regression tests for the stratified and unstratified cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant