~ubuntu-branches/debian/jessie/arb/jessie

« back to all changes in this revision

Viewing changes to SEQ_QUALITY/SQ_GroupData.h

  • Committer: Package Import Robot
  • Author(s): Elmar Pruesse, Andreas Tille, Elmar Pruesse
  • Date: 2014-09-02 15:15:06 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140902151506-jihq58b3iz342wif
Tags: 6.0.2-1
[ Andreas Tille ]
* New upstream version
  Closes: #741890
* debian/upstream -> debian/upstream/metadata
* debian/control:
   - Build-Depends: added libglib2.0-dev
   - Depends: added mafft, mrbayes
* debian/rules
   - Add explicite --remove-section=.comment option to manual strip call
* cme fix dpkg-control
* arb-common.dirs: Do not create unneeded lintian dir
* Add turkish debconf translation (thanks for the patch to Mert Dirik
  <mertdirik@gmail.com>)
  Closes: #757497

[ Elmar Pruesse ]
* patches removed:
   - 10_config.makefiles.patch,
     80_no_GL.patch
       removed in favor of creating file from config.makefile.template via 
       sed in debian/control
   - 20_Makefile_main.patch
       merged upstream
   - 21_Makefiles.patch
       no longer needed
   - 30_tmpfile_CVE-2008-5378.patch: 
       merged upstream
   - 50_fix_gcc-4.8.patch:
       merged upstream
   - 40_add_libGLU.patch:
       libGLU not needed for arb_ntree)
   - 60_use_debian_packaged_raxml.patch:
       merged upstream
   - 70_hardening.patch
       merged upstream
   - 72_add_math_lib_to_linker.patch
       does not appear to be needed
* patches added:
   - 10_upstream_r12793__show_db_load_progress:
       backported patch showing progress while ARB is loading a database
       (needed as indicator/splash screen while ARB is launching)
   - 20_upstream_r12794__socket_permissions:
       backported security fix
   - 30_upstream_r12814__desktop_keywords:
       backported add keywords to desktop (fixes lintian warning)
   - 40_upstream_r12815__lintian_spelling:
       backported fix for lintian reported spelling errors
   - 50_private_nameservers
       change configuration to put nameservers into users home dirs
       (avoids need for shared writeable directory)
   - 60_use_debian_phyml
       use phyml from debian package for both interfaces in ARB
* debian/rules:
   - create config.makefile from override_dh_configure target
   - use "make tarfile" in override_dh_install
   - remove extra cleaning not needed for ARB 6
   - use "dh_install --list-missing" to avoid missing files
   - added override_dh_fixperms target
* debian/control:
   - added libarb-dev package
   - Depends: added phyml, xdg-utils
   - Suggests: removed phyml
   - fix lintian duplicate-short-description (new descriptions)
