ReplicationReport.h 7.48 KB
Newer Older
1
// ****************************************************************************
2
//
3
//          Aevol - An in silico experimental evolution platform
4
//
5
// ****************************************************************************
Vincent Liard's avatar
Vincent Liard committed
6
//
7
8
9
10
// Copyright: See the AUTHORS file provided with the package or <www.aevol.fr>
// Web: http://www.aevol.fr/
// E-mail: See <http://www.aevol.fr/contact/>
// Original Authors : Guillaume Beslon, Carole Knibbe, David Parsons
Vincent Liard's avatar
Vincent Liard committed
11
//
12
13
14
15
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
Vincent Liard's avatar
Vincent Liard committed
16
//
17
18
19
20
// This program 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 General Public License for more details.
Vincent Liard's avatar
Vincent Liard committed
21
//
22
// You should have received a copy of the GNU General Public License
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
Vincent Liard's avatar
Vincent Liard committed
24
25
//
// ****************************************************************************
26
27


Vincent Liard's avatar
Vincent Liard committed
28
29
#ifndef AEVOL_REPLICATION_REPORT_H_
#define AEVOL_REPLICATION_REPORT_H_
30
31
32


// =================================================================
33
//                              Includes
34
35
// =================================================================
#include <inttypes.h>
36
#include <zlib.h>
37

38
39
40
#include <cstdio>
#include <cstdlib>
#include <cassert>
41

42
#include "DnaReplicationReport.h"
43
#include "ae_enums.h"
44
#include "ObservableEvent.h"
45

Vincent Liard's avatar
Vincent Liard committed
46
namespace aevol {
47
48
49
50
51


// =================================================================
//                          Class declarations
// =================================================================
52
class Tree;
53

TURPIN Laurent's avatar
TURPIN Laurent committed
54
class ReplicationReport{
55
56
57
58
59
  public :

    // =================================================================
    //                             Constructors
    // =================================================================
60
    ReplicationReport() = default;
61
    // Creates a completely independent copy of the original report
62
    ReplicationReport(const ReplicationReport& other);
63

TURPIN Laurent's avatar
TURPIN Laurent committed
64
65
  ReplicationReport(gzFile tree_file);

66
67
68
    // =================================================================
    //                             Destructors
    // =================================================================
69
    virtual ~ReplicationReport() = default;
70
71
72
73

    // =================================================================
    //                              Accessors
    // =================================================================
TURPIN Laurent's avatar
TURPIN Laurent committed
74

75
    unsigned long long id() { return id_; };
76
    inline int32_t  genome_size() const;
77
    inline unsigned long long  parent_id() const;
78
79
80
    inline double   parent_metabolic_error() const;
    inline double   parent_secretion_error() const;
    inline int32_t  parent_genome_size() const;
Vincent Liard's avatar
Vincent Liard committed
81

Vincent Liard's avatar
Vincent Liard committed
82
    inline double   mean_align_score() const;
83
84
85
86
87
    inline int32_t	donor_id() const;
    inline double   donor_metabolic_error() const;
    inline int32_t  donor_genome_size() const;
    int32_t nb(MutationType t) const {
      return dna_replic_report_.nb(t);
David Parsons's avatar
David Parsons committed
88
89
90
91
92
    }

    // TODO <david.parsons@inria.fr> re-constify
    // => const DnaReplicationReport& dna_replic_report() const
    DnaReplicationReport& dna_replic_report() {
93
      return dna_replic_report_;
David Parsons's avatar
David Parsons committed
94
    }
95

96
    inline void     set_parent_id(unsigned long long parent_id);
97
98
99
100
101
102
103
    inline void     set_parent_metabolic_error(double parent_metabolic_error);
    inline void     set_parent_secretion_error(double parent_secretion_error);
    inline void     set_parent_genome_size(int32_t parent_genome_size);
    inline void     set_donor_id(int32_t donor_id);
    inline void     set_donor_metabolic_error(double donor_metabolic_error);
    inline void     set_donor_secretion_error(double donor_secretion_error);
    inline void     set_donor_genome_size(int32_t donor_genome_size);
104
105
106
107

    // =================================================================
    //                            Public Methods
    // =================================================================
TURPIN Laurent's avatar
TURPIN Laurent committed
108
109
110
111
112

