class_docstr: High-level API for creating images of pileups of reads and reference bases.
  
  This class provides a higher-level and more natural API for constructing
  images at a candidate variant call site. Given a DeepVariantCall, which
  contains the candidate variant call along with key supplementary information,
  this class provides create_pileup_images() that will do all of the necessary
  fetching of reads and reference bases from readers and pass those off to the
  lower-level PileupImageEncoder to construct the image Tensor.
  
  for dv_call in candidates:
    allele_and_images = pic.create_pileup_images(dv_call)
    ...
  
  A quick note on how we deal with multiple alt alleles:
  
  Suppose variant has ref and two alt alleles. Assuming the sample is diploid,
  we have the following six possible genotypes:
  
    ref/ref   => 0/0
    ref/alt1  => 0/1
    alt1/alt1 => 1/1
    ref/alt2  => 0/2
    alt1/alt2 => 1/2
    alt2/alt2 => 2/2
  
  In DeepVariant we predict the genotype count (0, 1, 2) for a specific set of
  alternate alleles. If we only had a single alt, we'd construct an image for
  ref vs. alt1:
  
    image1 => ref vs. alt1 => determine if we are 0/0, 0/1, 1/1
  
  If we add a second image for alt2, we get:
  
    image2 => ref vs. alt2 => determine if we are 0/0, 0/2, 2/2
  
  but the problem here is that we don't have a good estimate for the het-alt
  state 1/2. So we construct a third image contrasting ref vs. either alt1 or
  alt2:
  
    image3 => ref vs. alt1 or alt2 => determines 0/0, 0/{1,2}, {1,2}/{1,2}
  
  Given the predictions for each image:
  
    image1 => p00, p01, p11
    image2 => p00, p02, p22
    image3 => p00, p0x, pxx where x is {1,2}
  
  we calculate our six genotype likelihoods as:
  
    0/0 => p00 [from any image]
    0/1 => p01 [image1]
    1/1 => p11 [image1]
    0/2 => p02 [image2]
    2/2 => p22 [image2]
    1/2 => pxx [image3]
  
  The function create_pileup_images() returns all of the necessary images, along
  with the alt alleles used for each image.
class_docstr_tok: ["High-level","API","for","creating","images","of","pileups","of","reads","and","reference","bases",".","This","class","provides","a","higher-level","and","more","natural","API","for","constructing","images","at","a","candidate","variant","call","site",".","Given","a","DeepVariantCall",",","which","contains","the","candidate","variant","call","along","with","key","supplementary","information",",","this","class","provides","create_pileup_images","(",")","that","will","do","all","of","the","necessary","fetching","of","reads","and","reference","bases","from","readers","and","pass","those","off","to","the","lower-level","PileupImageEncoder","to","construct","the","image","Tensor",".","for","dv_call","in","candidates",":","allele_and_images","=","pic.create_pileup_images","(","dv_call",")","...","A","quick","note","on","how","we","deal","with","multiple","alt","alleles",":","Suppose","variant","has","ref","and","two","alt","alleles",".","Assuming","the","sample","is","diploid",",","we","have","the","following","six","possible","genotypes",":","ref\/ref","=",">","0\/0","ref\/alt1","=",">","0\/1","alt1\/alt1","=",">","1\/1","ref\/alt2","=",">","0\/2","alt1\/alt2","=",">","1\/2","alt2\/alt2","=",">","2\/2","In","DeepVariant","we","predict","the","genotype","count","(","0",",","1",",","2",")","for","a","specific","set","of","alternate","alleles",".","If","we","only","had","a","single","alt",",","we","'d","construct","an","image","for","ref","vs.","alt1",":","image1","=",">","ref","vs.","alt1","=",">","determine","if","we","are","0\/0",",","0\/1",",","1\/1","If","we","add","a","second","image","for","alt2",",","we","get",":","image2","=",">","ref","vs.","alt2","=",">","determine","if","we","are","0\/0",",","0\/2",",","2\/2","but","the","problem","here","is","that","we","do","n't","have","a","good","estimate","for","the","het-alt","state","1\/2",".","So","we","construct","a","third","image","contrasting","ref","vs.","either","alt1","or","alt2",":","image3","=",">","ref","vs.","alt1","or","alt2","=",">","determines","0\/0",",","0\/","{","1,2","}",",","{","1,2","}","\/","{","1,2","}","Given","the","predictions","for","each","image",":","image1","=",">","p00",",","p01",",","p11","image2","=",">","p00",",","p02",",","p22","image3","=",">","p00",",","p0x",",","pxx","where","x","is","{","1,2","}","we","calculate","our","six","genotype","likelihoods","as",":","0\/0","=",">","p00","[","from","any","image","]","0\/1","=",">","p01","[","image1","]","1\/1","=",">","p11","[","image1","]","0\/2","=",">","p02","[","image2","]","2\/2","=",">","p22","[","image2","]","1\/2","=",">","pxx","[","image3","]","The","function","create_pileup_images","(",")","returns","all","of","the","necessary","images",",","along","with","the","alt","alleles","used","for","each","image","."]
docstr: Yields the set of all alt_alleles for variant.
  
  This function computes the sets of alt_alleles we want to use to cover all
  genotype likelihood calculations we need for n alt alleles (see class docs
  for background). The easiest way to do this is to calculate all combinations
  of 2 alleles from ref + alts and then strip away the reference alleles,
  leaving us with the set of alts for the pileup image encoder. The sets are
  converted to sorted lists at the end for downstream consistency.
  
  Args:
    variant: third_party.nucleus.protos.Variant to generate the alt allele
      combinations for.
  
  Yields:
    A series of lists containing the alt alleles we want to use for a single
    pileup image. The entire series covers all combinations of alt alleles
    needed for variant.
  
  Raises:
    ValueError: if options.multi_allelic_mode is UNSPECIFIED.
