📄 read_xml.cpp
字号:
/* * * created: 26 Feb 2002 by Wasinee Rungsarityotin * authors: Wasinee Rungsarityotin (rungsari@molgen.mpg.de) * file : $Source$ * $Id: read_xml.cpp 1033 2004-10-28 15:11:39Z benrich $ * revision date : $Date: 2004-10-28 17:11:39 +0200 (Thu, 28 Oct 2004) $ ___copyright__ */#include <stdio.h>#include <unistd.h>#include <assert.h>#include <ghmm/rng.h>#include "ghmm++/GHMM.h"#include "ghmm++/GHMM_GMLDoc.h"#include <iostream>#ifdef HAVE_NAMESPACESusing namespace std;#endifint main(int argc, char* argv[]) { GHMM_Document doc; // GHMM_GraphMLDoc doc; GHMM_DiscreteModel *dmo; GHMM_Sequences* training_seq = NULL; GHMM_Sequences* my_output = NULL; GHMM_Alphabet* alphas = NULL; /* Important! initialise rng */ GHMM_Toolkit::ghmm_rng_init(); doc.open("dna.xml", "r"); doc.readDocument(); doc.close(); dmo = doc.getDiscreteModel(); //dmo->setTransition(0,0,0.0); //dmo->setTransition(0,1,1.0); if (dmo->check() == -1) return 1; fprintf(stdout, "initial distribution:\n"); dmo->Pi_print(stdout," ",",","\n"); fprintf(stdout,"transition matrix:\n"); dmo->A_print(stdout,""," ","\n"); fprintf(stdout,"observation symbol matrix:\n"); dmo->B_print(stdout,""," ","\n"); alphas = dmo->getAlphabet(); assert( alphas != NULL ); for(int i=0; i < alphas->size(); i++) { cout << "Symbol " << i << ":"; cout << alphas->getSymbol(i) << endl; } if ( ( training_seq = doc.getSequences() ) != NULL ) { training_seq->print(stdout); printf("reestimating with Baum-Welch-algorithm..."); dmo->reestimate_baum_welch( training_seq ); /* print the result */ printf("Done\nthe result is:\n"); dmo->A_print(stdout,""," ","\n"); fprintf(stdout,"observation symbol matrix:\n"); dmo->B_print(stdout,""," ","\n"); my_output = dmo->generate_sequences(1,10,10); my_output->print(stdout); doc.open("dna2.xml","w"); // Try writing to a new format!!!! doc.writeElement(dmo); doc.writeEndl(); doc.writeEndl(); //doc.writeElement(training_seq); doc.writeEndl(); doc.close(); cout << "Wrote to dna2.xml" << endl; } delete my_output; delete alphas; SAFE_DELETE(dmo); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -