File: test_pbcore_util.py

package info (click to toggle)
python-pbcore 1.7.1%2Bgit20200430.a127b1e%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,404 kB
  • sloc: python: 23,243; xml: 2,504; makefile: 232; sh: 66
file content (24 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pytest
import sys

from pbcore.util.statistics import accuracy_as_phred_qv, phred_qv_as_accuracy


class TestStatistics:

    def test_accuracy_as_phred_qv(self):
        qv = accuracy_as_phred_qv(0.999)
        assert int(round(qv)) == 30
        qv = accuracy_as_phred_qv(1.0, max_qv=60)
        assert int(round(qv)) == 60
        qv = accuracy_as_phred_qv([0.95, 1.0, 0.99999])
        qvs = [int(round(x)) for x in qv]
        assert qvs == [13, 60, 50]

    def test_phred_qv_as_accuracy(self):
        assert phred_qv_as_accuracy(20) == 0.99
        assert phred_qv_as_accuracy(30) == 0.999
        assert phred_qv_as_accuracy(10) == 0.9
        assert phred_qv_as_accuracy(0) == 0
        with pytest.raises(ValueError):
            x = phred_qv_as_accuracy(-1)