Skip to content

Commit

Permalink
indentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
lee212 committed Feb 19, 2016
1 parent 0a60889 commit f4c0b55
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 253 deletions.
24 changes: 9 additions & 15 deletions mgescan/nonltr/hmm/hmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#define RT_CRE 31
#define RT_R2 32


#define A_H_KD 0.0703
#define A_H_WW 0.0976
#define A_H_HH 0.0639
Expand All @@ -62,22 +61,17 @@

#define CODE 1



typedef struct {
int N; /* number of states; Q={1,2,...,N} */
int M; /* number of observation symbols; V={1,2,...,M}*/
double **A; /* A[1..N][1..N]. a[i][j] is the transition prob
of going from state i at time t to state j
at time t+1 */
double **B; /* B[1..N][1..M]. b[j][k] is the probability of
of observing symbol k in state j */
double *pi; /* pi[1..N] pi[i] is the initial state distribution. */
int N; /* number of states; Q={1,2,...,N} */
int M; /* number of observation symbols; V={1,2,...,M}*/
double **A; /* A[1..N][1..N]. a[i][j] is the transition prob
of going from state i at time t to state j
at time t+1 */
double **B; /* B[1..N][1..M]. b[j][k] is the probability of
of observing symbol k in state j */
double *pi; /* pi[1..N] pi[i] is the initial state distribution. */
} HMM;




void print_hmm(HMM *hmm_ptr);
void get_hmm_from_file(FILE *fp, HMM *hmm_ptr);
void free_hmm(HMM *hmm);
Expand All @@ -90,4 +84,4 @@ double dist_rt(int dist);
double dist_id(int dist);
double dist_ie(int dist);
double get_prob(int state, int start, int end, char *O, char *hmmerv);

89 changes: 89 additions & 0 deletions mgescan/nonltr/hmm/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <string.h>
#include "hmm.h"

int main (int argc, char **argv){

int c;
char *hmm_file, *seq_file, *sig1_file, *sig2_file, *out_file, *phmm_dir, *out_dir, *hmmerv;
int debug=1;
FILE *fp;
HMM hmm;

int i,j;
int num_seqs;
char **obs_seqs;

char *O;
int T;
double **alpha, **beta;
double pprob;
int *vpath;

/* read command line argument */
while ((c=getopt(argc, argv, "m:s:r:a:o:p:d:v:")) != -1){

switch (c){
case 'm':
hmm_file = optarg; /* HMM */
break;

case 's':
seq_file = optarg; /* DNA SEQ */
break;

case 'a':
sig1_file = optarg; /* APE */
break;

case 'r':
sig2_file = optarg; /* RT */
break;

case 'o':
out_file = optarg; /* output */
break;

case 'p':
phmm_dir = optarg; /* program main dir */
break;

case 'd':
out_dir = optarg; /* out1 dir */
break;

case 'v':
hmmerv = optarg; /* hmmer version */
break;

}
}

/* read initial model */
fp = fopen(hmm_file, "r");
get_hmm_from_file(fp, &hmm);
fclose(fp);
/*print_hmm(&hmm);*/

/* read observation seq */
fp = fopen(seq_file, "r");
read_obs_seq_from_file(fp, &num_seqs, &obs_seqs);
fclose(fp);

/* test */
for (i=0; i<num_seqs; i++){
T = strlen(obs_seqs[i]);
viterbi(&hmm, T, obs_seqs[i], &pprob, vpath, sig1_file, sig2_file, out_file, phmm_dir, out_dir, hmmerv);
}
/* free memory */
free_hmm(&hmm);
for (i=0; i<num_seqs; i++){
free(obs_seqs[i]);
}
free(obs_seqs);

}
2 changes: 1 addition & 1 deletion mgescan/nonltr/hmm/makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CC = gcc
CFLAGS = -O3 -Wall -w # -g -O0 for gdb
SRCS = util_lib.c hmm_lib.c test_hmm.c
SRCS = util_lib.c hmm_lib.c main.c
OBJS = $(SRCS:.c=.o)
MAIN = MGEScan

Expand Down
90 changes: 0 additions & 90 deletions mgescan/nonltr/hmm/test_hmm.c

This file was deleted.

0 comments on commit f4c0b55

Please sign in to comment.