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. for window in windows: if window.end - window.start > self.config.ws_config.max_window_size: continue if not self.ref_reader.is_valid_interval(window): continue ref = self.ref_reader.bases(window) # redacted dbg_reads = [ read for read in reads if ranges.ranges_overlap(window, utils.read_range(read)) ] with timer.Timer() as t: graph = debruijn_graph.build(ref, dbg_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
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
def testVacuous(self): with timer.Timer() as t: pass print('Time consuming stuff took %f seconds.' % t.GetDuration())