code: def _read_bed(self):
          
          # Checking if BIM and BAM files were both read
          if (self._bim is None) or (self._fam is None):
              raise RuntimeError("no BIM or FAM file were read")
  
          # The number of bytes per marker
          self._nb_bytes = int(np.ceil(self._nb_samples / 4.0))
  
          # Checking the file is valid by looking at the first 3 bytes and the
          # last entry (correct size)
          with open(self.bed_filename, "rb") as bed_file:
              # Checking that the first two bytes are OK
              if (ord(bed_file.read(1)) != 108) or (ord(bed_file.read(1)) != 27):
                  raise ValueError("not a valid BED file: "
                                   "{}".format(self.bed_filename))
  
              # Checking that the format is SNP-major
              if ord(bed_file.read(1)) != 1:
                  raise ValueError("not in SNP-major format (please recode): "
                                   "{}".format(self.bed_filename))
  
              # Checking the last entry (for BED corruption)
              seek_index = self._get_seek_position(self._bim.iloc[-1, :].i)
              bed_file.seek(seek_index)
              geno = self._geno_values[
                  np.frombuffer(bed_file.read(self._nb_bytes), dtype=np.uint8)
              ].flatten(order="C")[:self._nb_samples]
              if geno.shape[0] != self._nb_samples:
                  raise ValueError("invalid number of entries: corrupted BED?")
  
          # Opening the file for the rest of the operations (reading 3 bytes)
          self._bed = open(self.bed_filename, "rb")
          self._bed.read(3)
docs: Reads the BED file.