Mac binaries
[jabaws.git] / website / archive / binaries / mac / src / clustalw / src / general / Stats.h
1 /**
2  * Author: Andreas Wilm
3  * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.
4  *
5  */
6 #ifndef STATS_H
7 #define STATS_H
8
9
10 namespace clustalw
11 {
12     
13 using namespace std;
14
15
16 /** Log simple statistics about input and output
17  *
18  * @section LICENSE
19  * FIXME: please add license text
20  *
21  * @section DESCRIPTION
22  * The hashing functions have to be enabled at compile/configure time
23  * otherwise they will not be used.
24  *
25  * 
26  */
27 class Stats {
28     
29 public:
30     /* FUNCTIONS */
31     
32     /** constructor */
33     Stats();
34     /** destructor */
35     ~Stats();
36
37     /**  set the name of the file where stats are logged to
38      * @param f filename
39      */
40     void setStatsFile(string f) {logfilename=f;};
41     
42     /**
43      * return name of used stats file
44      * @return file name
45      */
46     string getStatsFile() {return logfilename;};
47     
48     /** enable stats logging
49      */
50     void setEnabled(bool b) {enabled=b;};
51     
52     /** check if stats logging is enabled
53      * @return true if enabled, false otherwise
54      */    
55     bool isEnabled() {return enabled;};
56     
57     /** log the command line arguments
58      * @param argc number arguments
59      * @param argv argument array
60      */
61     void logCmdLine(int argc, char **argv);
62     
63     /** log statistics about sequence input
64      * @param alnObj: input "alignment" (confusing isn't it?)
65      */
66     void logInputSeqStats(Alignment *alnObj);
67     
68     /** log statistics about sequence input
69      * @param alnObj: input "alignment" (confusing isn't it?)
70      */
71     void logAlignedSeqStats(Alignment *alnObj);
72
73     
74     /* ATTRIBUTES */
75
76
77     
78 private:
79     
80     /* FUNCTIONS */
81
82     /** Compute pairwise identity of two sequences
83      *
84      * Adopted from Sean Eddy'ssquid:aligneval.c
85      * He defines pairwise identity as fraction:
86      * idents / min(len1, len2)
87      *
88      * Function is case sensitive!
89      *
90      * @param alnObj alignment object
91      * @param s1 index of first sequence
92      * @param s2 index of first sequence
93      * @return pairwise identity as float
94      */
95     float pairwiseIdentity(Alignment *alnObj, int s1, int s2);
96     
97 #ifdef HAVE_MHASH_H
98
99     /** compute md5 hash from string
100      * @param thread string to hash
101      * @return hash string, or NULL on failure
102      */
103     char * Md5Hash(const char *thread);
104
105     /** compute md5 hash for a sequence
106      * @param alnObj alignment object
107      * @param s index of sequence
108      * @return md5 hash string
109      */
110     string Md5ForSeq(Alignment *alnObj, int s);
111     
112     /** compute md5 hash for all sequences
113      * sorts and concatenates all sequences beforehand
114      * thus sequence order doesn't matter
115      * 
116      * @param alnObj alignment object
117      * @param s index of sequence
118      * @return md5 hash string
119      */
120     string ConcatInputHash(Alignment *alnObj);
121 #endif
122
123     /* ATTRIBUTES */
124
125     /** the filename used for logging statistics */
126     string logfilename;
127     /** logging of statistics enabled */
128     bool enabled;
129 };
130 }
131 #endif