[med-svn] [Git][med-team/ghmm][master] 3 commits: Added files used to create test

Israel Komolehin (@Komolehin) gitlab at salsa.debian.org
Fri Jan 12 18:56:14 GMT 2024



Israel Komolehin pushed to branch master at Debian Med / ghmm


Commits:
564c1125 by Komolehin Israel Timilehin at 2024-01-12T18:45:12+00:00
Added files used to create test

- - - - -
662b2599 by Komolehin Israel Timilehin at 2024-01-12T18:45:50+00:00
Document test attempts and errors

- - - - -
33d3d425 by Komolehin Israel Timilehin at 2024-01-12T18:53:54+00:00
Updated readme

- - - - -


3 changed files:

- + debian/tests/README.md
- + debian/tests/ghmm_test.c
- + debian/tests/ghmm_test.py


Changes:

=====================================
debian/tests/README.md
=====================================
@@ -0,0 +1,30 @@
+## Installation
+
+`apt-get install libghmm-dev`
+
+## GHMM test in python
+
+Test in python can be referenced [here](https://ghmm.sourceforge.net/documentation.html)
+
+## Executed command
+`python3 ghmm_test.py`
+
+- `ModuleNotFoundError: No module named 'ghmm'`
+
+
+## GHMM test in C
+
+Test is referenced from ghmm/tests/two_states_three_symbols.c
+
+
+## Executed commands
+
+- `gcc -c ghmm_test.c -o ghmm_test.o -I/usr/include/ghmm`
+- `gcc ghmm_test.o -o ghmm_test -lghmm -llapack`
+- `./ghmm_test`
+
+#### Error
+- `./ghmm_test: symbol lookup error: /lib/x86_64-linux-gnu/libghmm.so.1: undefined symbol: clapack_dgetrf`
+
+
+


=====================================
debian/tests/ghmm_test.c
=====================================
@@ -0,0 +1,132 @@
+#include <stdio.h>
+#include <ghmm/rng.h>
+#include <ghmm/sequence.h>
+#include <ghmm/model.h>
+#include <ghmm/reestimate.h>
+
+/*
+  model with two states and three symbols
+  transition probability: 0->0: 0.9, 0->1: 0.1, 1->0: 0.1 and 1->1:0.9
+  state 0 has symbol 0 (probability 0.5) and 1 (probability 0.5)
+  state 1 has symbol 2
+*/
+int my_model()
+{
+  /* model structure, that contains states */
+  ghmm_dmodel my_model;
+  /* array of states */
+  ghmm_dstate model_states[2];
+
+  /* first state */
+  /*  probability of emmission of 0,1 or 2 */
+  double symbols_0_state[3]={0.5,0.5,0.0};
+  /* transition to which state is given in the following arrays */
+  int trans_id_0_state[2]={0,1};
+  /* transition probability from here to 0-state (self) and 1-state */
+  double trans_prob_0_state[2]={0.9,0.1};
+  /* transition probability from 0-state (self) and 1-state to this state */
+  double trans_prob_0_state_rev[2]={0.9,0.1};
+
+  /* second state , comments see above */
+  double symbols_1_state[3]={0.0,0.0,1.0};
+  int trans_id_1_state[2]={0,1};
+  double trans_prob_1_state[2]={0.1,0.9};
+  double trans_prob_1_state_rev[2]={0.1,0.9};
+  ghmm_dseq* my_output;
+
+  int pow_look[2] = {1,3};
+
+  /* flags indicating whether a state is silent */
+  /*int silent_array[2] =  {0,0};*/
+  
+  /* initialise state 0 */
+  /* start probability for this state */
+  model_states[0].pi = 0.5;
+  /* array with emission probabilities */
+  model_states[0].b=symbols_0_state;
+  /* number of fields in out_a and out_id */
+  model_states[0].out_states=2;
+  /* transition probability from this state */
+  model_states[0].out_a=trans_prob_0_state;
+  /* state ids belonging to the probability */
+  model_states[0].out_id=trans_id_0_state;
+  /* transition probability to this state */
+  /* in_states,in_id and in_a have the same function as above*/
+  model_states[0].in_states=2;
+  model_states[0].in_id=trans_id_0_state;
+  model_states[0].in_a=trans_prob_0_state_rev;
+  /* should emission probabilities be changed during reestimation? 1: no, else: yes*/
+  model_states[0].fix=0;
+  
+  /* initialise state 1 */
+  /* same meaning as above */
+  model_states[1].pi = 0.5;
+  model_states[1].b=symbols_1_state;
+  model_states[1].out_states=2;
+  model_states[1].out_a=trans_prob_1_state;
+  model_states[1].out_id=trans_id_1_state;
+  model_states[1].in_states=2;
+  model_states[1].in_id=trans_id_0_state;
+  model_states[1].in_a=trans_prob_1_state_rev;
+  model_states[1].fix=0;
+  
+    /* initialise model */
+  my_model.N=2; /* number of states, dimension of model.s */
+  my_model.M=3; /* number of symbols, dimension of states.b */
+  my_model.s=model_states; /* array of states */
+  my_model.prior=-1; /* probability of this model, used in a model array */
+
+  /*my_model.silent = silent_array;*/
+  my_model.pow_lookup = pow_look;
+  my_model.maxorder = 0;
+  my_model.model_type =0;
+  
+  
+    /* consistency check */
+  fprintf(stdout,"checking model:\n");
+  if (ghmm_dmodel_check(&my_model))
+    {
+      fprintf(stderr,"ghmm_dmodel_check failed!\n");
+      return 1;
+    }
+  fprintf(stdout,"model is ok\n");
+
+  /* print model parameters */
+  fprintf(stdout,"two_states_three_symbols model:\n");
+  ghmm_dmodel_print(stdout,&my_model);
+
+  /* generate sequences */
+  fprintf(stdout,"generating sequences:...");
+  my_output=ghmm_dmodel_generate_sequences(&my_model, /* model */
+				     0,   /* random seed */
+				     100, /* length of each sequence */
+				     100, /* no of sequences */
+		  			 100); /* maxT */ 
+  fprintf(stdout,"Done\n");
+  /*ghmm_dseq_print(stdout,my_output);*/
+
+  /* slight change of emission probabilities in state 0 */
+  symbols_0_state[0] = 0.6;
+  symbols_0_state[1] = 0.4;
+  symbols_0_state[2] = 0.0;
+
+  /* reestimation */
+  fprintf(stdout,"reestimating with Baum-Welch-algorithm...");
+  ghmm_dmodel_baum_welch(&my_model,my_output);
+
+  /* print the result */
+  fprintf(stdout,"Done\nthe result is:\n");
+  ghmm_dmodel_print(stdout,&my_model);
+
+  ghmm_dseq_free(&my_output);
+
+  return 0;
+}
+
+int main()
+{
+  /* Important! initialise rng  */
+//   ghmm_rng_init();
+
+  return my_model();
+}
\ No newline at end of file


=====================================
debian/tests/ghmm_test.py
=====================================
@@ -0,0 +1,3 @@
+import ghmm
+
+help(ghmm)
\ No newline at end of file



View it on GitLab: https://salsa.debian.org/med-team/ghmm/-/compare/8e490e66cddbbbd6146c50aad0b686e770973324...33d3d42554998e4fc75f0632ccc7a035f8bcd9a4

-- 
View it on GitLab: https://salsa.debian.org/med-team/ghmm/-/compare/8e490e66cddbbbd6146c50aad0b686e770973324...33d3d42554998e4fc75f0632ccc7a035f8bcd9a4
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20240112/02407c2e/attachment-0001.htm>


More information about the debian-med-commit mailing list