From a464db59a550ebdbff2061f843db62be1f0fcc52 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Sun, 13 Nov 2016 21:23:01 +0100 Subject: [PATCH 1/3] Removed unreachable part of the code --- hmm_lib.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/hmm_lib.c b/hmm_lib.c index 5e8671d..402d056 100644 --- a/hmm_lib.c +++ b/hmm_lib.c @@ -1226,37 +1226,5 @@ void print_outputs(int codon_start, int start_t, int end_t, int frame, char* out sprintf(temp_str_ptr, "%s\n", dna_f); } strcat(dna_buffer, temp_str_ptr); - - } else if (codon_start == -1) { - - //sprintf(temp_str_ptr, "%d\t%d\t-\t%d\t%lf\t", start_t, end_t, frame, final_score); - sprintf(temp_str_ptr, "%d\t%d\t-\t%d\t", start_t, end_t, frame); - strcat(output_buffer, temp_str_ptr); - sprintf(temp_str_ptr, "I:"); - strcat(output_buffer, temp_str_ptr); - - for (i = 0; i < insert_id; i++) { - sprintf(temp_str_ptr, "%d,", insert[i]); - strcat(output_buffer, temp_str_ptr); - } - - sprintf(temp_str_ptr, "\tD:"); - strcat(aa_buffer, temp_str_ptr); - sprintf(temp_str_ptr, "%s_%d_%d_-\n", sequence_head_short, start_t, end_t); - strcat(dna_buffer, temp_str_ptr); - - get_protein(dna,protein,-1); - get_rc_dna(dna, dna1); - get_rc_dna_indel(dna_f, dna_f1); - sprintf(temp_str_ptr, "%s\n", protein); - if(multiple) strcat(aa_buffer, tab); - strcat(aa_buffer, temp_str_ptr); - - if (format == 0) { - sprintf(temp_str_ptr, "%s\n", dna1); - } else if (format == 1) { - sprintf(temp_str_ptr, "%s\n", dna_f1); - } - strcat(dna_buffer, temp_str_ptr); } } From 08dd85e7c10639ca39dd6c83005c849fa2e8e843 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Sun, 13 Nov 2016 21:23:15 +0100 Subject: [PATCH 2/3] Refactor unnecessarily large if-else --- hmm_lib.c | 107 +++++++++++++++++------------------------------------- 1 file changed, 33 insertions(+), 74 deletions(-) diff --git a/hmm_lib.c b/hmm_lib.c index 402d056..1f1fe58 100644 --- a/hmm_lib.c +++ b/hmm_lib.c @@ -1136,95 +1136,54 @@ void print_outputs(int codon_start, int start_t, int end_t, int frame, char* out int* insert, int* c_delete, int insert_id, int delete_id, int format, char* temp_str_ptr, unsigned int multiple) { int i; - char tab[] = "\t"; + if (codon_start != 1 || codon_start != -1) + return; - - - if (codon_start == 1) { - - //sprintf(temp_str_ptr, "%d\t%d\t+\t%d\t%lf\t", start_t, end_t, frame, final_score); + if (codon_start == 1) sprintf(temp_str_ptr, "%d\t%d\t+\t%d\t", start_t, end_t, frame); - strcat(output_buffer, temp_str_ptr); - sprintf(temp_str_ptr, "I:"); - strcat(output_buffer, temp_str_ptr); - + else + sprintf(temp_str_ptr, "%d\t%d\t-\t%d\t", start_t, end_t, frame); - for (i=0; i Date: Sun, 13 Nov 2016 22:30:04 +0100 Subject: [PATCH 3/3] Fix wrong condition in print_outputs --- hmm_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmm_lib.c b/hmm_lib.c index 1f1fe58..9997c90 100644 --- a/hmm_lib.c +++ b/hmm_lib.c @@ -1137,7 +1137,7 @@ void print_outputs(int codon_start, int start_t, int end_t, int frame, char* out int i; - if (codon_start != 1 || codon_start != -1) + if (codon_start != 1 && codon_start != -1) return; if (codon_start == 1)