📄 ghmmwrapper_wrap.c
字号:
if (!SWIG_AsVal_double(obj, &v)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(double)); } return v;} SWIGINTERNSHORT intSWIG_Check_double(PyObject* obj){ return SWIG_AsVal_double(obj, (double*)0);} /*@D:\\PROGRAM FILES\\SWIG\\Lib\\python\\pymacros.swg,66,SWIG_define@*/#define SWIG_From_double PyFloat_FromDouble/*@@*/static sequence_t ** *new_sequence_setPtr() { return (sequence_t ** *) calloc(1,sizeof(sequence_t **)); }static sequence_t ** *copy_sequence_setPtr(sequence_t ** value) { sequence_t ** *self = (sequence_t ** *) calloc(1,sizeof(sequence_t **)); *self = value; return self; }static void delete_sequence_setPtr(sequence_t ** *self) { if (self) free(self); }static void sequence_setPtr_assign(sequence_t ** *self, sequence_t ** value) { *self = value;}static sequence_t ** sequence_setPtr_value(sequence_t ** *self) { return *self;}static sequence_d_t ** *new_sequence_d_setPtr() { return (sequence_d_t ** *) calloc(1,sizeof(sequence_d_t **)); }static sequence_d_t ** *copy_sequence_d_setPtr(sequence_d_t ** value) { sequence_d_t ** *self = (sequence_d_t ** *) calloc(1,sizeof(sequence_d_t **)); *self = value; return self; }static void delete_sequence_d_setPtr(sequence_d_t ** *self) { if (self) free(self); }static void sequence_d_setPtr_assign(sequence_d_t ** *self, sequence_d_t ** value) { *self = value;}static sequence_d_t ** sequence_d_setPtr_value(sequence_d_t ** *self) { return *self;}sequence_t *sequence_calloc(long);sequence_d_t *sequence_d_calloc(long);void sequence_clean(sequence_t *);void sequence_d_clean(sequence_d_t *);int sequence_d_add(sequence_d_t *,sequence_d_t *);void sequence_d_print(FILE *,sequence_d_t *,int); /* return a C-pointer to an integer sequence */ int *get_onesequence(sequence_t *seqpt, int seqnumber) { return (int *) seqpt->seq[seqnumber]; } sequence_t *seq_read(char* filename ){ int i; sequence_t** s; //s = (sequence_d_t **) malloc(1*sizeof(sequence_d_t*)); s = sequence_read(filename, &i); return s[0]; } sequence_t* get_seq_ptr(sequence_t** array, int index){ return (sequence_t*) array[index]; } /*** create and manipulate an array of pointers of pointers to sequence_d_t structs ***/ sequence_d_t **sequence_d_t_array(int size) { int i; sequence_d_t **s; s = (sequence_d_t **) malloc(size*sizeof(sequence_d_t*)); for(i =0;i<size;i++){ s[i] = NULL; } return s; } sequence_d_t* get_seq_d_ptr(sequence_d_t** array, int index){ return (sequence_d_t*) array[index]; } void set_seq_d_array(sequence_d_t** array, int index,sequence_d_t* seq){ array[index] = seq; } void set_sequence_d_label(sequence_d_t* seq, int seq_num, long label){ seq->seq_label[seq_num] = label; } long get_sequence_d_label(sequence_d_t* seq, int seq_num ){ return seq->seq_label[seq_num]; } sequence_d_t *seq_d_read(char* filename ){ int i; sequence_d_t** s; //s = (sequence_d_t **) malloc(1*sizeof(sequence_d_t*)); s = sequence_d_read(filename, &i); return *s; } void call_sequence_print(char* ch, sequence_t* seq){ FILE* file_name; file_name = fopen(ch,"at"); sequence_print(file_name,seq); fclose(file_name); } void call_sequence_d_print(char* ch,sequence_d_t* seq, int disc){ FILE* file_name; file_name = fopen(ch,"at"); sequence_d_print(file_name,seq, disc); fclose(file_name); } SWIGINTERN PyObject *SWIG_FromCharPtr(const char* cptr){ if (cptr) { size_t size = strlen(cptr); if (size > INT_MAX) { return SWIG_NewPointerObj((char*)(cptr), SWIG_TypeQuery("char *"), 0); } else { if (size != 0) { return PyString_FromStringAndSize(cptr, size); } else { return PyString_FromString(cptr); } } } Py_INCREF(Py_None); return Py_None;}int model_free(model **);model **model_read(char *,int *);model **model_from_sequence_ascii(scanner_t *,long *);model **model_from_sequence(sequence_t *,long *);model *model_copy(model const *);int model_check(model const *);int model_check_compatibility(model **,int);model *model_generate_from_sequence(int const *,int,int);sequence_t *model_generate_sequences(model *,int,int,long,int);double model_likelihood(model *,sequence_t *);int reestimate_baum_welch(model *,sequence_t *);int reestimate_baum_welch_nstep(model *,sequence_t *,int,double);void reestimate_update_tie_groups(model *);int reestimate_baum_welch_label(model *,sequence_t *);int reestimate_baum_welch_nstep_label(model *,sequence_t *,int,double);int gradient_descent(model **,sequence_t *);int *kbest(model *,int *,int,int,double *);int *viterbi(model *,int *,int,double *);double viterbi_logp(model *,int *,int,int *);int discriminative(model **,sequence_t **,int,int);double discrime_compute_performance(model **,sequence_t **,int);model **discrime_modelarray_alloc(int);void discrime_modelarray_dealloc(model **);void discrime_modelarray_setptr(model **,model *,int);model *discrime_modelarray_getptr(model **,int);sequence_t **discrime_seqarray_alloc(int);void discrime_seqarray_dealloc(sequence_t **);void discrime_seqarray_setptr(sequence_t **,sequence_t *,int);sequence_t *discrime_seqarray_getptr(sequence_t **,int);int foba_forward(model *,int const *,int,double **,double *,double *);int foba_backward(model *,int const *,int,double **,double const *);int foba_logp(model *,int const *,int,double *);void model_set_transition(model *,int,int,double);int foba_label_forward(model *,int const *,int const *,int,double **,double *,double *);int foba_label_logp(model *,int const *,int const *,int,double *);int foba_label_backward(model *,int const *,int const *,int,double **,double *,double *);background_distributions *model_copy_background_distributions(background_distributions *);int model_free_background_distributions(background_distributions *);int get_emission_index(model *,int,int,int);void update_emission_history(model *,int);void update_emission_history_front(model *,int);int model_normalize(model *);int model_add_noise(model *,double,int);int model_apply_background(model *,double *); /* allocation of an empty model struct*/ model *new_model() { return (struct model *)(struct model *) calloc(1, sizeof(struct model)); } /* allocation of an array of state structs*/ state *arraystate(int size) { return (state *) malloc(size*sizeof(state)); } /* extract pointer to a state */ state *get_stateptr(state *ary, int index) { return ary + index; } void call_model_print(char *filename, model *mo) { FILE *fp=fopen(filename, "a"); if (fp == NULL) { fprintf(stderr, "call_smodel_print(0): cannot open file %s\n", filename); } else { model_print(fp, mo); fclose(fp); } } void call_model_free(model *mo ) {model_free(&mo);} model *get_model_ptr(model **mo, int index) { return mo[index]; } model **cast_model_ptr(model *mo){ model** result = &mo; return result; } sequence_t *model_label_generate_sequences(model *,int,int,long,int);double sdmodel_likelihood(sdmodel *,sequence_t *);int smodel_individual_likelihoods(smodel *,sequence_d_t *,double *);int sdfoba_forward(sdmodel *,int const *,int,double **,double *,double *);int cp_class_change(int *,int);void setSwitchingFunction(sdmodel *); void call_sdmodel_free(sdmodel * sdm) { sdmodel_free(&sdm); } /* allocation of an array of sdstate structs*/ sdstate *arraysdstate(int size) { return (sdstate *) malloc(size*sizeof(sdstate)); } /* extract pointer to a sdstate */ sdstate *get_sdstateptr(sdstate *ary, int index) { return ary + index; } int smodel_free(smodel **);smodel **smodel_read(char const *,int *);smodel *smodel_copy(smodel const *);sequence_d_t *smodel_generate_sequences(smodel *,int,int,long,long,int);double smodel_prob_distance(smodel *,smodel *,int,int,int);int sfoba_forward(smodel *,double const *,int,double ***,double **,double *,double *);int sfoba_backward(smodel *,double const *,int,double ***,double **,double const *);int sfoba_logp(smodel *,double const *,int,double *);smodel *smodel_alloc_fill(int,int,int,double,int);void smodel_set_pivector(smodel *,int,double);void smodel_set_fixvector(smodel *,int,double);void smodel_set_transition(smodel *,int,int,int,double);double smodel_get_transition(smodel *,int,int,int);void smodel_set_mean(smodel *,int,double *);void smodel_set_variance(smodel *,int,double *);int smodel_likelihood(smodel *,sequence_d_t *,double *);int smodel_sorted_individual_likelihoods(smodel *,sequence_d_t *,double *,int *);int *sviterbi(smodel *,double *,int,double *); void set_trunc_density(smodel* smo){ smo->density = (density_t) 1 ; } /*allocation of an empty smodel struct */ smodel *new_smodel() { return (struct smodel *)(struct smodel *) calloc(1, sizeof(struct smodel)); } /* array of sstate structs */ sstate *arraysstate(int size) { return (sstate *) malloc(size*sizeof(sstate)); } sstate *get_sstate_ptr(sstate *states, int k) { return &(states[k]); } void call_smodel_free(smodel *smo ) {smodel_free(&smo);} void free_smodel_array(smodel **smo) { if (smo){ m_free(smo);} } void smodel_print_stdout(smodel *smo) { smodel_print(stdout, smo); } /* extract pointer to sstate */ sstate *get_sstate(smodel *smo, int k) { return &(smo->s[k]); } /* creation and assessor functions for an array of smodels */ smodel **smodel_array(int size){ return (smodel**) malloc(size * sizeof(smodel*)); } smodel *get_smodel_ptr(smodel **smo, int index) { return smo[index]; } void set_smodel_ptr(smodel **smo_array ,smodel *smo, int index) { smo_array[index] = smo; } smodel **cast_smodel_ptr(smodel *smo){ smodel** res = (smodel**) malloc(sizeof(smodel*)); res[0] = smo; return res; } // write a smodel to a file void call_smodel_print(char *filename, smodel *smo) { FILE *fp=fopen(filename, "a"); if (fp == NULL) { fprintf(stderr, "call_smodel_print(0): cannot open file %s\n", filename); } else { smodel_print(fp, smo); fclose(fp); }}int scluster_t_free(scluster_t *);int scluster_random_labels(sequence_d_t *,int);void scluster_prob(smosqd_t *);int scluster_best_model(scluster_t *,long,double **,double *);int scluster_update(scluster_t *,sequence_d_t *);int scluster_log_aposteriori(scluster_t *,sequence_d_t *,int,double *);int scluster_avoid_empty_smodel(sequence_d_t *,scluster_t *);int scluster_hmm(char *[]); void scluster_printl_stdout(scluster_t *scl) { scluster_print_likelihood(stdout, scl); } int sreestimate_baum_welch(smosqd_t *); /************ create and manipulate an array of pointers to smosqd_t structs **************/ smosqd_t *smosqd_t_array(int size) { return (smosqd_t *) malloc(size*sizeof(smosqd_t)); } void set_smosq_t_smo(smosqd_t *cs, smodel *smo, int index){ cs[index].smo = smo; } smosqd_t get_smosqd_t_ptr(smosqd_t *cs, int i){ return cs[i];} void free_smosqd_t(smosqd_t *s){ if(s){ m_free(s); } } // Some array helpers /* Create any sort of int[size] array */ int *int_array(int size) { return (int *) malloc(size*sizeof(int)); } void set_arrayint(int *ary, int index, int value) { ary[index] = value; } int get_arrayint(int *ary, int index) { return ary[index]; } void free_arrayi(int *pt ) { m_free(pt); (pt) = NULL; } /************ Create and access double[size] arrays ************/ double *double_array(int size) { return (double *) malloc(size*sizeof(double)); } void set_arrayd(double *ary, int index, double value) { ary[index] = value; } double get_arrayd(double *ary, int index) { return ary[index]; } void free_arrayd(double *pt) { m_free(pt); (pt) = NULL;} /************ Create and access sort of long[size] arrays **************/ long *long_array(int size) { return (long *) malloc(size*sizeof(long)); } void set_arrayl(long *ary, int index, long value) { ary[index] = value; } double get_arrayl(long *ary, int index) { return ary[index]; } void free_arrayl(long *ary) {m_free(ary);(ary) = NULL;} /*********** Create and access char** arrays ***********/ char **char_array(int size) { return (char **) malloc(size*sizeof(char*)); } void set_arraychar(char** ary, int index, char* value) { ary[index] = value; } char *get_arraychar(char** ary, int index) { return ary[index]; } /************ Create and access double[size1][size2] arrays ************/ double **double_2d_array(int rows, int cols) { return matrix_d_alloc(rows,cols); } double **double_2d_array_nocols(int rows){ return (double **) malloc(rows*sizeof(double*)); } void set_2d_arrayd_col(double **ary, int index, double *col){ ary[index] = col; } void set_2d_arrayd(double **ary, int index1,int index2, double value) { ary[index1][index2] = value; } double get_2d_arrayd(double **ary, int index1, int index2) { return ary[index1][index2]; } double *get_col_pointer_d(double **ary, int index) { return ary[index]; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -