@@ -338,6 +338,12 @@ fn render_app_observation_json(input: AppObservationJson) -> serde_json::Value {
338338 } else {
339339 gene
340340 } ;
341+ let canonical_rsid = manifest. spec . rsids . first ( ) . filter ( |rsid| !rsid. is_empty ( ) ) ;
342+ let matched_rsid = row. get ( "matched_rsid" ) . filter ( |rsid| !rsid. is_empty ( ) ) ;
343+ let alias_match_note = matched_rsid
344+ . filter ( |matched| canonical_rsid. is_some_and ( |canonical| canonical != * matched) )
345+ . filter ( |matched| manifest. spec . rsids . iter ( ) . any ( |rsid| rsid == * matched) )
346+ . map ( |matched| format ! ( "matched alias: {matched}" ) ) ;
341347 let source = if source. is_null ( ) {
342348 manifest_default_source ( & row, & manifest)
343349 } else {
@@ -349,7 +355,7 @@ fn render_app_observation_json(input: AppObservationJson) -> serde_json::Value {
349355 "assay_version" : "1.0" ,
350356 "variant_key" : manifest. name,
351357 "variant_path" : row_path,
352- "rsid" : row . get ( "matched_rsid" ) . filter ( |value| !value . is_empty ( ) ) . cloned( ) . or_else( || manifest . spec . rsids . first ( ) . cloned( ) ) ,
358+ "rsid" : canonical_rsid . cloned( ) . or_else( || matched_rsid . cloned( ) ) ,
353359 "gene" : gene,
354360 "assembly" : if assembly. is_empty( ) { serde_json:: Value :: Null } else { serde_json:: Value :: String ( assembly. to_uppercase( ) ) } ,
355361 "chrom" : chrom,
@@ -377,6 +383,8 @@ fn render_app_observation_json(input: AppObservationJson) -> serde_json::Value {
377383 "match_quality" : if weak_indel_match { serde_json:: Value :: String ( "weak" . to_owned( ) ) } else { serde_json:: Value :: Null } ,
378384 "match_notes" : if weak_indel_match {
379385 serde_json:: Value :: String ( "consumer genotype file reported an insertion/deletion token at the marker, not sequence-resolved evidence for the exact deletion allele" . to_owned( ) )
386+ } else if let Some ( note) = alias_match_note {
387+ serde_json:: Value :: String ( note)
380388 } else {
381389 serde_json:: Value :: Null
382390 } ,
@@ -397,10 +405,10 @@ fn manifest_default_source(
397405 manifest : & VariantManifest ,
398406) -> serde_json:: Value {
399407 let rsid = row
400- . get ( "matched_rsid " )
408+ . get ( "rsid " )
401409 . filter ( |rsid| !rsid. is_empty ( ) )
402- . or_else ( || row . get ( "rsid" ) . filter ( |rsid| !rsid. is_empty ( ) ) )
403- . or_else ( || manifest . spec . rsids . first ( ) . filter ( |rsid| !rsid. is_empty ( ) ) ) ;
410+ . or_else ( || manifest . spec . rsids . first ( ) . filter ( |rsid| !rsid. is_empty ( ) ) )
411+ . or_else ( || row . get ( "matched_rsid" ) . filter ( |rsid| !rsid. is_empty ( ) ) ) ;
404412 let Some ( rsid) = rsid else {
405413 return serde_json:: Value :: Null ;
406414 } ;
@@ -445,6 +453,32 @@ mod tests {
445453 ) ;
446454 }
447455
456+ #[ test]
457+ fn repeat_indel_insertion_deletion_tokens_remain_ambiguous_without_sequence_alleles ( ) {
458+ assert_eq ! (
459+ normalize_app_genotype(
460+ "II" ,
461+ "TTTTTTTTTTTTT" ,
462+ "TTTTTTTTTTTT" ,
463+ Some ( VariantKind :: Indel ) ,
464+ "19" ,
465+ None ,
466+ ) ,
467+ ( "II" . to_owned( ) , "unknown" . to_owned( ) )
468+ ) ;
469+ assert_eq ! (
470+ normalize_app_genotype(
471+ "ID" ,
472+ "TTTTTTTTTTTTT" ,
473+ "TTTTTTTTTTTT" ,
474+ Some ( VariantKind :: Indel ) ,
475+ "19" ,
476+ None ,
477+ ) ,
478+ ( "ID" . to_owned( ) , "unknown" . to_owned( ) )
479+ ) ;
480+ }
481+
448482 #[ test]
449483 fn displays_cram_long_deletion_copy_number_as_insertion_deletion_tokens ( ) {
450484 let manifest = VariantManifest {
0 commit comments