@@ -140,6 +140,27 @@ def test_fst_gwss(fixture, api: AnophelesFstAnalysis):
140140 assert isinstance (fig , bokeh .models .GridPlot )
141141
142142
143+ @parametrize_with_cases ("fixture,api" , cases = "." )
144+ def test_fst_gwss_window_size_too_large (fixture , api : AnophelesFstAnalysis ):
145+ # Use a window_size larger than the number of available SNPs to trigger the
146+ # ValueError guard added in _fst_gwss.
147+ all_sample_sets = api .sample_sets ()["sample_set" ].to_list ()
148+ all_countries = api .sample_metadata ()["country" ].dropna ().unique ().tolist ()
149+ countries = random .sample (all_countries , 2 )
150+ cohort1_query = f"country == { countries [0 ]!r} "
151+ cohort2_query = f"country == { countries [1 ]!r} "
152+ with pytest .raises (ValueError , match = "window_size" ):
153+ api .fst_gwss (
154+ contig = random .choice (api .contigs ),
155+ sample_sets = all_sample_sets ,
156+ cohort1_query = cohort1_query ,
157+ cohort2_query = cohort2_query ,
158+ site_mask = random .choice (api .site_mask_ids ),
159+ window_size = 10_000_000 , # far larger than any fixture SNP count
160+ min_cohort_size = 1 ,
161+ )
162+
163+
143164@parametrize_with_cases ("fixture,api" , cases = "." )
144165def test_average_fst (fixture , api : AnophelesFstAnalysis ):
145166 # Set up test parameters.
0 commit comments