📄 savehmm_multialpha.c
字号:
}#ifdef SAVE_DEBUG printf("%s", s);#endif /* emission prior file */ strcpy(s, "Emission prior file 1: "); if(fputs(strcat(strcat(s, modulep->priorfile_name), "\0"), outfile) == EOF) { perror(""); } if(fputs("\n", outfile) == EOF) { perror(""); } if(hmmp->nr_alphabets > 1) { /* emission prior file */ strcpy(s, "Emission prior file 2: "); if(fputs(strcat(strcat(s, modulep->priorfile_name_2), "\0"), outfile) == EOF) { perror(""); } if(fputs("\n", outfile) == EOF) { perror(""); } } if(hmmp->nr_alphabets > 2) { /* emission prior file */ strcpy(s, "Emission prior file 3: "); if(fputs(strcat(strcat(s, modulep->priorfile_name_3), "\0"), outfile) == EOF) { perror(""); } if(fputs("\n", outfile) == EOF) { perror(""); } } if(hmmp->nr_alphabets > 3) { /* emission prior file */ strcpy(s, "Emission prior file 4: "); if(fputs(strcat(strcat(s, modulep->priorfile_name_4), "\0"), outfile) == EOF) { perror(""); } if(fputs("\n", outfile) == EOF) { perror(""); } } /* transition prior file */ strcpy(s, "Transition prior file: null\0"); if(fputs(s, outfile) == EOF) { perror(""); } /* empty row */ if(fputs("\n\n", outfile) == EOF) { perror(""); } for(i = 0; i < modulep->nr_v; i++) { #ifdef SAVE_DEBUG printf("saving vertex %d...\n", *(modulep->vertices + i)); printf("nr_v left: %d\n", modulep->nr_v - i);#endif /* Vertex nr */ cur_v = *(modulep->vertices + i); strcpy(s, "Vertex "); itoa(nr, cur_v); if(fputs(strcat(strcat(s, nr), ":\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif /* vertex type */ strcpy(s, "Vertex type: "); switch(modulep->v_type) { case STARTV: strcat(s, "start\n"); break; case ENDV: strcat(s, "end\n"); break; case STANDARDV: strcat(s, "standard\n"); break; case LOCKEDV: strcat(s, "locked\n"); break; case SILENTV: strcat(s, "silent\n"); break; case PROFILEV: strcat(s, get_profile_vertex_type(cur_v, hmmp->silent_vertices)); break; default: printf("Error: unknown vertex type, can't save hmm\n"); exit(-1); } if(fputs(s, outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif /* vertex label */ strcpy(s, "Vertex label: \n"); s[14] = *(hmmp->vertex_labels + cur_v); if(fputs(s, outfile) == EOF) { perror(""); } /* Transition prior scaler */ strcpy(s, "Transition prior scaler: "); ftoa(nr, *(hmmp->vertex_trans_prior_scalers + cur_v), 6); strcat(s, nr); strcat(s, "\n"); if(fputs(s, outfile) == EOF) { perror(""); } /* Emission prior scaler */ strcpy(s, "Emission prior scaler 1: "); ftoa(nr, *(hmmp->vertex_emiss_prior_scalers + cur_v), 6); strcat(s, nr); strcat(s, "\n"); if(fputs(s, outfile) == EOF) { perror(""); } if(hmmp->nr_alphabets > 1) { strcpy(s, "Emission prior scaler 2: "); ftoa(nr, *(hmmp->vertex_emiss_prior_scalers_2 + cur_v), 6); strcat(s, nr); strcat(s, "\n"); if(fputs(s, outfile) == EOF) { perror(""); } } if(hmmp->nr_alphabets > 2) { strcpy(s, "Emission prior scaler 3: "); ftoa(nr, *(hmmp->vertex_emiss_prior_scalers_3 + cur_v), 6); strcat(s, nr); strcat(s, "\n"); if(fputs(s, outfile) == EOF) { perror(""); } } if(hmmp->nr_alphabets > 3) { strcpy(s, "Emission prior scaler 4: "); ftoa(nr, *(hmmp->vertex_emiss_prior_scalers_4 + cur_v), 6); strcat(s, nr); strcat(s, "\n"); if(fputs(s, outfile) == EOF) { perror(""); } } /* nr transitions */ strcpy(s, "Nr transitions = "); nr_t = 0; for(j = 0; j < hmmp->nr_v-1; j++) { if(*(hmmp->transitions + get_mtx_index(cur_v, j, hmmp->nr_v)) != 0) { nr_t++; } } itoa(nr, nr_t); if(fputs(strcat(strcat(s, nr), "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif /* nr end transitions */ strcpy(s, "Nr end transitions = "); nr_et = 0; if(*(hmmp->transitions + get_mtx_index(cur_v, hmmp->nr_v-1, hmmp->nr_v)) != 0.0) { nr_et++; } itoa(nr, nr_et); if(fputs(strcat(strcat(s, nr), "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif /* nr emissions */ strcpy(s, "Nr emissions 1 = "); itoa(nr, hmmp->a_size); if(fputs(strcat(strcat(s, nr), "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif if(hmmp->nr_alphabets > 1) { /* nr emissions */ strcpy(s, "Nr emissions 2 = "); itoa(nr, hmmp->a_size_2); if(fputs(strcat(strcat(s, nr), "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif } if(hmmp->nr_alphabets > 2) { /* nr emissions */ strcpy(s, "Nr emissions 3 = "); itoa(nr, hmmp->a_size_3); if(fputs(strcat(strcat(s, nr), "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif } if(hmmp->nr_alphabets > 3) { /* nr emissions */ strcpy(s, "Nr emissions 4 = "); itoa(nr, hmmp->a_size_4); if(fputs(strcat(strcat(s, nr), "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif } /* transition probabilities */ if(fputs("Transition probabilities\n", outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("Transition probabilities\n"); dump_trans_matrix(hmmp->nr_v, hmmp->nr_v, hmmp->transitions); printf("saving transp probs:\n");#endif for(k = 0; k < hmmp->nr_v-1; k++) { if(*(hmmp->transitions + get_mtx_index(cur_v, k, hmmp->nr_v)) != 0.0) { strcpy(s, "\tVertex "); itoa(nr, k); strcat(s, nr); strcat(s, ": "); ftoa(nr, *(hmmp->transitions + get_mtx_index(cur_v, k, hmmp->nr_v)), 6); strcat(s, nr); if(fputs(strcat(s, "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif } } /* end transition probabilities */ if(fputs("End transition probabilities\n", outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("saving end trans probs\n");#endif if(*(hmmp->transitions + get_mtx_index(cur_v, hmmp->nr_v-1, hmmp->nr_v)) != 0.0) { strcpy(s, "\tVertex "); itoa(nr, hmmp->nr_v - 1); strcat(s, nr); strcat(s, ": "); ftoa(nr, *(hmmp->transitions + get_mtx_index(cur_v, hmmp->nr_v-1, hmmp->nr_v)), 6); strcat(s, nr); if(fputs(strcat(s, "\n"), outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif } /* emission probabilities */ if(fputs("Emission probabilities 1\n", outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("saving emiss probs\n");#endif alphp = hmmp->alphabet; strcpy(s, "\t"); for(l = 0; l < hmmp->a_size; l++) { m = 1; while(*alphp != ';') { s[m] = *alphp; m++; alphp++; } alphp++; s[m] =':'; s[m+1] = ' '; s[m+2] ='\0'; if(*(hmmp->emissions + get_mtx_index(cur_v, l, hmmp->a_size)) == SILENT) { ftoa(nr, 0.0, 6); } else { ftoa(nr, *(hmmp->emissions + get_mtx_index(cur_v, l, hmmp->a_size)), 6); } strcat(s, nr);#ifdef SAVE_DEBUG printf("%s\n", s);#endif strcat(s,"\n"); if(fputs(s, outfile) == EOF) { perror(""); } } /* empty row */ if(fputs("\n", outfile) == EOF) { perror(""); } #ifdef SAVE_DEBUG printf("reached end of module vertices loop\n"); printf("loop index i = %d\n", i);#endif if(hmmp->nr_alphabets > 1) { /* emission probabilities */ if(fputs("Emission probabilities 2\n", outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("saving emiss probs\n");#endif alphp = hmmp->alphabet_2; strcpy(s, "\t"); for(l = 0; l < hmmp->a_size_2; l++) { m = 1; while(*alphp != ';') { s[m] = *alphp; m++; alphp++; } alphp++; s[m] =':'; s[m+1] = ' '; s[m+2] ='\0'; if(*(hmmp->emissions_2 + get_mtx_index(cur_v, l, hmmp->a_size_2)) == SILENT) { ftoa(nr, 0.0, 6); } else { ftoa(nr, *(hmmp->emissions_2 + get_mtx_index(cur_v, l, hmmp->a_size_2)), 6); } strcat(s, nr);#ifdef SAVE_DEBUG printf("%s\n", s);#endif strcat(s,"\n"); if(fputs(s, outfile) == EOF) { perror(""); } } /* empty row */ if(fputs("\n", outfile) == EOF) { perror(""); } #ifdef SAVE_DEBUG printf("reached end of module vertices loop\n"); printf("loop index i = %d\n", i);#endif } if(hmmp->nr_alphabets > 2) { /* emission probabilities */ if(fputs("Emission probabilities 3\n", outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("saving emiss probs\n");#endif alphp = hmmp->alphabet_3; strcpy(s, "\t"); for(l = 0; l < hmmp->a_size_3; l++) { m = 1; while(*alphp != ';') { s[m] = *alphp; m++; alphp++; } alphp++; s[m] =':'; s[m+1] = ' '; s[m+2] ='\0'; if(*(hmmp->emissions_3 + get_mtx_index(cur_v, l, hmmp->a_size_3)) == SILENT) { ftoa(nr, 0.0, 6); } else { ftoa(nr, *(hmmp->emissions_3 + get_mtx_index(cur_v, l, hmmp->a_size_3)), 6); } strcat(s, nr);#ifdef SAVE_DEBUG printf("%s\n", s);#endif strcat(s,"\n"); if(fputs(s, outfile) == EOF) { perror(""); } } /* empty row */ if(fputs("\n", outfile) == EOF) { perror(""); } #ifdef SAVE_DEBUG printf("reached end of module vertices loop\n"); printf("loop index i = %d\n", i);#endif } if(hmmp->nr_alphabets > 3) { /* emission probabilities */ if(fputs("Emission probabilities 4\n", outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("saving emiss probs\n");#endif alphp = hmmp->alphabet_4; strcpy(s, "\t"); for(l = 0; l < hmmp->a_size_4; l++) { m = 1; while(*alphp != ';') { s[m] = *alphp; m++; alphp++; } alphp++; s[m] =':'; s[m+1] = ' '; s[m+2] ='\0'; if(*(hmmp->emissions_4 + get_mtx_index(cur_v, l, hmmp->a_size_4)) == SILENT) { ftoa(nr, 0.0, 6); } else { ftoa(nr, *(hmmp->emissions_4 + get_mtx_index(cur_v, l, hmmp->a_size_4)), 6); } strcat(s, nr);#ifdef SAVE_DEBUG printf("%s\n", s);#endif strcat(s,"\n"); if(fputs(s, outfile) == EOF) { perror(""); } } /* empty row */ if(fputs("\n", outfile) == EOF) { perror(""); } #ifdef SAVE_DEBUG printf("reached end of module vertices loop\n"); printf("loop index i = %d\n", i);#endif } } /* ------------------------------------- */ if(fputs("-------------------------------------------------------\n", outfile) == EOF) { perror(""); }#ifdef SAVE_DEBUG printf("%s", s);#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -