@@ -403,14 +403,21 @@ def test_allele_frequencies_with_str_cohorts(
403403 # Run the function under test.
404404 df_aa = api .aa_allele_frequencies (** params )
405405
406- check_plot_frequencies_heatmap (api , df_aa )
407-
408- # Standard checks.
409- check_aa_allele_frequencies (
410- df = df_aa ,
411- cohort_labels = cohort_labels ,
412- transcript = transcript ,
413- )
406+ # Handle the case where no amino acid change SNPs are found.
407+ # In this case, aa_allele_frequencies returns an empty DataFrame
408+ # instead of raising (see issue #1064).
409+ if len (df_aa ) > 0 :
410+ check_plot_frequencies_heatmap (api , df_aa )
411+
412+ # Standard checks.
413+ check_aa_allele_frequencies (
414+ df = df_aa ,
415+ cohort_labels = cohort_labels ,
416+ transcript = transcript ,
417+ )
418+ else :
419+ assert isinstance (df_aa , pd .DataFrame )
420+ assert df_aa .index .names == ["aa_change" , "contig" , "position" ]
414421
415422
416423@pytest .mark .parametrize ("min_cohort_size" , [0 , 10 , 100 ])
@@ -531,14 +538,22 @@ def test_allele_frequencies_with_str_cohorts_and_sample_query(
531538 # Run the function under test.
532539 df_aa = api .aa_allele_frequencies (** params )
533540
534- check_plot_frequencies_heatmap (api , df_aa )
541+ # Handle the case where no amino acid change SNPs are found.
542+ # In this case, aa_allele_frequencies returns an empty DataFrame
543+ # instead of raising (see issue #1064).
544+ if len (df_aa ) > 0 :
545+ check_plot_frequencies_heatmap (api , df_aa )
535546
536- # Standard checks.
537- check_aa_allele_frequencies (
538- df = df_aa ,
539- cohort_labels = cohort_labels ,
540- transcript = transcript ,
541- )
547+ # Standard checks.
548+ check_aa_allele_frequencies (
549+ df = df_aa ,
550+ cohort_labels = cohort_labels ,
551+ transcript = transcript ,
552+ )
553+ else :
554+ # Verify the empty DataFrame has the expected structure.
555+ assert isinstance (df_aa , pd .DataFrame )
556+ assert df_aa .index .names == ["aa_change" , "contig" , "position" ]
542557
543558
544559@parametrize_with_cases (
@@ -604,14 +619,21 @@ def test_allele_frequencies_with_str_cohorts_and_sample_query_options(
604619 # Run the function under test.
605620 df_aa = api .aa_allele_frequencies (** params )
606621
607- check_plot_frequencies_heatmap (api , df_aa )
622+ # Handle the case where no amino acid change SNPs are found.
623+ # In this case, aa_allele_frequencies returns an empty DataFrame
624+ # instead of raising (see issue #1064).
625+ if len (df_aa ) > 0 :
626+ check_plot_frequencies_heatmap (api , df_aa )
608627
609- # Standard checks.
610- check_aa_allele_frequencies (
611- df = df_aa ,
612- cohort_labels = cohort_labels ,
613- transcript = transcript ,
614- )
628+ # Standard checks.
629+ check_aa_allele_frequencies (
630+ df = df_aa ,
631+ cohort_labels = cohort_labels ,
632+ transcript = transcript ,
633+ )
634+ else :
635+ assert isinstance (df_aa , pd .DataFrame )
636+ assert df_aa .index .names == ["aa_change" , "contig" , "position" ]
615637
616638
617639@parametrize_with_cases ("fixture,api" , cases = "." )
0 commit comments