⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 structs.h

📁 马尔科夫模型的java版本实现
💻 H
📖 第 1 页 / 共 2 页
字号:
#include <time.h>#include <stdio.h>/* various constants */#define END -999 /* used in to_trans_array, from_trans_array, silent_vertices, etc		  * for marking the end of a transition group */#define TOT_END -1010 /* used as a more final end marker than END */#define DEFAULT 99.0 /* used in log_matrices to represent probability 0.0 */#define NO_PREV -1 /* used in viterbi to indicate no max value is found yet */#define NOPROB -1 /* used in forward, backward and viterbi for signaling to		   * caller that the given sequence has 0 prob of being produced		   * by the hmm */#define OK 0 /* all went as expected in the function that returns this value */#define SILENT 888.0 /* if emission probability = SILENT (in emissions and log emissions)		      * then this state is a silent state */#define MAX_SEQ_NAME_SIZE 100 /* maximal size of a sequence name, if larger it will			       * simply be truncated */#define MAX_GAP_SIZE 20 /* maximum gap size, meaning paths between states longer than this value will			 * be disregarded */#define ENDLETTER '\0'#define NO -1#define YES 0#define OH_MY_YES 100/* hmm file types */#define SINGLE_HMM 0#define MULTI_HMM 1/* core alg scoring methods for msa */#define DOT_PRODUCT 1#define SUBST_MTX_DOT_PRODUCT 3#define SUBST_MTX_PRODUCT 2#define SUBST_MTX_DOT_PRODUCT_PRIOR 4#define SJOLANDER 5#define PICASSO 6#define PICASSO_SYM 7#define DOT_PRODUCT_PICASSO 8#define SJOLANDER_REVERSED 9/* multi alphabet scoring methods */#define JOINT_PROB 10#define AVERAGE 11/* training algorithms */#define BW_STD 0#define CML_STD 1/* types of modules */#define SINGLENODE 2#define CLUSTER 3#define SINGLELOOP 4#define FORWARD_STD 5#define FORWARD_ALT 6#define PROFILE7 7#define PROFILE9 9/* types of vertices */#define STANDARDV 101#define SILENTV 102#define STARTV 100#define LOCKEDV 104#define PROFILEV 103#define ENDV 999/* sequence formats */#define STANDARD 0 /* default */#define FASTA 1#define LABELED 3#define PROFILE 4#define MSA_STANDARD 2/* score algorithms */#define FORW_ALG 10#define VITERBI_ALG 11#define ONE_BEST_ALG 12/* max alphabet size */#define MAX_NR_ALPHABETS 4;/* alphabet types */#define DISCRETE 1#define CONTINUOUS 2/* model maker options */#define FAST 1#define QUERY 2#define HAND 3/* weighting schemes */#define NONE -2#define HENIKOFF 1//#define DEBUG//#define DEBUG2/* Structure: hmm_s *  * Declaration of a general HMM */struct hmm_s {    /* general info */  char name[100];  /* name of the HMM */  struct time_t *constr_t; /* time of construction */  char alphabet[1000]; /* the alphabet */  int alphabet_type; /* discrete or continuous */  int a_size; /* size of alphabet */  int nr_m; /* nr of modules */  int nr_v; /* nr of vertices (states) */  int nr_t; /* nr of transitions */  int nr_d; /* nr of distribution groups */  int nr_dt; /* total nr of distribution ties */  int nr_ttg; /* nr of transition tie groups */  int nr_tt; /* total nr of transition ties */  int nr_ed; /* nr of emission dirichlet structs */  int nr_tp;  int startnode; /* nr of startnode */  int endnode; /* nr of endnode */  struct replacement_letter_s *replacement_letters; /* pointer to wildcard letters */  struct module_s **modules; /* pointer to array of pointers to the modules */  /* data structures */  int *silent_vertices; /* pointer to array of the silent vertices */  int *locked_vertices; /* pointer to arrray of locked vertices */  char *vertex_labels; /* pointer to array of vertex labels */  char *labels; /* pointer to array which contains the set of vertex labels */  int nr_labels; /* the number of labels (set count) for this hmm */  double *vertex_trans_prior_scalers; /* pointer to values that decide how to weight prior distribution contribution				       * when updating vertex parameters */  double *vertex_emiss_prior_scalers; /* --------------------------------- " --------------------------------------- */  double *transitions; /* pointer to transition probabilities matrix,		       * from_v on vertical, to_v on horizontal */  double *log_transitions; /* pointer to log of trans probs, for viterbi */  double *emissions; /* pointer to emission probabilities matrix, letters on horizontal,		     *  vertices on vertical */  double *log_emissions; /* pointer to log of emiss probs, for viterbi */  double *tot_transitions; /* pointer to transition probability matrix storing the total prob of going from a to b, adding all			    * paths via silent vertices */  double *max_log_transitions; /* pointer to log of maximal transprob for going from a to b of all possible paths via silent states*/  struct path_element **from_trans_array; /* pointer to an array that for each vertex stores					   * a pointer to the paths to the vertices that has					   * a transition to that vertex (including via one or more					   * silent states */  struct path_element **to_trans_array; /* pointer to an array that for each vertex stores					 * a pointer to the paths to the vertices that it has					 * a transition to (including via one or more silent					 * states) */  int **to_silent_trans_array; /* pointer to array that for each vertex stores a pointer to the silent vertices this vertex				* has a DIRECT transition to */  struct path_element **tot_to_trans_array;  /* pointer to an array that for each vertex stores					      * a pointer to the vertices that it has					      * a transition to (including via one or more silent					      * states) */  struct path_element **tot_from_trans_array; /* pointer to an array that for each vertex stores					       * a pointer to the vertices that has					       * a transition to that vertex (including via one or more					       * silent states */  int *distrib_groups; /* a pointer to the arrays for the distribution groups,			* i.e. groups of vertices that have identical emission			* probabilities */  struct transition_s *trans_tie_groups; /* a pointer to the arrays for the transition tie groups, 					   * i.e. groups of transitions that have identical transition probabilities */  struct emission_dirichlet_s *emission_dirichlets; /* pointer to the different dirichlet						     * mixtures */  struct emission_dirichlet_s **ed_ps; /* pointer to array of pointers (one for each state)					* to the different dirichlet mixtures */  double *subst_mtx; /* substitution matrix array giving the probability of two alphabet letters  being related */};struct hmm_multi_s {    /* general info */  char name[100];  /* name of the HMM */  struct time_t *constr_t; /* time of construction */  int nr_alphabets;  char alphabet[1000]; /* the alphabet */  char alphabet_2[1000]; /* the alphabet */  char alphabet_3[1000]; /* the alphabet */  char alphabet_4[1000]; /* the alphabet */  int alphabet_type; /* discrete or continuous */  int alphabet_type_2; /* discrete or continuous */  int alphabet_type_3; /* discrete or continuous */  int alphabet_type_4; /* discrete or continuous */  int a_size; /* size of alphabet */  int a_size_2; /* size of alphabet */  int a_size_3; /* size of alphabet */  int a_size_4; /* size of alphabet */  int nr_m; /* nr of modules */  int nr_v; /* nr of vertices (states) */  int nr_t; /* nr of transitions */  int nr_d; /* nr of distribution groups */  int nr_dt; /* total nr of distribution ties */  int nr_ttg; /* nr of transition tie groups */  int nr_tt; /* total nr of transition ties */  int nr_ed; /* nr of emission dirichlet structs */  int nr_ed_2; /* nr of emission dirichlet structs */  int nr_ed_3; /* nr of emission dirichlet structs */  int nr_ed_4; /* nr of emission dirichlet structs */  int nr_tp;  int startnode; /* nr of startnode */  int endnode; /* nr of endnode */  struct replacement_letter_multi_s *replacement_letters; /* pointer to wildcard letters */    struct module_multi_s **modules; /* pointer to array of pointers to the modules */  /* data structures */  int *silent_vertices; /* pointer to array of the silent vertices */  int *locked_vertices; /* pointer to arrray of locked vertices */  char *vertex_labels; /* pointer to array of vertex labels */  char *labels; /* pointer to array which contains the set of vertex labels */  int nr_labels; /* the number of labels (set count) for this hmm */  double *vertex_trans_prior_scalers; /* pointer to values that decide how to weight prior distribution contribution				       * when updating vertex parameters */  double *vertex_emiss_prior_scalers; /* --------------------------------- " --------------------------------------- */  double *vertex_emiss_prior_scalers_2; /* --------------------------------- " --------------------------------------- */  double *vertex_emiss_prior_scalers_3; /* --------------------------------- " --------------------------------------- */  double *vertex_emiss_prior_scalers_4; /* --------------------------------- " --------------------------------------- */  double *transitions; /* pointer to transition probabilities matrix,		       * from_v on vertical, to_v on horizontal */  double *log_transitions; /* pointer to log of trans probs, for viterbi */  double *emissions; /* pointer to emission probabilities matrix, letters on horizontal,		      *  vertices on vertical */  double *emissions_2; /* pointer to emission probabilities matrix, letters on horizontal,			*  vertices on vertical */  double *emissions_3; /* pointer to emission probabilities matrix, letters on horizontal,			*  vertices on vertical */  double *emissions_4; /* pointer to emission probabilities matrix, letters on horizontal,			*  vertices on vertical */  double *log_emissions; /* pointer to log of emiss probs, for viterbi */  double *log_emissions_2; /* pointer to log of emiss probs, for viterbi */  double *log_emissions_3; /* pointer to log of emiss probs, for viterbi */  double *log_emissions_4; /* pointer to log of emiss probs, for viterbi */  double *tot_transitions; /* pointer to transition probability matrix storing the total prob of going from a to b, adding all			   * paths via silent vertices */  double *max_log_transitions; /* pointer to log of maximal transprob for going from a to b of all possible paths via silent states*/  struct path_element **from_trans_array; /* pointer to an array that for each vertex stores					   * a pointer to the paths to the vertices that has					   * a transition to that vertex (including via one or more					   * silent states */  struct path_element **to_trans_array; /* pointer to an array that for each vertex stores					 * a pointer to the paths to the vertices that it has					 * a transition to (including via one or more silent					 * states) */  int **to_silent_trans_array; /* pointer to array that for each vertex stores a pointer to the silent vertices this vertex				* has a DIRECT transition to */    struct path_element **tot_to_trans_array;  /* pointer to an array that for each vertex stores					      * a pointer to the vertices that it has					      * a transition to (including via one or more silent					      * states) */  struct path_element **tot_from_trans_array; /* pointer to an array that for each vertex stores					       * a pointer to the vertices that has					       * a transition to that vertex (including via one or more					       * silent states */  int *distrib_groups; /* a pointer to the arrays for the distribution groups,			* i.e. groups of vertices that have identical emission			* probabilities */  struct transition_s *trans_tie_groups; /* a pointer to the arrays for the transition tie groups, 					   * i.e. groups of transitions that have identical transition probabilities */  struct emission_dirichlet_s *emission_dirichlets; /* pointer to the different dirichlet						     * mixtures */  struct emission_dirichlet_s *emission_dirichlets_2; /* pointer to the different dirichlet						       * mixtures */  struct emission_dirichlet_s *emission_dirichlets_3; /* pointer to the different dirichlet						       * mixtures */  struct emission_dirichlet_s *emission_dirichlets_4; /* pointer to the different dirichlet						       * mixtures */  struct emission_dirichlet_s **ed_ps; /* pointer to array of pointers (one for each state)					* to the different dirichlet mixtures */  struct emission_dirichlet_s **ed_ps_2; /* pointer to array of pointers (one for each state)					  * to the different dirichlet mixtures */  struct emission_dirichlet_s **ed_ps_3; /* pointer to array of pointers (one for each state)					  * to the different dirichlet mixtures */  struct emission_dirichlet_s **ed_ps_4; /* pointer to array of pointers (one for each state)					  * to the different dirichlet mixtures */  double *subst_mtx; /* substitution matrix array giving the probability of two alphabet letters  being related */  double *subst_mtx_2; /* substitution matrix array giving the probability of two alphabet letters  being related */  double *subst_mtx_3; /* substitution matrix array giving the probability of two alphabet letters  being related */  double *subst_mtx_4; /* substitution matrix array giving the probability of two alphabet letters  being related */};/* Structure: null_model_s * * Declaration of null model struct */struct null_model_s {  double trans_prob;  int a_size;  char alphabet[1000];  double *emissions;};/* Structure: null_model_multi_s * * Declaration of null model multi struct */struct null_model_multi_s {  int nr_alphabets;  double trans_prob;  int a_size;  int a_size_2;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -