Permalink
Browse files

moved Bio::Tools::HMM and Bio::Ext::HMM into their own distro, got th…

…em compiling cleanly. tests not passing yet

svn path=/bioperl-ext/trunk/; revision=15966
  • Loading branch information...
1 parent 82779ba commit d3f0ee3804107176ec6dbdf5a5ef6fd66ccaee29 rbuels committed Aug 17, 2009
Showing with 0 additions and 1,179 deletions.
  1. +0 −49 Bio/Ext/HMM/HMM.pm
  2. +0 −205 Bio/Ext/HMM/HMM.xs
  3. +0 −13 Bio/Ext/HMM/Makefile.PL
  4. +0 −36 Bio/Ext/HMM/hmm.h
  5. +0 −764 Bio/Ext/HMM/hmmlib.c
  6. +0 −102 Bio/Ext/HMM/test.pl
  7. +0 −10 Bio/Ext/HMM/typemap
View
@@ -1,49 +0,0 @@
-
-package Bio::Ext::HMM;
-
-use vars qw($AUTOLOAD @ISA @EXPORT_OK $dl_debug);
-use Exporter;
-use Carp;
-use strict;
-
-use DynaLoader;
-
-
-@ISA = qw(Exporter DynaLoader);
-# Items to export into callers namespace by default. Note: do not export
-# names by default without a very good reason. Use EXPORT_OK instead.
-# Do not simply export all your public functions/methods/constants.
-
-sub AUTOLOAD {
- # This AUTOLOAD is used to 'autoload' constants from the constant()
- # XS function. If a constant is not found then control is passed
- # to the AUTOLOAD in AutoLoader.
-
- my $constname;
- ($constname = $AUTOLOAD) =~ s/.*:://;
- my $val = constant($constname, @_ ? $_[0] : 0);
- if ($! != 0) {
- if ($! =~ /Invalid/) {
- $AutoLoader::AUTOLOAD = $AUTOLOAD;
- goto &AutoLoader::AUTOLOAD;
- }
- else {
- croak "Your vendor has not defined Test macro $constname";
- }
- }
- eval "sub $AUTOLOAD { $val }";
- goto &$AUTOLOAD;
-}
-
-BEGIN {
- $dl_debug = 40;
-}
-
-bootstrap Bio::Ext::HMM; # hopefully has the correct things...
-
-# Preloaded methods go here.
-
-# Autoload methods go after __END__, and are processed by the autosplit program.
-
-1;
-__END__
View
@@ -1,205 +0,0 @@
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-#ifdef __cplusplus
-}
-#endif
-
-#include "hmm.h"
-
-MODULE = Bio::Ext::HMM PACKAGE = Bio::Ext::HMM
-
-void
-HMM_statistical_training(class, hmm, obs, hs)
- char * class
- HMM * hmm
- SV * obs
- SV * hs
- CODE:
- AV * obs_av = (AV *) SvRV(obs);
- AV * hs_av = (AV *) SvRV(hs);
- int i;
- int avlen = av_len(obs_av);
- char ** obs_ar = (char **) malloc(avlen*sizeof(char *));
- char ** hs_ar = (char **) malloc(avlen*sizeof(char *));
- int * obs_len = (int *) malloc(avlen*sizeof(int));
- if (obs_ar == NULL || hs_ar == NULL)
- croak("Can't allocate memory for observation and/or state arrays!\n");
- if (obs_len == NULL)
- croak("Can't allocate memory for observation length array!\n");
- for (i = 0; i < avlen; ++i) {
- obs_ar[i] = (char *) SvPV(*av_fetch(obs_av, i, 0), PL_na);
- obs_len[i] = strlen(obs_ar[i]);
- obs_ar[i] = (char *) malloc((obs_len[i]+1)*sizeof(char));
- if (obs_ar[i] == NULL)
- croak("Can't allocate memory for observation array!\n");
- strcpy(obs_ar[i], (char *) SvPV(*av_fetch(obs_av, i, 0), PL_na));
- hs_ar[i] = (char *) malloc((obs_len[i]+1)*sizeof(char));
- if (hs_ar[i] == NULL)
- croak("Can't allocate memory for state array!\n");
- strcpy(hs_ar[i], (char *) SvPV(*av_fetch(hs_av, i, 0), PL_na));
- omap(hmm, obs_ar[i], obs_len[i]);
- smap(hmm, hs_ar[i], obs_len[i]);
- }
- state_est(hmm, obs_ar, hs_ar, obs_len, avlen);
- for (i = 0; i < avlen; ++i) {
- free(obs_ar[i]);
- free(hs_ar[i]);
- }
- free(obs_ar);
- free(hs_ar);
- free(obs_len);
-
-double
-HMM_likelihood(class, hmm, seq)
- char * class
- HMM * hmm
- char * seq
- CODE:
- int T = strlen(seq);
- char obs[T+1];
- strcpy(obs, seq);
- omap(hmm, obs, T);
- RETVAL = Palpha(hmm, obs, T);
- OUTPUT:
- RETVAL
-
-void
-HMM_baum_welch_training(class, hmm, obs)
- char * class
- HMM * hmm
- SV * obs
- PPCODE:
- AV * obs_av = (AV *) SvRV(obs);
- int i;
- int avlen = av_len(obs_av);
- char ** obs_ar = (char **) malloc(avlen*sizeof(char *));
- int * obs_len = (int *) malloc(avlen*sizeof(int));
- if (obs_ar == NULL)
- croak("Can't allocate memory for observation arrays!\n");
- if (obs_len == NULL)
- croak("Can't allocate memory for observation length array!\n");
- for (i = 0; i < avlen; ++i) {
- obs_ar[i] = (char *) SvPV(*av_fetch(obs_av, i, 0), PL_na);
- obs_len[i] = strlen(obs_ar[i]);
- obs_ar[i] = (char *) malloc((obs_len[i]+1)*sizeof(char));
- if (obs_ar[i] == NULL)
- croak("Can't allocate memory for observation array!\n");
- strcpy(obs_ar[i], (char *) SvPV(*av_fetch(obs_av, i, 0), PL_na));
- omap(hmm, obs_ar[i], obs_len[i]);
- }
- baum_welch(hmm, obs_ar, obs_len, avlen);
- for (i = 0; i < avlen; ++i)
- free(obs_ar[i]);
- free(obs_ar);
-
-SV *
-HMM_viterbi(class, hmm, seq)
- char * class
- HMM * hmm
- char * seq
- PPCODE:
- SV * sv;
- int T = strlen(seq);
- char * hss = (char *) malloc((T+1)*sizeof(char));
- char obs[T+1];
- if (hss == NULL)
- croak("Can't allocate memory for hidden state sequence!\n");
- strcpy(obs, seq);
- omap(hmm, obs, T);
- viterbi(hmm, hss, obs, T);
- sv = newSVpv(hss, strlen(hss));
- free(hss);
- PUSHs(sv_2mortal(sv));
-
-
-MODULE = Bio::Ext::HMM PACKAGE = Bio::Ext::HMM::HMM
-
-HMM *
-new(class, symbols, states)
- char * class
- char * symbols
- char * states
- CODE:
- RETVAL = HMM_new(symbols, states);
- OUTPUT:
- RETVAL
-
-double
-get_init_entry(class, hmm, state)
- char * class
- HMM * hmm
- char * state
- CODE:
- RETVAL = HMM_get_init_entry(hmm, state);
- OUTPUT:
- RETVAL
-
-void
-set_init_entry(class, hmm, state, val)
- char * class
- HMM * hmm
- char * state
- double val
- CODE:
- HMM_set_init_entry(hmm, state, val);
-
-double
-get_a_entry(class, hmm, state1, state2)
- char * class
- HMM * hmm
- char * state1
- char * state2
- CODE:
- RETVAL = HMM_get_a_entry(hmm, state1, state2);
- OUTPUT:
- RETVAL
-
-void
-set_a_entry(class, hmm, state1, state2, val)
- char * class
- HMM * hmm
- char * state1
- char * state2
- double val
- CODE:
- HMM_set_a_entry(hmm, state1, state2, val);
-
-double
-get_e_entry(class, hmm, state, symbol)
- char * class
- HMM * hmm
- char * state
- char * symbol
- CODE:
- RETVAL = HMM_get_e_entry(hmm, state, symbol);
- OUTPUT:
- RETVAL
-
-void
-set_e_entry(class, hmm, state, symbol, val)
- char * class
- HMM * hmm
- char * state
- char * symbol
- double val
- CODE:
- HMM_set_e_entry(hmm, state, symbol, val);
-
-void
-DESTROY(obj)
- HMM * obj
- PPCODE:
- int i;
- free(obj->init);
- for (i = 0; i < obj->N; ++i)
- free(obj->a_mat[i]);
- free(obj->a_mat);
- for (i = 0; i < obj->N; ++i)
- free(obj->e_mat[i]);
- free(obj->e_mat);
-
View
@@ -1,13 +0,0 @@
-use ExtUtils::MakeMaker;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
-WriteMakefile(
- 'NAME' => 'Bio::Ext::HMM',
- 'VERSION' => '0.1',
- 'LIBS' => ['-lm'], # e.g., '-lm'
- 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
- 'INC' => '', # e.g., '-I/usr/include/other'
- 'OBJECT' => 'HMM.o hmmlib.o',
- 'clean' => { 'FILES' => '*.o' }
-);
-
View
@@ -1,36 +0,0 @@
-#ifndef _HMM_H_
-#define _HMM_H_
-
-typedef struct HMM
-{
- int M;
- int N;
- char * symbols;
- unsigned char omap[256];
- char * states;
- unsigned char smap[256];
- double * init;
- double ** a_mat;
- double ** e_mat;
-} HMM;
-
-#define UPPER_TOL 0.000001
-#define LOWER_TOL 1e-100
-
-HMM * init_HMM(char *, char *, double *, double **, double **);
-HMM * HMM_new(char *, char *);
-double HMM_get_init_entry(HMM *, char *);
-void HMM_set_init_entry(HMM *, char *, double);
-double HMM_get_a_entry(HMM *, char *, char *);
-void HMM_set_a_entry(HMM *, char *, char *, double);
-double HMM_get_e_entry(HMM *, char *, char *);
-void HMM_set_e_entry(HMM *, char *, char *, double);
-void omap(HMM *, char *, int);
-void smap(HMM *, char *, int);
-double Palpha(HMM *, char *, int);
-double Pbeta(HMM *, char *, int);
-void viterbi(HMM *, char *, char *, int);
-void state_est(HMM *, char **, char **, int *, int);
-void baum_welch(HMM *, char **, int *, int);
-
-#endif
Oops, something went wrong.

0 comments on commit d3f0ee3

Please sign in to comment.