From 000a04a76b3584e3f1934d09f0b2b1a184df29a1 Mon Sep 17 00:00:00 2001 From: Nick Croucher Date: Tue, 23 Apr 2024 09:46:16 +0100 Subject: [PATCH] Modularise functions --- src/parse_phylip.c | 10 +++++++--- src/parse_phylip.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/parse_phylip.c b/src/parse_phylip.c index cbc0c587..aa5e0013 100644 --- a/src/parse_phylip.c +++ b/src/parse_phylip.c @@ -62,17 +62,21 @@ int get_internal_node(int sequence_index) void get_sequence_for_sample_name(char * sequence_bases, char * sample_name) { int sequence_index; - sequence_index = find_sequence_index_from_sample_name( sample_name); + sequence_index = find_sequence_index_from_sample_name(sample_name); if(sequence_index < 0) { - printf("Couldnt find sequence name %s with index %d\n", sample_name,sequence_index); + printf("Could not find sequence name %s with index %d\n", sample_name,sequence_index); exit(1); } + get_sequence_for_sample_index(sequence_bases, sequence_index); + +} +void get_sequence_for_sample_index(char * sequence_bases, int sequence_index) +{ memcpy(sequence_bases, sequences[sequence_index], size_of_string(sequences[sequence_index]) +1); } - void fill_in_unambiguous_gaps_in_parent_from_children(int parent_sequence_index, int * child_sequence_indices, int num_children) { int snp_counter = 0; diff --git a/src/parse_phylip.h b/src/parse_phylip.h index 9be4c939..bbff7e6c 100644 --- a/src/parse_phylip.h +++ b/src/parse_phylip.h @@ -33,6 +33,7 @@ } sample_statistics; void get_sequence_for_sample_name(char * sequence_bases, char * sample_name); +void get_sequence_for_sample_index(char * sequence_bases, int sequence_index); int find_sequence_index_from_sample_name( char * sample_name); int update_sequence_base(char new_sequence_base, int sequence_index, int base_index); int does_column_contain_snps(int snp_column, char reference_base);