    void init(Individual_7* offspring,
              Individual_7* parent,
              int indiv_id,
              int parent_id);
113
    void signal_end_of_replication(Individual_7* indiv);
114

115
    void write_to_tree_file(gzFile tree_file);
116

117
  Individual_7* simd_indiv_ = nullptr;
118

119
120
    unsigned long long id_ = 0;
    unsigned long long parent_id_ = 0;
121
122
123
124
125
126
127
128
129

  protected :
    // =================================================================
    //                           Protected Methods
    // =================================================================

    // =================================================================
    //                          Protected Attributes
    // =================================================================
David Parsons's avatar
David Parsons committed
130

131
132
    int32_t genome_size_ = -1;
    double metabolic_error_ = -1;
David Parsons's avatar
David Parsons committed
133
134

    // List of each genetic unit's replication report
135
    DnaReplicationReport dna_replic_report_;
136

137
138
139
    double parent_metabolic_error_ = -1;
    double parent_secretion_error_ = -1;
    int32_t parent_genome_size_ = -1;
140

141
142
143
144
    int32_t	donor_id_ = -1;
    double donor_metabolic_error_ = -1;
    double donor_secretion_error_ = -1;
    int32_t donor_genome_size_ = -1;
145
146

    // CK: I think that the attributes below are obsolete
147
    // (HT events are now stored in the ae_dna_replic_reports)
148

149
    double mean_align_score_;
150
151
152
153
154
155
};


// =====================================================================
//                          Accessors' definitions
// =====================================================================
156

157
inline int32_t ReplicationReport::genome_size() const
158
{
159
  return genome_size_;
160
161
}

162
unsigned long long ReplicationReport::parent_id() const
David Parsons's avatar
David Parsons committed
163
{
164
  return parent_id_;
David Parsons's avatar
David Parsons committed
165
166
}

167
double ReplicationReport::parent_metabolic_error() const
168
{
169
  return parent_metabolic_error_;
170
}
David Parsons's avatar
David Parsons committed
171

172
double ReplicationReport::parent_secretion_error() const
173
{
174
  return parent_secretion_error_;
175
176
}

177
int32_t ReplicationReport::parent_genome_size() const
178
{
179
  return parent_genome_size_;
180
181
}

182
inline int32_t	ReplicationReport::donor_id() const
183
{
184
  return donor_id_;
185
186
}

187
inline double   ReplicationReport::donor_metabolic_error() const
188
{
189
  return donor_metabolic_error_;
190
191
}

192
inline int32_t  ReplicationReport::donor_genome_size() const
193
{
194
  return donor_genome_size_;
195
196
}

197
198


Vincent Liard's avatar
Vincent Liard committed
199
inline double ReplicationReport::mean_align_score() const
200
{
201
  return mean_align_score_;
202
203
}

204
void ReplicationReport::set_parent_id(unsigned long long parent_id)
205
{
206
  parent_id_ = parent_id;
207
208
}

209
void ReplicationReport::set_parent_metabolic_error(double parent_metabolic_error)
210
{
211
  parent_metabolic_error_ = parent_metabolic_error;
212
213
}

214
void ReplicationReport::set_parent_secretion_error(double parent_secretion_error)
215
{
216
  parent_secretion_error_ = parent_secretion_error;
217
}
218

219
void ReplicationReport::set_parent_genome_size(int32_t parent_genome_size)
David Parsons's avatar
David Parsons committed
220
{
221
  parent_genome_size_ = parent_genome_size;
David Parsons's avatar
David Parsons committed
222
}
223

224
inline void ReplicationReport::set_donor_id(int32_t donor_id)
David Parsons's avatar
David Parsons committed
225
{
226
  donor_id_ = donor_id;
227
228
}

229
inline void  ReplicationReport::set_donor_metabolic_error(double donor_metabolic_error)
230
{
231
  donor_metabolic_error_ = donor_metabolic_error;
David Parsons's avatar
David Parsons committed
232
}
233

234
inline void ReplicationReport::set_donor_secretion_error(double donor_secretion_error)
235
{
236
  donor_secretion_error_ = donor_secretion_error;
237
238
}

239
inline void ReplicationReport::set_donor_genome_size(int32_t donor_genome_size)
David Parsons's avatar
David Parsons committed
240
{
241
  donor_genome_size_ = donor_genome_size;
David Parsons's avatar
David Parsons committed
242
}
243

Vincent Liard's avatar
Vincent Liard committed
244
} // namespace aevol
245

Vincent Liard's avatar
Vincent Liard committed
246
#endif // AEVOL_REPLICATION_REPORT_H_