static inline KOccurRun* fetch_ref_contact(const GraphCache *cache, uint32_t pathid, const PathRefRun *ref_runs, KOccurRunBuffer *runbuf) { // Get path const GCachePath *path = graph_cache_path(cache, pathid); const GCacheStep *steps = graph_cache_step(cache, path->first_step); size_t num_steps = path->num_steps; // Get runs along the ref PathRefRun ref_run = ref_runs[pathid]; size_t num_runs = ref_run.num_runs; KOccurRun *koruns = runbuf->data + ref_run.first_runid; koruns_sort_by_qoffset(koruns, num_runs); // Set qoffset to be the kmer offset in the path size_t r, s, offset = 0; for(s = r = 0; s < num_steps; s++) { for(; r < num_runs && koruns[r].qoffset == s; r++) { koruns[r].qoffset = offset; } if(r == num_runs) break; const GCacheSnode *snode = graph_cache_snode(cache, steps[s].supernode); offset += snode->num_nodes; } return koruns; }
// If `pickup_new_runs` is true we pick up runs starting at this supernode static inline bool gcrawler_stop_at_ref_covg(const GraphCache *cache, const GCacheStep *step, BreakpointCaller *caller, KOccurRunBuffer *koruns, KOccurRunBuffer *koruns_ended, bool pickup_new_runs) { GCacheSnode *snode = graph_cache_snode(cache, step->supernode); GCachePath *path = graph_cache_path(cache, step->pathid); const dBNode *nodes = graph_cache_first_node(cache, snode); bool forward = (step->orient == FORWARD); // Use index of last step as qoffset size_t qoffset = path->num_steps-1; // Kmer occurance runs are added to koruns_3p_ended only if they end and are // longer than the mininum length in kmers (caller->min_ref_nkmers) kograph_filter_extend(caller->kograph, nodes, snode->num_nodes, forward, caller->min_ref_nkmers, qoffset, koruns, koruns_ended, pickup_new_runs); size_t i, min_run_qoffset = SIZE_MAX, min_ended_run_qoffset = SIZE_MAX; for(i = 0; i < koruns->len; i++) min_run_qoffset = MIN2(min_run_qoffset, koruns->data[i].qoffset); // Stop if all our earliest runs have finished for(i = 0; i < koruns_ended->len; i++) { min_ended_run_qoffset = MIN2(min_ended_run_qoffset, koruns_ended->data[i].qoffset); } // Continue if... return min_run_qoffset <= min_ended_run_qoffset; }
// For 5p flank only pick up new runs starting at the first supernode static bool gcrawler_flank5p_stop_at_ref_covg(GraphCache *cache, GCacheStep *step, void *arg) { BreakpointCaller *caller = (BreakpointCaller*)arg; const GCachePath *path = graph_cache_path(cache, step->pathid); const GCacheStep *first_step = graph_cache_step(cache, path->first_step); bool pickup_new_runs = (step == first_step); return gcrawler_stop_at_ref_covg(cache, step, caller, &caller->koruns_5p, &caller->koruns_5p_ended, pickup_new_runs) && (caller->koruns_5p.len > 0); }
void graph_crawler_reset_rpt_walker(RepeatWalker *rptwlk, const GraphCache *cache, uint32_t pathid) { rpt_walker_fast_clear(rptwlk, NULL, 0); const GCachePath *path = graph_cache_path(cache, pathid); const GCacheStep *step = graph_cache_step(cache, path->first_step), *endstep; const GCacheSnode *snode; const dBNode *node0, *node1; // Loop over supernodes in the path for(endstep = step + path->num_steps; step < endstep; step++) { // We don't care about orientation here snode = graph_cache_snode(cache, step->supernode); node0 = graph_cache_first_node(cache, snode); node1 = graph_cache_last_node(cache, snode); rpt_walker_fast_clear_single_node(rptwlk, *node0); rpt_walker_fast_clear_single_node(rptwlk, *node1); } }