limix / bgen-reader-py

A BGEN file format reader.
MIT License
10 stars 3 forks source link

Empty bgen file might cause division by zero. #36

Open horta opened 3 years ago

horta commented 3 years ago

Empty bgen file being one with no genotype but with samples. Marc found the following exception with such a file:

Traceback (most recent call last):
  File "/hps/nobackup/stegle/users/galvari/src/hipsci_pipeline/limix_QTL_pipeline/run_QTL_analysis.py", line 813, in <module>
    randomeff_filename=randeff_file, sample_mapping_filename=samplemap_file, extended_anno_filename=extended_anno_file, regressCovariatesUpfront = regressBefore, debugger= debugger)
  File "/hps/nobackup/stegle/users/galvari/src/hipsci_pipeline/limix_QTL_pipeline/run_QTL_analysis.py", line 64, in run_QTL_analysis
    extended_anno_filename=extended_anno_filename, feature_variant_covariate_filename=feature_variant_covariate_filename)
  File "/hps/nobackup/stegle/users/galvari/src/hipsci_pipeline/limix_QTL_pipeline/qtl_utilities.py", line 90, in run_QTL_analysis_load_intersect_phenotype_covariates_kinship_sample_mapping
    bgen = read_bgen(geno_prefix+'.bgen', verbose=False)
  File "/opt/conda/lib/python3.7/site-packages/bgen_reader/_reader.py", line 81, in read_bgen
    create_metafile(filepath, metafile_filepath, verbose)
  File "/opt/conda/lib/python3.7/site-packages/bgen_reader/_metadata.py", line 57, in create_metafile
    nparts = _estimate_best_npartitions(lib.bgen_nvariants(bgen))
  File "/opt/conda/lib/python3.7/site-packages/bgen_reader/_metadata.py", line 69, in _estimate_best_npartitions
    return nvariants // m
ZeroDivisionError: integer division or modulo by zero