* debian/*.install:
   - "unrolled" confusing globbing to select files
   - pick files from debian/tmp
   - moved all config files to /etc/arb
* debian/arb-common.templates: updated
* scripts:
   - removed arb-add-pt-server
   - launch-wrapper: 
     - only add demo.arb to newly created $ARBUSERDATA
     - pass commandline arguments through bin/arb wrapper
   - preinst: removing old PT server index files on upgrade from 5.5*
   - postinst: set setgid on shared PT dir
* rewrote arb.1 manfile
* added file icon for ARB databases
* using upstream arb_tcp.dat

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#ifndef SQ_GROUPDATA_H
17
17
#define SQ_GROUPDATA_H
18
18
 
19
 
#ifndef _CPP_CSTDDEF
 
19
#ifndef _GLIBCXX_CSTDDEF
20
20
# include <cstddef>
21
21
#endif
22
 
#ifndef _CPP_IOSTREAM
 
22
#ifndef _GLIBCXX_IOSTREAM
23
23
# include <iostream>
24
24
#endif
25
 
#ifndef _MEMORY_H
26
 
#include <memory.h>
27
 
#endif
28
 
 
29
25
#ifndef ARB_ASSERT_H
30
26
# include <arb_assert.h>
31
27
#endif
 
28
#ifndef CXXFORWARD_H
 
29
#include <cxxforward.h>
 
30
#endif
 
31
 
32
32
#define seq_assert(bed) arb_assert(bed)
33
33
 
34
 
typedef struct {
 
34
struct consensus_result {
35
35
    double conformity;
36
36
    double deviation;
37
 
} consensus_result;
 
37
};
38
38
 
39
39
class SQ_GroupData {
 
40
protected:
 
41
    int    size;
 
42
    int    avg_bases;
 
43
    int    nr_sequences;
 
44
    double gc_prop;
 
45
    bool   initialized;
 
46
 
40
47
public:
41
48
    SQ_GroupData();
42
49
    virtual ~SQ_GroupData();
43
 
    virtual SQ_GroupData& operator =(const SQ_GroupData& other) = 0;
 
50
    virtual SQ_GroupData& operator      = (const SQ_GroupData& other) = 0;
44
51
    virtual SQ_GroupData *clone() const = 0;
45
52
 
46
53
    void SQ_set_avg_bases(int bases) {
47
54
        avg_bases += bases;
48
55
    }
49
56
    int SQ_get_avg_bases() const {
50
 
        return (avg_bases/nr_sequences );
 
57
        return (avg_bases/nr_sequences);
51
58
    }
52
59
    void SQ_set_avg_gc(double gc) {
53
60
        gc_prop += gc;
54
61
    }
55
62
    double SQ_get_avg_gc() const {
56
 
        return (gc_prop/nr_sequences );
 
63
        return (gc_prop/nr_sequences);
57
64
    }
58
65
    void SQ_count_sequences() {
59
66
        nr_sequences++;
65
72
        return initialized;
66
73
    }
67
74
 
68
 
    virtual void SQ_init_consensus(int size) = 0;
69
 
    virtual int SQ_print_on_screen() = 0;
 
75
    virtual void SQ_init_consensus(int size)                               = 0;
 
76
    virtual int SQ_print_on_screen()                                       = 0;
70
77
    virtual consensus_result SQ_calc_consensus(const char *sequence) const = 0;
71
 
    virtual void SQ_add_sequence(const char *sequence) = 0;
72
 
    virtual void SQ_add(const SQ_GroupData& other) = 0;
 
78
    virtual void SQ_add_sequence(const char *sequence)                     = 0;
 
79
    virtual void SQ_add(const SQ_GroupData& other)                         = 0;
73
80
 
74
81
    int getSize() const {
75
82
        return size;
76
83
    }
77
84
 
78
 
protected:
79
 
    int size;
80
 
    int avg_bases;
81
 
    int nr_sequences;
82
 
    double gc_prop;
83
 
    bool initialized;
84
85
};
85
86
 
86
87
template <int I> class Int {
97
98
        memset(i, 0, I*sizeof(int));
98
99
    }
99
100
 
100
 
    Int& operator +=(const Int& other) {
 
101
    Int& operator += (const Int& other) {
101
102
        const int *otheri = other.i;
102
103
        for (int j = 0; j<I; ++j) {
103
104
            i[j] += otheri[j];
105
106
        return *this;
106
107
    }
107
108
 
108
 
    Int& operator =(const Int& other) {
 
109
    Int& operator = (const Int& other) {
109
110
        memcpy(i, other.i, I*sizeof(int));
110
111
        return *this;
111
112
    }
113
114
 
114
115
template <int I> class SQ_GroupData_Impl : public SQ_GroupData {
115
116
    SQ_GroupData_Impl(const SQ_GroupData_Impl& other);
 
117
    SQ_GroupData_Impl& operator = (const SQ_GroupData_Impl& Other);
116
118
 
117
119
public:
118
120
    SQ_GroupData_Impl() {
119
121
        consensus = 0;
120
122
    }
121
 
 
122
 
    virtual ~SQ_GroupData_Impl();
123
 
 
124
 
    SQ_GroupData_Impl& operator=(const SQ_GroupData_Impl& other) {
125
 
        seq_assert ( other.size>0 && other.initialized );
126
 
        if ( !initialized)
127
 
            SQ_init_consensus(other.size);seq_assert ( size==other.size );
 
123
    virtual ~SQ_GroupData_Impl() OVERRIDE;
 
124
 
 
125
    SQ_GroupData_Impl& operator = (const SQ_GroupData& Other) OVERRIDE {
 
126
        const SQ_GroupData_Impl& other = dynamic_cast<const SQ_GroupData_Impl&>(Other);
 
127
        seq_assert(other.size>0 && other.initialized);
 
128
 
 
129
        if (!initialized) SQ_init_consensus(other.size);
 
130
        seq_assert(size==other.size);
 
131
 
128
132
        avg_bases = other.avg_bases;
129
 
        gc_prop = other.gc_prop;
 
133
        gc_prop   = other.gc_prop;
 
134
        
130
135
        for (int s=0; s<size; ++s) {
131
136
            consensus[s] = other.consensus[s];
132
137
        }
134
139
        return *this;
135
140
    }
136
141
 
137
 
    void SQ_init_consensus(int size);
138
 
    int SQ_print_on_screen();
139
 
    void SQ_add_column(int col);
140
 
    void SQ_add(const SQ_GroupData& other); // add's other to this
 
142
    void SQ_init_consensus(int size) OVERRIDE;
 
143
    int SQ_print_on_screen() OVERRIDE;
 
144
    void SQ_add(const SQ_GroupData& other) OVERRIDE; // add's other to this
141
145
 
142
146
protected:
143
147
    Int<I> *consensus;
144
148
};
145
149
 
146
150
class SQ_GroupData_RNA : public SQ_GroupData_Impl<6> {
 
151
    typedef SQ_GroupData_Impl<6> Base;
147
152
    SQ_GroupData_RNA(const SQ_GroupData_RNA& other); // copying not allowed
148
153
public:
149
154
    SQ_GroupData_RNA() {
150
155
    }
151
156
 
152
 
    SQ_GroupData_RNA *clone() const {
 
157
    SQ_GroupData_RNA *clone() const OVERRIDE {
153
158
        return new SQ_GroupData_RNA;
154
159
    }
155
 
    SQ_GroupData_RNA& operator=(const SQ_GroupData& other) {
156
 
        return static_cast<SQ_GroupData_RNA&> (SQ_GroupData_Impl<6>::operator=
157
 
        ( static_cast<const SQ_GroupData_Impl<6>&> ( other ) ) );
 
160
    SQ_GroupData_RNA& operator = (const SQ_GroupData& other) OVERRIDE {
 
161
        Base::operator=(other);
 
162
        return *this;
158
163
    }
159
164
 
160
 
    consensus_result SQ_calc_consensus ( const char *sequence ) const;
161
 
    void SQ_add_sequence ( const char *sequence );
 
165
    consensus_result SQ_calc_consensus (const char *sequence) const OVERRIDE;
 
166
    void SQ_add_sequence (const char *sequence) OVERRIDE;
162
167
protected:
163
168
    static int class_counter;
164
169
};
165
170
 
166
171
class SQ_GroupData_PRO : public SQ_GroupData_Impl<20> {
 
172
    typedef SQ_GroupData_Impl<20> Base;
167
173
    SQ_GroupData_PRO(const SQ_GroupData_PRO& other); // copying not allowed
168
174
public:
169
175
    SQ_GroupData_PRO() {
170
176
    }
171
177
 
172
 
    SQ_GroupData_PRO *clone() const {
 
178
    SQ_GroupData_PRO *clone() const OVERRIDE {
173
179
        return new SQ_GroupData_PRO;
174
180
    }
175
 
    SQ_GroupData_PRO& operator=(const SQ_GroupData& other) {
176
 
        return static_cast<SQ_GroupData_PRO&> (SQ_GroupData_Impl<20>::operator=
177
 
        ( static_cast<const SQ_GroupData_Impl<20>&> ( other ) ) );
 
181
    SQ_GroupData_PRO& operator = (const SQ_GroupData& other) OVERRIDE {
 
182
        Base::operator=(other);
 
183
        return *this;
178
184
    }
179
185
 
180
 
    consensus_result SQ_calc_consensus ( const char *sequence ) const;
181
 
    void SQ_add_sequence ( const char *sequence );
 
186
    consensus_result SQ_calc_consensus (const char *sequence) const OVERRIDE;
 
187
    void SQ_add_sequence (const char *sequence) OVERRIDE;
182
188
};
183
189
 
184
190
// -----------------------
185
191
//      implementation
186
 
// -----------------------
187
 
 
188
192
 
189
193
template <int I> SQ_GroupData_Impl<I>::~SQ_GroupData_Impl() {
190
194
    delete [] consensus;
191
195
}
192
196
 
193
197
template <int I> void SQ_GroupData_Impl<I>::SQ_init_consensus(int size_) {
194
 
    seq_assert ( !initialized );
 
198
    seq_assert (!initialized);
195
199
 
196
200
    size = size_;
197
201
    consensus = new Int<I>[size];
201
205
template <int I> void SQ_GroupData_Impl<I>::SQ_add(
202
206
        const SQ_GroupData& other_base) {
203
207
    const SQ_GroupData_Impl<I>& other =
204
 
            dynamic_cast<const SQ_GroupData_Impl<I>&> (other_base );
205
 
    seq_assert ( size==other.size );
 
208
            dynamic_cast<const SQ_GroupData_Impl<I>&> (other_base);
 
209
    seq_assert (size==other.size);
206
210
    for (int i = 0; i<size; ++i) {
207
211
        consensus[i] += other.consensus[i];
208
212
    }
217
221
            std::cout << consensus[i].i[j];
218
222
        }
219
223
    }
220
 
    return ( 0 );
 
224
    return (0);
221
225
}
222
226
 
223
227
#else