@@ -368,3 +368,50 @@ def test_pairwise_average_fst_with_bad_cohorts(fixture, api: AnophelesFstAnalysi
368368 # Run function under test.
369369 with pytest .raises (ValueError ):
370370 api .pairwise_average_fst (** fst_params )
371+
372+
373+ @parametrize_with_cases ("fixture,api" , cases = "." )
374+ def test_average_fst_with_list_of_regions (fixture , api : AnophelesFstAnalysis ):
375+ # Set up test parameters.
376+ all_sample_sets = api .sample_sets ()["sample_set" ].to_list ()
377+ all_countries = api .sample_metadata ()["country" ].dropna ().unique ().tolist ()
378+ countries = random .sample (all_countries , 2 )
379+ cohort1_query = f"country == { countries [0 ]!r} "
380+ cohort2_query = f"country == { countries [1 ]!r} "
381+ fst_params = dict (
382+ region = random .sample (api .contigs , 2 ),
383+ sample_sets = all_sample_sets ,
384+ cohort1_query = cohort1_query ,
385+ cohort2_query = cohort2_query ,
386+ site_mask = random .choice (api .site_mask_ids ),
387+ min_cohort_size = 1 ,
388+ n_jack = random .randint (10 , 200 ),
389+ )
390+
391+ # Run function under test.
392+ fst , se = api .average_fst (** fst_params )
393+
394+ # Checks.
395+ assert isinstance (fst , float )
396+ assert isinstance (se , float )
397+ assert 0 <= fst <= 1
398+ assert 0 <= se <= 1
399+
400+
401+ @parametrize_with_cases ("fixture,api" , cases = "." )
402+ def test_pairwise_average_fst_with_list_of_regions (fixture , api : AnophelesFstAnalysis ):
403+ # Set up test parameters.
404+ all_sample_sets = api .sample_sets ()["sample_set" ].to_list ()
405+ region = random .sample (api .contigs , 2 )
406+ site_mask = random .choice (api .site_mask_ids )
407+ fst_params = dict (
408+ region = region ,
409+ cohorts = "country" ,
410+ sample_sets = all_sample_sets ,
411+ site_mask = site_mask ,
412+ min_cohort_size = 1 ,
413+ n_jack = random .randint (10 , 200 ),
414+ )
415+
416+ # Run checks.
417+ check_pairwise_average_fst (api = api , fst_params = fst_params )
0 commit comments