diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/gemma.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/routes/gemma.rs b/src/routes/gemma.rs index 232e965..38f33a4 100644 --- a/src/routes/gemma.rs +++ b/src/routes/gemma.rs @@ -837,6 +837,9 @@ pub(crate) async fn resolve_inputs( }) .unwrap_or_default(); let supplied_values = request.trait_values.clone(); + // Whether the caller named its values: `named` moves into the alignment + // closure below, and the note after it still has to say which it was. + let had_named_values = !named.is_empty(); match (request.genotype_file.clone(), request.snps_file.clone(), group) { (Some(genotype_file), Some(snps_file), None) => { @@ -856,7 +859,15 @@ pub(crate) async fn resolve_inputs( } else { let path = std::path::PathBuf::from(&genotype_file); let aligned = tokio::task::spawn_blocking(move || { - genotypes::align_to_file(&path, &named) + // A `.geno` names its individuals in the header; a BIMBAM + // does not, so its names come from the `.geno` beside it + // (see `names_for_bimbam`). Without that, named values on + // a file request aligned against nothing and every value + // was dropped. + match genotypes::names_for_bimbam(&path) { + Some(names_source) => genotypes::align_to_columns_of(&names_source, &named), + None => genotypes::align_to_file(&path, &named), + } }) .await .map_err(|error| { @@ -873,8 +884,15 @@ pub(crate) async fn resolve_inputs( aligned }; notes.push(format!( - "Genotype: given file and SNP map; {} values used.", - trait_values.iter().filter(|value| value.is_some()).count() + // Name the order the values ended up in, so a caller can check + // it without knowing the file by heart. + "Genotype: given file and SNP map; {} values used{}.", + trait_values.iter().filter(|value| value.is_some()).count(), + if had_named_values { + ", aligned by name onto the genotype file's individuals" + } else { + "" + } )); Ok(ResolvedInputs { individuals: trait_values.len(), |
