@@ -313,6 +313,34 @@ def test_embed_default_matches_in_process(self, fx_reader, fx_small_vcz):
313313 assert data == ref_data
314314
315315
316+ class TestBgenUnphasedToggle :
317+ """``--unphased`` flows through to ``BgenEncoder(unphased=True)``.
318+
319+ With the flag set, the encoder must ignore ``call_genotype_phased``
320+ and produce the same bytes as an in-process ``BgenEncoder`` built
321+ with ``unphased=True`` on the same reader.
322+ """
323+
324+ def test_unphased_matches_in_process (self , fx_reader , fx_small_vcz ):
325+ opts = vcztools .ViewBgenOptions (unphased = True )
326+ with formats .BGEN_SPEC .encoder_factory (fx_reader , opts ) as encoder :
327+ data = encoder .read (0 , encoder .total_size )
328+ ref_reader = _open_reader (fx_small_vcz .path )
329+ with vcztools .BgenEncoder (ref_reader , unphased = True ) as ref :
330+ ref_data = ref .read (0 , ref .total_size )
331+ assert data == ref_data
332+
333+ def test_unphased_default_matches_in_process (self , fx_reader , fx_small_vcz ):
334+ opts = vcztools .ViewBgenOptions ()
335+ assert opts .unphased is False
336+ with formats .BGEN_SPEC .encoder_factory (fx_reader , opts ) as encoder :
337+ data = encoder .read (0 , encoder .total_size )
338+ ref_reader = _open_reader (fx_small_vcz .path )
339+ with vcztools .BgenEncoder (ref_reader , unphased = False ) as ref :
340+ ref_data = ref .read (0 , ref .total_size )
341+ assert data == ref_data
342+
343+
316344class TestSpecsRegistry :
317345 def test_specs_dict_has_both_entries (self ):
318346 assert formats .SPECS == {"plink" : formats .PLINK_SPEC , "bgen" : formats .BGEN_SPEC }
0 commit comments