Skip to content

Commit

Permalink
exception for viterbi path or array in hmm_lib.c
Browse files Browse the repository at this point in the history
  • Loading branch information
lee212 committed Feb 12, 2016
1 parent 277b6d8 commit abde41c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions mgescan/nonltr/hmm/hmm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,14 @@ void viterbi(HMM *hmm_ptr, int T, char *O, double *pprob, int *vpath, char *sign
vpath[final_t]=0;
}

for(sig_id=final_t-1; sig_id>=0; sig_id--){
for(sig_id=final_t-1; sig_id>=0; sig_id--){

// skip if viterbi path or array is out of range
if ( path[vpath[sig_id+1]][sig_id+1] == -1)
continue;
vpath[sig_id] = path[vpath[sig_id+1]][sig_id+1];

if (path_signal[sig_id] == 1){
if (path_signal[sig_id] == 1 && alpha[vpath[sig_id]][sig_id] != DBL_MAX){
fprintf(outfp, "%d %d %lf\n", signal[sig_id], vpath[sig_id], alpha[vpath[sig_id]][sig_id]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion mgescan/nonltr/hmm/makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC = gcc
CFLAGS = -O3 -Wall -w
CFLAGS = -O3 -Wall -w # -g -O0 for gdb
SRCS = util_lib.c hmm_lib.c test_hmm.c
OBJS = $(SRCS:.c=.o)
MAIN = MGEScan
Expand Down

0 comments on commit abde41c

Please sign in to comment.