def write_genotypes(self, genotypes):
        """Write genotypes to binary file.

        Args:
            genotypes (numpy.ndarray): The genotypes to write in the BED file.

        """
        if self._mode != "w":
            raise UnsupportedOperation("not available in 'r' mode")

        # Initializing the number of samples if required
        if self._nb_values is None:
            self._nb_values = len(genotypes)

        # Checking the expected number of samples
        if self._nb_values != len(genotypes):
            raise ValueError("{:,d} samples expected, got {:,d}".format(
                self._nb_values,
                len(genotypes),
            ))

        # Writing to file
        byte_array = [
            g[0] | (g[1] << 2) | (g[2] << 4) | (g[3] << 6) for g in
            self._grouper((_byte_recode[geno] for geno in genotypes), 4)
        ]
        self._bed.write(bytearray(byte_array))
def write_genotypes ( self , genotypes ) : if self . _mode != "w" : raise UnsupportedOperation ( "not available in 'r' mode" ) if self . _nb_values is None : self . _nb_values = len ( genotypes ) if self . _nb_values != len ( genotypes ) : raise ValueError ( "{:,d} samples expected, got {:,d}" . format ( self . _nb_values , len ( genotypes ) , ) ) byte_array = [ g [ 0 ] | ( g [ 1 ] << 2 ) | ( g [ 2 ] << 4 ) | ( g [ 3 ] << 6 ) for g in self . _grouper ( ( _byte_recode [ geno ] for geno in genotypes ) , 4 ) ] self . _bed . write ( bytearray ( byte_array ) )
Write genotypes to binary file.

        Args:
            genotypes (numpy.ndarray): The genotypes to write in the BED file.