, metadata_file=None, sample_file=None, verbose=True)[source]

Read a given BGEN file.

  • filepath (str) – A BGEN file path.

  • metadata_file (str, optional) – If True, it will try to read the variants metadata from the metadata file filepath + ".metadata". If this is not possible, the variants metadata will be read from the BGEN file itself. If filepath + ".metadata" does not exist, it will try to create one with the same name to speed up reads. If False, variants metadata will be read only from the BGEN file. If a file path is given instead, it assumes that the specified metadata file is valid and readable and therefore it will read variants metadata from that file only. Defaults to None.

  • sample_file (str, optional) – A sample file in GEN format. If sample_file is provided, sample IDs are read from this file. Otherwise, it reads from the BGEN file itself if present. Defaults to None.

  • verbose (bool, optional) – True to show progress; False otherwise.



Metadata files can speed up subsequent reads tremendously. But often the user does not have write permission for the default metadata file location filepath + ".metadata". We thus provide the function for creating one at the given path.