class_docstr: BaseClass for variant callers.
class_docstr_tok: ["BaseClass","for","variant","callers","."]
docstr: Computes the confidence that a site in the genome has no variation.
  
  Computes this confidence using only the counts of the number of reads
  supporting the reference allele and the total number of reads at this site.
  
  See: https:www.broadinstitute.org/gatk/guide/article?id=4017 for
  background.
  
  Computes the reference confidence for site allele_count.
  
  Examines the number of reference supporting and alternate supporting reads
  in allele_count and estimates the genotype likelihoods and confidence that
  this site is homozygous reference. These values are written into the first
  VariantCall record of variant, into the repeated field genotype_likelihood
  and the map field GQ.
  
  The genotype likelihoods are computed against any possible alternative
  allele, the so-called <*> allele, which boils down to a model that looks
  like:
  
   log10_p_ref = (1 - p_error)^(ref_n) (p_error)^(non_ref_n)
   log10_p_het = (0.5)^(total_n)
   log10_p_hom_alt = (p_e)^(ref_n) (1 - p_error)^(non_ref_n)
  
  ref_n is the number of reference supporting reads and non_ref_n is the sum
  of any reads supporting any alternate alleles. Non-informative reads are
  excluded from the calculation.
  
  and written in as the normalized log10 values so that:
  
   sum(10^genotype_likelihoods) = 1
  
  The GQ, according to the VCF specification, is the conditional genotype
  quality, encoded as a phred quality -10 * log10 p(genotype call is wrong,
  conditioned on the site's being variant, as an integer. See:
  https:samtools.github.io/hts-specs/VCFv4.3.pdf
  We are calculating the GQ not for the best genotype, but the GQ of the 0/0
  genotype, regardless of the likelihoods.
  1 = pRR + pRA + pAA; [R is reference, A=<*> is any alternative alternative]
  GQ of 0/0 = -10 * log10(pRA + pAA) [prob that any other differen genotype]
            = -10 * log10(1 - pRR) [substitution from the previous equation]
  Here we don't have pRR directly, but rather log10(pRR).
  
  Args:
    n_ref: int >= 0 and <= n_total: The number of reads supporting the
      reference allele.
    n_total: int >= 0 and >= n_ref: The number of reads supporting any allele
      at this site.
  
  Returns:
    A tuple of two values. The first is an integer value for the GQ (genotype
    quality) and the second is an array-like of the log10 probabilities for
    each of the three genotype configurations.
docstr_tok: ["Computes","the","confidence","that","a","site","in","the","genome","has","no","variation",".","Computes","this","confidence","using","only","the","counts","of","the","number","of","reads","supporting","the","reference","allele","and","the","total","number","of","reads","at","this","site",".","See",":","https",":","www.broadinstitute.org\/gatk\/guide\/article","?","id=4017","for","background",".","Computes","the","reference","confidence","for","site","allele_count",".","Examines","the","number","of","reference","supporting","and","alternate","supporting","reads","in","allele_count","and","estimates","the","genotype","likelihoods","and","confidence","that","this","site","is","homozygous","reference",".","These","values","are","written","into","the","first","VariantCall","record","of","variant",",","into","the","repeated","field","genotype_likelihood","and","the","map","field","GQ",".","The","genotype","likelihoods","are","computed","against","any","possible","alternative","allele",",","the","so-called","<","*",">","allele",",","which","boils","down","to","a","model","that","looks","like",":","log10_p_ref","=","(","1","-","p_error",")","^","(","ref_n",")","(","p_error",")","^","(","non_ref_n",")","log10_p_het","=","(","0.5",")","^","(","total_n",")","log10_p_hom_alt","=","(","p_e",")","^","(","ref_n",")","(","1","-","p_error",")","^","(","non_ref_n",")","ref_n","is","the","number","of","reference","supporting","reads","and","non_ref_n","is","the","sum","of","any","reads","supporting","any","alternate","alleles",".","Non-informative","reads","are","excluded","from","the","calculation",".","and","written","in","as","the","normalized","log10","values","so","that",":","sum","(","10^genotype_likelihoods",")","=","1","The","GQ",",","according","to","the","VCF","specification",",","is","the","conditional","genotype","quality",",","encoded","as","a","phred","quality","-10","*","log10","p","(","genotype","call","is","wrong",",","conditioned","on","the","site","'s","being","variant",",","as","an","integer",".","See",":","https",":","samtools.github.io\/hts-specs\/VCFv4.3.pdf","We","are","calculating","the","GQ","not","for","the","best","genotype",",","but","the","GQ","of","the","0\/0","genotype",",","regardless","of","the","likelihoods",".","1","=","pRR","+","pRA","+","pAA",";","[","R","is","reference",",","A=","<","*",">","is","any","alternative","alternative","]","GQ","of","0\/0","=","-10","*","log10","(","pRA","+","pAA",")","[","prob","that","any","other","differen","genotype","]","=","-10","*","log10","(","1","-","pRR",")","[","substitution","from","the","previous","equation","]","Here","we","do","n't","have","pRR","directly",",","but","rather","log10","(","pRR",")",".","Args",":","n_ref",":","int",">","=","0","and","<","=","n_total",":","The","number","of","reads","supporting","the","reference","allele",".","n_total",":","int",">","=","0","and",">","=","n_ref",":","The","number","of","reads","supporting","any","allele","at","this","site",".","Returns",":","A","tuple","of","two","values",".","The","first","is","an","integer","value","for","the","GQ","(","genotype","quality",")","and","the","second","is","an","array-like","of","the","log10","probabilities","for","each","of","the","three","genotype","configurations","."]
code: def reference_confidence(self, n_ref, n_total):
      """Computes the confidence that a site in the genome has no variation.
  
      Computes this confidence using only the counts of the number of reads
      supporting the reference allele and the total number of reads at this site.
  
      See: https:www.broadinstitute.org/gatk/guide/article?id=4017 for
      background.
  
      Computes the reference confidence for site allele_count.
  
      Examines the number of reference supporting and alternate supporting reads
      in allele_count and estimates the genotype likelihoods and confidence that
      this site is homozygous reference. These values are written into the first
      VariantCall record of variant, into the repeated field genotype_likelihood
      and the map field GQ.
  
      The genotype likelihoods are computed against any possible alternative
      allele, the so-called <*> allele, which boils down to a model that looks
      like:
  
       log10_p_ref = (1 - p_error)^(ref_n) (p_error)^(non_ref_n)
       log10_p_het = (0.5)^(total_n)
       log10_p_hom_alt = (p_e)^(ref_n) (1 - p_error)^(non_ref_n)
  
      ref_n is the number of reference supporting reads and non_ref_n is the sum
      of any reads supporting any alternate alleles. Non-informative reads are
      excluded from the calculation.
  
      and written in as the normalized log10 values so that:
  
       sum(10^genotype_likelihoods) = 1
  
      The GQ, according to the VCF specification, is the conditional genotype
      quality, encoded as a phred quality -10 * log10 p(genotype call is wrong,
      conditioned on the site's being variant, as an integer. See:
      https:samtools.github.io/hts-specs/VCFv4.3.pdf
      We are calculating the GQ not for the best genotype, but the GQ of the 0/0
      genotype, regardless of the likelihoods.
      1 = pRR + pRA + pAA; [R is reference, A=<*> is any alternative alternative]
      GQ of 0/0 = -10 * log10(pRA + pAA) [prob that any other differen genotype]
                = -10 * log10(1 - pRR) [substitution from the previous equation]
      Here we don't have pRR directly, but rather log10(pRR).
  
      Args:
        n_ref: int >= 0 and <= n_total: The number of reads supporting the
          reference allele.
        n_total: int >= 0 and >= n_ref: The number of reads supporting any allele
          at this site.
  
      Returns:
        A tuple of two values. The first is an integer value for the GQ (genotype
        quality) and the second is an array-like of the log10 probabilities for
        each of the three genotype configurations.
      """
      if self.table is None:
          return self._calc_reference_confidence(n_ref, n_total)
      else:
          ref_index, total_index = _rescale_read_counts_if_necessary(
              n_ref, n_total, self.max_cache_coverage
          )
          return self.table[total_index][ref_index]
  
imports: import abc
  import collections
  import itertools
  import math
  import operator
  import statistics
  from typing import Dict, Sequence, Tuple
  import numpy
  from deepvariant.protos import deepvariant_pb2
  from deepvariant.python import allelecounter
  from deepvariant.python import variant_calling
  from deepvariant.python import variant_calling_multisample
  from third_party.nucleus.protos import variants_pb2
  from third_party.nucleus.util import genomics_math
  from third_party.nucleus.util import variantcall_utils
  from third_party.nucleus.util import vcf_constants
label_desc: Use image node_id 2 for calling the VariantCaller obj's underlying member method code with example usage: obj.reference_confidence(n_ref, n_total) and returns: self, self