Example #1
0
def test_phred_conversions():
    assert util.phred_to_prob(40) == 0.9999
    assert util.phred_to_prob(30) == 0.999
    assert util.phred_to_prob(20) == 0.99
    assert util.phred_to_prob(10) == 0.9

    assert util.prob_to_phred(0.9999) == 40
    assert util.prob_to_phred(0.999) == 30
    assert util.prob_to_phred(0.99) == 20
    assert util.prob_to_phred(0.9) == 10
Example #2
0
    def gen_phred_scores(self, mean_quality, orientation):
        """Generate a normal distribution, transform to phred scores

        Generate a list of phred score according to a normal distribution
        centered around the ErrorModel quality

        Args:
            mean_quality (int): mean phred score

        Returns:
            list: list of phred scores following a normal distribution
        """
        norm = [min(q, 0.9999) for q in np.random.normal(
            util.phred_to_prob(mean_quality), 0.01, self.read_length)]
        phred = [util.prob_to_phred(p) for p in norm]
        return phred