From 37a5d3649bc2766520bc4e9900c1699583b5e1b1 Mon Sep 17 00:00:00 2001 From: Nick Croucher Date: Thu, 18 Apr 2024 13:27:06 +0100 Subject: [PATCH] Revert "Update get_blocks function" This reverts commit 28fcdb23d04629ec871c4768266c1c58f9d5dc41. --- src/branch_sequences.c | 43 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/src/branch_sequences.c b/src/branch_sequences.c index ca2fdf58..6b3c5d35 100644 --- a/src/branch_sequences.c +++ b/src/branch_sequences.c @@ -738,8 +738,6 @@ int get_blocks(int ** block_coordinates, int genome_size,int * snp_site_coords,i // create the pileup of the snps and their sphere of influence int snp_counter = 0; - int min_postion = genome_size; - int max_position = 0; for(snp_counter = 0; snp_counter < number_of_branch_snps; snp_counter++) { int j = 0; @@ -756,11 +754,6 @@ int get_blocks(int ** block_coordinates, int genome_size,int * snp_site_coords,i snp_sliding_window_counter = 0; } - if(snp_sliding_window_counter < min_postion) - { - min_postion = snp_sliding_window_counter; - } - // Upper bound of the window around a snp int max_snp_sliding_window_counter = snp_site_coords[snp_counter]+(window_size/2); max_snp_sliding_window_counter = extend_upper_part_of_window(snp_site_coords[snp_counter] + 1, @@ -772,11 +765,6 @@ int get_blocks(int ** block_coordinates, int genome_size,int * snp_site_coords,i { max_snp_sliding_window_counter = genome_size; } - - if(max_snp_sliding_window_counter > max_position) - { - max_position= max_snp_sliding_window_counter; - } for(j = snp_sliding_window_counter; j < max_snp_sliding_window_counter; j++) { @@ -790,7 +778,7 @@ int get_blocks(int ** block_coordinates, int genome_size,int * snp_site_coords,i int block_lower_bound = 0; // Scan across the pileup and record where blocks are above the cutoff int i; - for(i = min_postion; i <= max_position; i++) + for(i = 0; i <= genome_size; i++) { // Just entered the start of a block if(window_count[i] > cutoff && in_block == 0) @@ -800,23 +788,20 @@ int get_blocks(int ** block_coordinates, int genome_size,int * snp_site_coords,i } // Reached end of genome - if (in_block == 1) + if(i == genome_size && in_block == 1) + { + block_coordinates[0][number_of_blocks] = block_lower_bound; + block_coordinates[1][number_of_blocks] = i; + number_of_blocks++; + in_block = 0; + } + // Just left a block + else if(window_count[i] <= cutoff && in_block == 1) { - if(i == genome_size) - { - block_coordinates[0][number_of_blocks] = block_lower_bound; - block_coordinates[1][number_of_blocks] = i; - number_of_blocks++; - in_block = 0; - } - // Just left a block - else if(window_count[i] <= cutoff) - { - block_coordinates[0][number_of_blocks] = block_lower_bound; - block_coordinates[1][number_of_blocks] = i-1; - number_of_blocks++; - in_block = 0; - } + block_coordinates[0][number_of_blocks] = block_lower_bound; + block_coordinates[1][number_of_blocks] = i-1; + number_of_blocks++; + in_block = 0; } }