docstr_tok: ["Yields","the","set","of","all","alt_alleles","for","variant",".","This","function","computes","the","sets","of","alt_alleles","we","want","to","use","to","cover","all","genotype","likelihood","calculations","we","need","for","n","alt","alleles","(","see","class","docs","for","background",")",".","The","easiest","way","to","do","this","is","to","calculate","all","combinations","of","2","alleles","from","ref","+","alts","and","then","strip","away","the","reference","alleles",",","leaving","us","with","the","set","of","alts","for","the","pileup","image","encoder",".","The","sets","are","converted","to","sorted","lists","at","the","end","for","downstream","consistency",".","Args",":","variant",":","third_party.nucleus.protos.Variant","to","generate","the","alt","allele","combinations","for",".","Yields",":","A","series","of","lists","containing","the","alt","alleles","we","want","to","use","for","a","single","pileup","image",".","The","entire","series","covers","all","combinations","of","alt","alleles","needed","for","variant",".","Raises",":","ValueError",":","if","options.multi_allelic_mode","is","UNSPECIFIED","."]
code: def _alt_allele_combinations(
      self, variant: variants_pb2.Variant
  ) -> Iterable[List[str]]:
      """Yields the set of all alt_alleles for variant.
  
      This function computes the sets of alt_alleles we want to use to cover all
      genotype likelihood calculations we need for n alt alleles (see class docs
      for background). The easiest way to do this is to calculate all combinations
      of 2 alleles from ref + alts and then strip away the reference alleles,
      leaving us with the set of alts for the pileup image encoder. The sets are
      converted to sorted lists at the end for downstream consistency.
  
      Args:
        variant: third_party.nucleus.protos.Variant to generate the alt allele
          combinations for.
  
      Yields:
        A series of lists containing the alt alleles we want to use for a single
        pileup image. The entire series covers all combinations of alt alleles
        needed for variant.
  
      Raises:
        ValueError: if options.multi_allelic_mode is UNSPECIFIED.
      """
      ref = variant.reference_bases
      alts = list(variant.alternate_bases)
  
      if (
          self.multi_allelic_mode
          == deepvariant_pb2.PileupImageOptions.UNSPECIFIED
      ):
          raise ValueError("multi_allelic_mode cannot be UNSPECIFIED")
      elif (
          self.multi_allelic_mode
          == deepvariant_pb2.PileupImageOptions.NO_HET_ALT_IMAGES
      ):
          for alt in alts:
              yield sorted([alt])
      else:
          for combination in itertools.combinations([ref] + alts, 2):
              yield sorted(list(set(combination) - {ref}))
  
imports: import itertools
  from typing import Iterable, List, Optional, Tuple
  from absl import logging
  import numpy
  from deepvariant import dv_constants
  from deepvariant import sample
  from deepvariant.protos import deepvariant_pb2
  from deepvariant.python import pileup_image_native
  from third_party.nucleus.io import fasta
  from third_party.nucleus.io import sam
  from third_party.nucleus.protos import reads_pb2
  from third_party.nucleus.protos import variants_pb2
  from third_party.nucleus.util import ranges
label_desc: Use image node_id 7 for calling the PileupImageCreator obj's underlying member method code with example usage: obj._alt_allele_combinations(variant) without return types