File: Stats.h

package info (click to toggle)
clustalx 2.1%2Blgpl-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,324 kB
  • sloc: cpp: 40,050; sh: 163; xml: 102; makefile: 16
file content (131 lines) | stat: -rw-r--r-- 2,986 bytes parent folder | download | duplicates (11)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
 * Author: Andreas Wilm
 * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.
 *
 */
#ifndef STATS_H
#define STATS_H


namespace clustalw
{
    
using namespace std;


/** Log simple statistics about input and output
 *
 * @section LICENSE
 * FIXME: please add license text
 *
 * @section DESCRIPTION
 * The hashing functions have to be enabled at compile/configure time
 * otherwise they will not be used.
 *
 * 
 */
class Stats {
    
public:
    /* FUNCTIONS */
    
    /** constructor */
    Stats();
    /** destructor */
    ~Stats();

    /**  set the name of the file where stats are logged to
     * @param f filename
     */
    void setStatsFile(string f) {logfilename=f;};
    
    /**
     * return name of used stats file
     * @return file name
     */
    string getStatsFile() {return logfilename;};
    
    /** enable stats logging
     */
    void setEnabled(bool b) {enabled=b;};
    
    /** check if stats logging is enabled
     * @return true if enabled, false otherwise
     */    
    bool isEnabled() {return enabled;};
    
    /** log the command line arguments
     * @param argc number arguments
     * @param argv argument array
     */
    void logCmdLine(int argc, char **argv);
    
    /** log statistics about sequence input
     * @param alnObj: input "alignment" (confusing isn't it?)
     */
    void logInputSeqStats(Alignment *alnObj);
    
    /** log statistics about sequence input
     * @param alnObj: input "alignment" (confusing isn't it?)
     */
    void logAlignedSeqStats(Alignment *alnObj);

    
    /* ATTRIBUTES */


    
private:
    
    /* FUNCTIONS */

    /** Compute pairwise identity of two sequences
     *
     * Adopted from Sean Eddy'ssquid:aligneval.c
     * He defines pairwise identity as fraction:
     * idents / min(len1, len2)
     *
     * Function is case sensitive!
     *
     * @param alnObj alignment object
     * @param s1 index of first sequence
     * @param s2 index of first sequence
     * @return pairwise identity as float
     */
    float pairwiseIdentity(Alignment *alnObj, int s1, int s2);
    
#ifdef HAVE_MHASH_H

    /** compute md5 hash from string
     * @param thread string to hash
     * @return hash string, or NULL on failure
     */
    char * Md5Hash(const char *thread);

    /** compute md5 hash for a sequence
     * @param alnObj alignment object
     * @param s index of sequence
     * @return md5 hash string
     */
    string Md5ForSeq(Alignment *alnObj, int s);
    
    /** compute md5 hash for all sequences
     * sorts and concatenates all sequences beforehand
     * thus sequence order doesn't matter
     * 
     * @param alnObj alignment object
     * @param s index of sequence
     * @return md5 hash string
     */
    string ConcatInputHash(Alignment *alnObj);
#endif

    /* ATTRIBUTES */

    /** the filename used for logging statistics */
    string logfilename;
    /** logging of statistics enabled */
    bool enabled;
};
}
#endif