@@ -159,19 +159,30 @@ def test_xpehh_gwss():
159159 assert_allclose (xpehh [:, 2 ][100 ], 0.4817561326426265 )
160160
161161
162- def test_karyotyping ():
162+ @pytest .mark .parametrize (
163+ "inversion" ,
164+ ["2La" , "2Rb" , "2Rc_col" , "X_x" ],
165+ )
166+ def test_karyotyping (inversion ):
163167 ag3 = setup_ag3 (cohorts_analysis = "20230516" )
164168
165- df = ag3 .karyotype (inversion = "2La" , sample_sets = "AG1000G-GH" , sample_query = None )
166-
167- assert isinstance (df , pd .DataFrame )
168- expected_cols = [
169- "sample_id" ,
170- "inversion" ,
171- "karyotype_2La_mean" ,
172- "karyotype_2La" ,
173- "total_tag_snps" ,
174- ]
175- assert set (df .columns ) == set (expected_cols )
176- assert all (df ["karyotype_2La" ].isin ([0 , 1 , 2 ]))
177- assert all (df ["karyotype_2La_mean" ].between (0 , 2 ))
169+ if inversion == "X_x" :
170+ with pytest .raises (TypeError ):
171+ ag3 .karyotype (
172+ inversion = inversion , sample_sets = "AG1000G-GH" , sample_query = None
173+ )
174+ else :
175+ df = ag3 .karyotype (
176+ inversion = inversion , sample_sets = "AG1000G-GH" , sample_query = None
177+ )
178+ assert isinstance (df , pd .DataFrame )
179+ expected_cols = [
180+ "sample_id" ,
181+ "inversion" ,
182+ f"karyotype_{ inversion } _mean" ,
183+ f"karyotype_{ inversion } " ,
184+ "total_tag_snps" ,
185+ ]
186+ assert set (df .columns ) == set (expected_cols )
187+ assert all (df [f"karyotype_{ inversion } " ].isin ([0 , 1 , 2 ]))
188+ assert all (df [f"karyotype_{ inversion } _mean" ].between (0 , 2 ))
0 commit comments