@@ -343,3 +343,50 @@ def test_pairwise_average_fst_with_bad_cohorts(fixture, api: AnophelesFstAnalysi
343343 # Run function under test.
344344 with pytest .raises (ValueError ):
345345 api .pairwise_average_fst (** fst_params )
346+
347+
348+ @parametrize_with_cases ("fixture,api" , cases = "." )
349+ def test_average_fst_with_list_of_regions (fixture , api : AnophelesFstAnalysis ):
350+ # Set up test parameters.
351+ all_sample_sets = api .sample_sets ()["sample_set" ].to_list ()
352+ all_countries = api .sample_metadata ()["country" ].dropna ().unique ().tolist ()
353+ countries = random .sample (all_countries , 2 )
354+ cohort1_query = f"country == { countries [0 ]!r} "
355+ cohort2_query = f"country == { countries [1 ]!r} "
356+ fst_params = dict (
357+ region = random .sample (api .contigs , 2 ),
358+ sample_sets = all_sample_sets ,
359+ cohort1_query = cohort1_query ,
360+ cohort2_query = cohort2_query ,
361+ site_mask = random .choice (api .site_mask_ids ),
362+ min_cohort_size = 1 ,
363+ n_jack = random .randint (10 , 200 ),
364+ )
365+
366+ # Run function under test.
367+ fst , se = api .average_fst (** fst_params )
368+
369+ # Checks.
370+ assert isinstance (fst , float )
371+ assert isinstance (se , float )
372+ assert 0 <= fst <= 1
373+ assert 0 <= se <= 1
374+
375+
376+ @parametrize_with_cases ("fixture,api" , cases = "." )
377+ def test_pairwise_average_fst_with_list_of_regions (fixture , api : AnophelesFstAnalysis ):
378+ # Set up test parameters.
379+ all_sample_sets = api .sample_sets ()["sample_set" ].to_list ()
380+ region = random .sample (api .contigs , 2 )
381+ site_mask = random .choice (api .site_mask_ids )
382+ fst_params = dict (
383+ region = region ,
384+ cohorts = "country" ,
385+ sample_sets = all_sample_sets ,
386+ site_mask = site_mask ,
387+ min_cohort_size = 1 ,
388+ n_jack = random .randint (10 , 200 ),
389+ )
390+
391+ # Run checks.
392+ check_pairwise_average_fst (api = api , fst_params = fst_params )
0 commit comments