songbo446 / RiboNT

RiboNT, a noise-tolerant predictor of ORFs from ribosome-protected footprints
MIT License
3 stars 1 forks source link

Division by zero error #1

Open Roleren opened 2 years ago

Roleren commented 2 years ago

hey, testing the package on Alexaki et al 2019 (human Ribo-seq)

Got an error I think is a bug, because I use a sparse bam file (2 Million reads only):

./RiboNT --gtf /media/roler/S/data/Bio_data/references/Homo_sapiens_GRCh38_101/Homo_sapiens.GRCh38.102_ensembl.gtf --genome /media/roler/S/data/Bio_data/references/Homo_sapiens_GRCh38_101/Homo_sapiens.GRCh38.dna.primary_assembly.fa --bam /media/roler/S/data/Bio_data/processed_data/Ribo-seq/Alexaki_Human/aligned/Ribo-Seq_CO1_Aligned.sortedByCoord.out.bam --outdir /home/roler/Desktop/test/RiboNT/ --pcov 0.1
GTF is: /media/roler/S/data/Bio_data/references/Homo_sapiens_GRCh38_101/Homo_sapiens.GRCh38.102_ensembl.gtf
Genome is: /media/roler/S/data/Bio_data/references/Homo_sapiens_GRCh38_101/Homo_sapiens.GRCh38.dna.primary_assembly.fa
bam is: /media/roler/S/data/Bio_data/processed_data/Ribo-seq/Alexaki_Human/aligned/Ribo-Seq_CO1_Aligned.sortedByCoord.out.bam
Output directory is: /home/roler/Desktop/test/RiboNT/
RiboNT starts ...
    Evaluating RPFs qualities
    Extracting genome-wide codon usages
Traceback (most recent call last):
  File "./RiboNT", line 126, in <module>
    main()
  File "./RiboNT", line 113, in main
    if not os.path.exists(prefix + '_dep.pickle'): entropy = ribont.PsiteAllocate(prefix + '.bed',prefix + '_OffSet.txt',prefix + '_multitaper.Freq.txt', prefix)
  File "/home/roler/Desktop/forks/RiboNT/bin/ribont.py", line 261, in PsiteAllocate
    meanEntropy = sumEntropy/sumAmount
ZeroDivisionError: division by zero
Roleren commented 2 years ago

In line 261 you divide on sum total, but if this is 0, it crashes, so you should add a catch for this corner case.