import math


def _get_qv(snpcount, length):
    """ Get accuracy based on snps comparison to reference

        Args:
             snpcount: Number of snps
             length: Number of nucleotides in fasta reference
        Returns:
             quality_value: A Phred Quality Score

    """

    if snpcount != 0:
        quality_value = round(
            -10 * math.log10(int(snpcount) / float(length)), 3)
    # if there are 0 snps, it means the query perfectly matches the reference
    else:
        quality_value = round(-10 * math.log10(1 / float(length)), 3)

    return quality_value