diff options
| author | pi coding agent <pi@localhost> | 2026-11-05 20:09:55 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-11-05 14:16:31 -0600 |
| commit | e4ffb00d2f505ba11ec175ada2c85288d80a6050 (patch) | |
| tree | a3af3dd9bd82e7ac26db04ba09390d1b6eb9d799 /uploader/genotypes | |
| parent | be5137651f46fe2d0fd649993efa0fe69b386ec3 (diff) | |
| download | gn-uploader-e4ffb00d2f505ba11ec175ada2c85288d80a6050.tar.gz | |
Unify missing-value symbol parsing in r_qtl.utils
Move `parse_missing_values_symbols` from the genotypes views into `r_qtl.utils` and use it in the genotypes Stage 01 collector config and the phenotypes individual-file uploads, replacing their divergent inline splits with the more robust whitespace/comma parsing. Move the tests to `tests/r_qtl/test_utils.py`.
Diffstat (limited to 'uploader/genotypes')
| -rw-r--r-- | uploader/genotypes/collector_config.py | 5 | ||||
| -rw-r--r-- | uploader/genotypes/views.py | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/uploader/genotypes/collector_config.py b/uploader/genotypes/collector_config.py index d7c8fa6..776dcc8 100644 --- a/uploader/genotypes/collector_config.py +++ b/uploader/genotypes/collector_config.py @@ -3,6 +3,8 @@ import sys from pathlib import Path from typing import Any, Mapping +from r_qtl.utils import parse_missing_values_symbols + def from_form(form: Mapping[str, str]) -> dict: """Build the statistics collector's config from the upload form. @@ -18,7 +20,8 @@ def from_form(form: Mapping[str, str]) -> dict: "mb": form.get("megabases_field", "Mb"), "separator": form.get("file-separator", ","), "comment.char": form.get("file-comment-char", "#"), - "na_strings": form.get("file-na", "- NA N/A").split(), + "na_strings": parse_missing_values_symbols( + form.get("file-na", "- NA N/A")), "transposed": (form.get("transposed") or "off") == "on", } diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index fcae9b0..2154330 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -33,6 +33,8 @@ from uploader.monadic_requests import make_either_error_handler from uploader.population.models import population_by_species_and_id from uploader.request_checks import with_dataset, with_population +from r_qtl.utils import parse_missing_values_symbols + from . import collector_config from . import collector_job @@ -48,11 +50,6 @@ genotypesbp = Blueprint("genotypes", __name__) render_template = make_template_renderer("genotypes") -def parse_missing_values_symbols(value: str) -> list[str]: - """Parse a whitespace- and/or comma-separated list of unique symbols.""" - return list(dict.fromkeys(value.replace(",", " ").split())) - - def collect_genotype_stats_success_handler(job): """Proceed to the study design/encoding stage.""" return redirect(url_for( |
