@@ -165,6 +165,27 @@ def test_fst_gwss_window_size_too_large(fixture, api: AnophelesFstAnalysis):
165165 assert x .shape == fst .shape
166166
167167
168+ @parametrize_with_cases ("fixture,api" , cases = "." )
169+ def test_fst_gwss_too_few_snps (fixture , api : AnophelesFstAnalysis ):
170+ # When min_snps_threshold exceeds available SNPs, a ValueError must be raised.
171+ all_sample_sets = api .sample_sets ()["sample_set" ].to_list ()
172+ all_countries = api .sample_metadata ()["country" ].dropna ().unique ().tolist ()
173+ countries = random .sample (all_countries , 2 )
174+ cohort1_query = f"country == { countries [0 ]!r} "
175+ cohort2_query = f"country == { countries [1 ]!r} "
176+ with pytest .raises (ValueError , match = "Too few SNP sites" ):
177+ api .fst_gwss (
178+ contig = random .choice (api .contigs ),
179+ sample_sets = all_sample_sets ,
180+ cohort1_query = cohort1_query ,
181+ cohort2_query = cohort2_query ,
182+ site_mask = random .choice (api .site_mask_ids ),
183+ window_size = 100 ,
184+ min_cohort_size = 1 ,
185+ min_snps_threshold = 10_000_000 , # far larger than any fixture SNP count (~28k-70k)
186+ )
187+
188+
168189@parametrize_with_cases ("fixture,api" , cases = "." )
169190def test_average_fst (fixture , api : AnophelesFstAnalysis ):
170191 # Set up test parameters.
0 commit comments