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 query(self, region): """Iterate over records overlapping a query region. Args: region: third_party.nucleus.protos.Range, query region. Returns: An iterator over third_party.nucleus.protos.Read """ # redacted return (read for read in self.reads if ranges.ranges_overlap(region, read_range(read)))
def query(self, region): """Iterate over records overlapping a query region. Args: region: learning.genomics.deepvariant.core.genomics.Range, query region. Returns: An iterator over learning.genomics.deepvariant.core.genomics.Read """ # redacted return (read for read in self.reads if ranges.ranges_overlap(region, read_range(read)))
def check_overlaps(chr1, start1, end1, chr2, start2, end2, expected): i1 = ranges.make_range(chr1, start1, end1) i2 = ranges.make_range(chr2, start2, end2) self.assertEquals(ranges.ranges_overlap(i1, i2), expected) self.assertEquals(ranges.ranges_overlap(i2, i1), expected)
def _fake_query(region): return [ variant for variant in variants if ranges.ranges_overlap( variantutils.variant_range(variant), region) ]