-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProfileCrossEntropy.cpp
92 lines (84 loc) · 3.19 KB
/
ProfileCrossEntropy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*---------------------------------------------------------------------------##
## Library:
## galosh::profuse
## File:
## ProfileCrossEntropy.cpp
## Author:
## D'Oleris Paul Thatcher Edlefsen [email protected]
## Description:
## The profileCrossEntropy program. It calculates the crossEntropy
## between two Profile HMMs (or if you call it with one profile it
## calculates the self entropy).
##
#******************************************************************************
#*
#* This file is part of profuse, a suite of programs for working with
#* Profile HMMs. Please see the document CITING, which should have been
#* included with this file. You may use at will, subject to the license
#* (Apache v2.0), but *please cite the relevant papers* in your documentation
#* and publications associated with uses of this library. Thank you!
#*
#* Copyright (C) 2015, 2011 by Paul T. Edlefsen, Fred Hutchinson Cancer
#* Research Center.
#*
#* profuse is free software: you can redistribute it and/or modify it under
#* the terms of the GNU Lesser Public License as published by the Free
#* Software Foundation, either version 3 of the License, or (at your option)
#* any later version.
#*
#* profuse is distributed in the hope that it will be useful, but WITHOUT
#* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser Public License for
#* more details.
#*
#* You should have received a copy of the GNU Lesser Public License along
#* with profuse. If not, see <http://www.gnu.org/licenses/>.
#*****************************************************************************/
#include "Algebra.hpp"
#include "Profile.hpp"
#include <iostream>
#ifdef __HAVE_MUSCLE
int g_argc;
char **g_argv;
#endif // __HAVE_MUSCLE
using namespace seqan;
int
main ( int const argc, char const ** argv )
{
#ifdef __PROFUSE_USE_AMINOS
typedef seqan::AminoAcid20 ResidueType;
#else // __PROFUSE_USE_AMINOS .. else
typedef seqan::Dna ResidueType;
#endif // __PROFUSE_USE_AMINOS .. else ..
if( argc < 2 ) {
cout << "Usage: " << argv[ 0 ] << " <input (galosh Profile) filename 1> [<input (galosh Profile) filename 2>]" << endl;
exit( 1 );
}
const bool be_verbose = ( argc > 3 );
if( be_verbose ) {
cout << "Reading profile from file '" << argv[ 1 ] << "'" << endl;
}
galosh::ProfileTreeRoot<ResidueType, floatrealspace> profile1;
profile1.fromFile( argv[ 1 ] );
if( be_verbose ) {
cout << "\tgot:" << std::endl;
cout << profile1;
cout << endl;
}
if( argc >= 2 ) {
if( be_verbose ) {
cout << "Reading another profile from file '" << argv[ 1 ] << "'" << endl;
}
galosh::ProfileTreeRoot<ResidueType, floatrealspace> profile2;
profile2.fromFile( argv[ 2 ] );
if( be_verbose ) {
cout << "\tgot:" << std::endl;
cout << profile2;
cout << endl;
}
cout << "Cross Entropy: " << profile1.crossEntropy( profile2 ) << endl;
} else {
cout << "Self Entropy: " << profile1.crossEntropy( profile1 ) << endl;
}
exit( 0 );
} // main (..)