diff options
| author | pi coding agent <pi@localhost> | 2026-11-05 19:19:34 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-11-05 13:36:22 -0600 |
| commit | be5137651f46fe2d0fd649993efa0fe69b386ec3 (patch) | |
| tree | 1e82ae5b0656441662eeab51a02dd51a04283e72 | |
| parent | a2edcd3ea33acd5e254c6c449e712adbbe9bd7a8 (diff) | |
| download | gn-uploader-be5137651f46fe2d0fd649993efa0fe69b386ec3.tar.gz | |
Add missing-value symbols to Stage 02
Add a missing-value symbol(s) input to the Stage 02 encoding form and a `parse_missing_values_symbols` helper in the genotypes views. Parse the input (whitespace/comma-separated, unique symbols) and store it in the collector job's `stage02` metadata alongside the description and encoding; prefill the input when the page is revisited.
| -rw-r--r-- | uploader/genotypes/views.py | 13 | ||||
| -rw-r--r-- | uploader/templates/genotypes/genotype-encoding-elements.html | 17 | ||||
| -rw-r--r-- | uploader/templates/genotypes/study-design.html | 1 |
3 files changed, 29 insertions, 2 deletions
diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 9bc7fbf..fcae9b0 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -48,6 +48,11 @@ 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( @@ -106,7 +111,9 @@ def study_design(# pylint: disable=[unused-argument] "study_design": request.form.get("study_design", ""), "geno_encoding": { _key: request.form.get(f"geno_encoding_{_key}", "") - for _key in ("mat", "pat", "het")} + for _key in ("mat", "pat", "het")}, + "missing_symbols": parse_missing_values_symbols( + request.form.get("missing_symbols", "")) } gnlibs_jobs.update_metadata( conn, job_id, "stage02", json.dumps(_saved)) @@ -133,7 +140,9 @@ def study_design(# pylint: disable=[unused-argument] "study_design": _saved.get("study_design", ""), "geno_encoding": { _key: _encoding.get(_key, _dot_geno.get(_key, "") or "") - for _key in ("mat", "pat", "het")} + for _key in ("mat", "pat", "het")}, + "missing_symbols": ", ".join( + _saved.get("missing_symbols", []) or []) }) diff --git a/uploader/templates/genotypes/genotype-encoding-elements.html b/uploader/templates/genotypes/genotype-encoding-elements.html index a7cb3c4..2cd4e4a 100644 --- a/uploader/templates/genotypes/genotype-encoding-elements.html +++ b/uploader/templates/genotypes/genotype-encoding-elements.html @@ -74,4 +74,21 @@ both parents. This allele will be mapped to the value 0.</span> </div> </div> + + <div class="form-group"> + <div class="row mb-3"> + <label for="txt-geno-missing-symbols" + class="col-form-label col-sm-2">Missing-value symbol(s)</label> + <div class="col-sm-10"> + <input type="text" + id="txt-geno-missing-symbols" + name="missing_symbols" + value="{{ missing_symbols|default('') }}" + class="form-control" /> + </div> + <span class="form-text text-muted"> + Enter the symbol(s) used in your file to represent missing genotype + values. Separate multiple symbols with spaces or commas.</span> + </div> + </div> </div> diff --git a/uploader/templates/genotypes/study-design.html b/uploader/templates/genotypes/study-design.html index 6eda890..4e11fe7 100644 --- a/uploader/templates/genotypes/study-design.html +++ b/uploader/templates/genotypes/study-design.html @@ -47,6 +47,7 @@ {% set study_design = values.study_design %} {% set geno_encoding = values.geno_encoding %} + {% set missing_symbols = values.missing_symbols %} {%include "genotypes/study-design-elements.html"%} {%include "genotypes/genotype-encoding-elements.html"%} |
