class_docstr: Realign reads in regions to assembled haplotypes.
  
  This class helps us to realign reads in regions by:
  
  (1) Create smaller windows in which to operate over the region. These windows
  are created by finding evidence of genetic variation surrounded by stretches
  of reference-matching seqence.
  
  (2) Build a de-Bruijn assembly graph of the window. Edges are pruned if they
  don't meet the required weight threshold. Every remaining haplotype is listed
  by traversing the graph.
  
  (3) Realign reads using a Smith-Waterman algorithm to the best candidate
  haplotype and then realign that haplotype to the reference sequence to modify
  the read's alignment.
class_docstr_tok: ["Realign","reads","in","regions","to","assembled","haplotypes",".","This","class","helps","us","to","realign","reads","in","regions","by",":","(","1",")","Create","smaller","windows","in","which","to","operate","over","the","region",".","These","windows","are","created","by","finding","evidence","of","genetic","variation","surrounded","by","stretches","of","reference-matching","seqence",".","(","2",")","Build","a","de-Bruijn","assembly","graph","of","the","window",".","Edges","are","pruned","if","they","do","n't","meet","the","required","weight","threshold",".","Every","remaining","haplotype","is","listed","by","traversing","the","graph",".","(","3",")","Realign","reads","using","a","Smith-Waterman","algorithm","to","the","best","candidate","haplotype","and","then","realign","that","haplotype","to","the","reference","sequence","to","modify","the","read","'s","alignment","."]
docstr: Helper function to call debruijn_graph module.
docstr_tok: ["Helper","function","to","call","debruijn_graph","module","."]
code: def call_debruijn_graph(self, windows, reads):
      """Helper function to call debruijn_graph module."""
      windows_haplotypes = []
      # Build and process de-Bruijn graph for each window.
      sam_reader = sam.InMemorySamReader(reads)
  
      for window in windows:
          if (
              window.end - window.start
              > self.config.ws_config.max_window_size
          ):
              continue
          if not self.ref_reader.is_valid(window):
              continue
          ref = self.ref_reader.query(window)
          window_reads = list(sam_reader.query(window))
  
          with timer.Timer() as t:
              graph = debruijn_graph.build(
                  ref, window_reads, self.config.dbg_config
              )
          graph_building_time = t.GetDuration()
  
          if not graph:
              candidate_haplotypes = [ref]
          else:
              candidate_haplotypes = graph.candidate_haplotypes()
          if candidate_haplotypes and candidate_haplotypes != [ref]:
              candidate_haplotypes_info = (
                  realigner_pb2.CandidateHaplotypes(
                      span=window, haplotypes=candidate_haplotypes
                  )
              )
              windows_haplotypes.append(candidate_haplotypes_info)
  
          self.diagnostic_logger.log_graph_metrics(
              window, graph, candidate_haplotypes, graph_building_time
          )
  
      return windows_haplotypes
  
imports: import csv
  import os
  import os.path
  from absl import flags
  from etils import epath
  from deepvariant.protos import realigner_pb2
  from deepvariant.realigner import window_selector
  from deepvariant.realigner.python import debruijn_graph
  from deepvariant.realigner.python import fast_pass_aligner
  from deepvariant.vendor import timer
  from google.protobuf import text_format
  from third_party.nucleus.io import sam
  from third_party.nucleus.protos import cigar_pb2
  from third_party.nucleus.protos import reads_pb2
  from third_party.nucleus.util import cigar
  from third_party.nucleus.util import ranges
  from third_party.nucleus.util import utils
  from third_party.nucleus.util.cigar import READ_ADVANCING_OPS
  from third_party.nucleus.util.cigar import REF_ADVANCING_OPS
label_desc: Use image node_id 2 for calling the Realigner obj's underlying member method code with example usage: obj.call_debruijn_graph(windows, reads) and returns: windows_haplotypes