From 88056efc855313204564a6f68918564d9d7e44ab Mon Sep 17 00:00:00 2001 From: Nick Croucher Date: Thu, 18 Apr 2024 20:35:19 +0100 Subject: [PATCH] Revert breaking changes --- src/branch_sequences.c | 77 +++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/src/branch_sequences.c b/src/branch_sequences.c index 6b3c5d35..fdc393be 100644 --- a/src/branch_sequences.c +++ b/src/branch_sequences.c @@ -77,27 +77,33 @@ int copy_and_concat_2d_integer_arrays(int ** array_1, int array_1_size, int ** a // Loop over all recombination blocks and return a list of all snp indices that fall within those blocks. int get_list_of_snp_indices_which_fall_in_downstream_recombinations(int ** current_block_coordinates,int num_blocks, int * snp_locations,int number_of_snps, int * snps_in_recombinations) { - int num_snps_in_recombinations =0; - int i = 0; + int num_snps_in_recombinations =0; + int i = 0; // loop over each block - for(i = 0; i max_position) + { + max_position= max_snp_sliding_window_counter; + } for(j = snp_sliding_window_counter; j < max_snp_sliding_window_counter; j++) { @@ -778,7 +796,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 = 0; i <= genome_size; i++) + for(i = min_postion; i <= max_position; i++) { // Just entered the start of a block if(window_count[i] > cutoff && in_block == 0) @@ -788,20 +806,23 @@ int get_blocks(int ** block_coordinates, int genome_size,int * snp_site_coords,i } // Reached end of genome - 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 (in_block == 1) { - block_coordinates[0][number_of_blocks] = block_lower_bound; - block_coordinates[1][number_of_blocks] = i-1; - number_of_blocks++; - in_block = 0; + 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; + } } }