Newer
Older
// ****************************************************************************
// Aevol - An in silico experimental evolution platform
// ****************************************************************************
// 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
// 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.
// 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.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ****************************************************************************
// =================================================================
// Libraries
// =================================================================
// =================================================================
// Project Files
ROUZAUD-CORNABAS Jonathan
committed
#include "ReplicationReport.h"
#include "7/Dna_7.h"
#include "7/Individual_7.h"
#include "7/ExpManager_7.h"
#include "AeTime.h"
#include "GridCell.h"
#include "legacy/population/Individual.h"
#include "Mutation.h"
#include "Observable.h"
//##############################################################################
// #
// Class ReplicationReport #
// #
//##############################################################################
// =================================================================
// Definition of static attributes
// =================================================================
// =================================================================
// Constructors
// =================================================================
#ifdef __REGUL
ReplicationReport::ReplicationReport(Individual_R* indiv,
const Individual_R* parent,
Individual_R* donor /*= NULL*/)
#else
ReplicationReport::ReplicationReport(Individual* indiv,
const Individual* parent,
Individual* donor /*= NULL*/)
// rank_ = indiv->rank();
// donor_id_ is set further down
genome_size_ = 0;
metabolic_error_ = 0.0;
nb_genes_activ_ = 0;
nb_genes_inhib_ = 0;
nb_non_fun_genes_ = 0;
nb_coding_RNAs_ = 0;
nb_non_coding_RNAs_ = 0;
parent_metabolic_error_ = parent->dist_to_target_by_feature(METABOLISM);
parent_secretion_error_ = parent->dist_to_target_by_feature(SECRETION);
parent_genome_size_ = parent->total_genome_size();
mean_align_score_ = 0.0;
if (donor == NULL)
donor_id_ = -1;
donor_metabolic_error_ = 0.0;
donor_secretion_error_ = 0.0;
donor_genome_size_ = 0;
donor_metabolic_error_ = donor->dist_to_target_by_feature(METABOLISM);
donor_secretion_error_ = donor->dist_to_target_by_feature(SECRETION);
donor_genome_size_ = donor->total_genome_size();
}
// Creates an independent copy of the original report
ReplicationReport::ReplicationReport(const ReplicationReport& other) :
dna_replic_report_(other.dna_replic_report_)
parent_id_ = other.parent_id_;
donor_id_ = other.donor_id_;
id_ = other.id_;
genome_size_ = other.genome_size_;
metabolic_error_ = other.metabolic_error_;
nb_genes_activ_ = other.nb_genes_activ_;
nb_genes_inhib_ = other.nb_genes_inhib_;
nb_non_fun_genes_ = other.nb_non_fun_genes_;
nb_coding_RNAs_ = other.nb_coding_RNAs_;
nb_non_coding_RNAs_ = other.nb_non_coding_RNAs_;
parent_metabolic_error_ = other.parent_metabolic_error_;
parent_secretion_error_ = other.parent_secretion_error_;
donor_metabolic_error_ = other.donor_metabolic_error_;
donor_secretion_error_ = other.donor_secretion_error_;
parent_genome_size_ = other.parent_genome_size_;
donor_genome_size_ = other.donor_genome_size_;
mean_align_score_ = other.mean_align_score_;
// remote_ = other.remote_;
#ifdef __REGUL
ReplicationReport::ReplicationReport(gzFile tree_file, Individual_R* indiv)
#else
ReplicationReport::ReplicationReport(gzFile tree_file, Individual* indiv)
gzread(tree_file, &id_, sizeof(id_));
gzread(tree_file, &parent_id_, sizeof(parent_id_));
#ifdef __EUKARYOTE
gzread(tree_file, &parent2_id_, sizeof(parent2_id_));
gzread(tree_file, &simd_indiv_->inverted_parents_, sizeof(simd_indiv_->inverted_parents_));
gzread(tree_file, &simd_indiv_->parent1_gave_chrsm_, sizeof(simd_indiv_->parent1_gave_chrsm_));
gzread(tree_file, &simd_indiv_->parent2_gave_chrsm_, sizeof(simd_indiv_->parent2_gave_chrsm_));
#else
gzread(tree_file, &donor_id_, sizeof(donor_id_));
#endif
gzread(tree_file, &genome_size_, sizeof(genome_size_));
gzread(tree_file, &metabolic_error_, sizeof(metabolic_error_));
gzread(tree_file, &nb_genes_activ_, sizeof(nb_genes_activ_));
gzread(tree_file, &nb_genes_inhib_, sizeof(nb_genes_inhib_));
gzread(tree_file, &nb_non_fun_genes_, sizeof(nb_non_fun_genes_));
gzread(tree_file, &nb_coding_RNAs_, sizeof(nb_coding_RNAs_));
gzread(tree_file, &nb_non_coding_RNAs_, sizeof(nb_non_coding_RNAs_));
dna_replic_report_.read_from_tree_file(tree_file);
dna_replic_report_.compute_stats();
parent_metabolic_error_ = -1;
parent_secretion_error_ = -1;
donor_metabolic_error_ = -1;
parent_genome_size_ = -1;
donor_genome_size_ = -1;
mean_align_score_ = 0.0;
}
// =================================================================
// Destructors
// =================================================================
// =================================================================
// Public Methods
// =================================================================
* Set the individual corresponding to this replication report and
* the characteristics of its parent
*
* This should be called as soon as a replication is started (just after calling
* the offspring constructor and before doing the mutations)
void ReplicationReport::init(Individual_R* offspring, Individual_R* parent, int indiv_id, int parent_id)
void ReplicationReport::init(Individual* offspring, Individual* parent, int indiv_id, int parent_id)
dna_replic_report_.clear();
ROUZAUD-CORNABAS Jonathan
committed
id_ = indiv_id;
parent_id_ = parent_id;
genome_size_ = 0;
metabolic_error_ = 0.0;
nb_genes_activ_ = 0;
nb_genes_inhib_ = 0;
nb_non_fun_genes_ = 0;
nb_coding_RNAs_ = 0;
nb_non_coding_RNAs_ = 0;
parent_metabolic_error_ = parent->dist_to_target_by_feature(METABOLISM);
parent_secretion_error_ = parent->dist_to_target_by_feature(SECRETION);
parent_genome_size_ = parent->total_genome_size();
mean_align_score_ = 0.0;
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#ifdef __EUKARYOTE
void ReplicationReport::init(Individual_7* offspring,
Individual_7* parent1, Individual_7* parent2,
int indiv_id, int parent1_id, int parent2_id){
dna_replic_report_.clear();
simd_indiv_ = offspring;
id_ = (unsigned long long) indiv_id;
parent_id_ = (unsigned long long) parent1_id;
parent2_id_ = (unsigned long long) parent2_id;
genome_size_ = 0;
metabolic_error_ = 0.0;
nb_genes_activ_ = 0;
nb_genes_inhib_ = 0;
nb_non_fun_genes_ = 0;
nb_coding_RNAs_ = 0;
nb_non_coding_RNAs_ = 0;
parent_metabolic_error_ = parent1->metaerror;
parent_secretion_error_ = 0.0;
parent_genome_size_ = parent1->dna_length();
mean_align_score_ = 0.0;
parent2_metabolic_error_ = parent2->metaerror;
parent2_secretion_error_ = 0.0;
parent2_genome_size_ = parent2->dna_length();
}
#else
void ReplicationReport::init(Individual_7* offspring,
Individual_7* parent,
int indiv_id,
int parent_id) {
ROUZAUD-CORNABAS Jonathan
committed
simd_indiv_ = offspring;
id_ = (unsigned long long) indiv_id;
parent_id_ = (unsigned long long) parent_id;
ROUZAUD-CORNABAS Jonathan
committed
genome_size_ = 0;
metabolic_error_ = 0.0;
nb_genes_activ_ = 0;
nb_genes_inhib_ = 0;
nb_non_fun_genes_ = 0;
nb_coding_RNAs_ = 0;
nb_non_coding_RNAs_ = 0;
parent_metabolic_error_ = parent->metaerror;
parent_secretion_error_ = 0.0;
parent_genome_size_ = parent->annotated_chromosome_[A]->dna_->length();
ROUZAUD-CORNABAS Jonathan
committed
mean_align_score_ = 0.0;
donor_id_ = -1;
donor_metabolic_error_ = -1;
donor_secretion_error_ = -1;
donor_genome_size_ = -1;
dna_replic_report_.clear();
ROUZAUD-CORNABAS Jonathan
committed
}
ROUZAUD-CORNABAS Jonathan
committed
/**
* Method called at the end of the replication of an individual.
* Actions such as finalize the calculation of average values can be done here.
*/
#ifdef __REGUL
void ReplicationReport::signal_end_of_replication(Individual_R* indiv) {
#else
void ReplicationReport::signal_end_of_replication(Individual* indiv) {
#endif
if (indiv_ == NULL) indiv_ = indiv;
genome_size_ = indiv_->total_genome_size();
metabolic_error_ = indiv_->dist_to_target_by_feature(METABOLISM);
nb_genes_activ_ = indiv_->nb_genes_activ();
nb_genes_inhib_ = indiv_->nb_genes_inhib();
nb_non_fun_genes_ = indiv_->nb_functional_genes();
nb_coding_RNAs_ = indiv_->nb_coding_RNAs();
nb_non_coding_RNAs_ = indiv_->nb_non_coding_RNAs();
ROUZAUD-CORNABAS Jonathan
committed
void ReplicationReport::signal_end_of_replication(Individual_7* indiv) {
ROUZAUD-CORNABAS Jonathan
committed
// TODO <david.parsons@inria.fr> tmp patch
if (simd_indiv_ == NULL) simd_indiv_ = indiv;
ROUZAUD-CORNABAS Jonathan
committed
// Retrieve data from the individual
LUISELLI Juliette
committed
genome_size_ = simd_indiv_->dna_length();
ROUZAUD-CORNABAS Jonathan
committed
metabolic_error_ = simd_indiv_->metaerror;
LUISELLI Juliette
committed
nb_genes_activ_ = simd_indiv_->nb_genes_activ();
nb_genes_inhib_ = simd_indiv_->nb_genes_inhib();
nb_non_fun_genes_ = simd_indiv_->nb_func_genes();
nb_coding_RNAs_ = simd_indiv_->nb_coding_RNAs();
nb_non_coding_RNAs_ = simd_indiv_->nb_non_coding_RNAs();
ROUZAUD-CORNABAS Jonathan
committed
}
/**
* Method called at the end of a generation.
* Actions such as update the individuals' ranks can be done here.
*/
void ReplicationReport::signal_end_of_generation() {
// if (!ExpManager_7::standalone_simd) {
// rank_ = indiv_->rank();
// }
void ReplicationReport::write_to_tree_file(gzFile tree_file)
// printf("RR ID %d PID %d\n",id_,parent_id_);
gzwrite(tree_file, &parent_id_, sizeof(parent_id_));
#ifdef __EUKARYOTE
gzwrite(tree_file, &parent2_id_, sizeof(parent2_id_));
gzwrite(tree_file, &simd_indiv_->inverted_parents_, sizeof(simd_indiv_->inverted_parents_));
gzwrite(tree_file, &simd_indiv_->parent1_gave_chrsm_, sizeof(simd_indiv_->parent1_gave_chrsm_));
gzwrite(tree_file, &simd_indiv_->parent2_gave_chrsm_, sizeof(simd_indiv_->parent2_gave_chrsm_));
#else
gzwrite(tree_file, &donor_id_, sizeof(donor_id_));
#endif
gzwrite(tree_file, &genome_size_, sizeof(genome_size_));
gzwrite(tree_file, &metabolic_error_, sizeof(metabolic_error_));
gzwrite(tree_file, &nb_genes_activ_, sizeof(nb_genes_activ_));
gzwrite(tree_file, &nb_genes_inhib_, sizeof(nb_genes_inhib_));
gzwrite(tree_file, &nb_non_fun_genes_, sizeof(nb_non_fun_genes_));
gzwrite(tree_file, &nb_coding_RNAs_, sizeof(nb_coding_RNAs_));
gzwrite(tree_file, &nb_non_coding_RNAs_, sizeof(nb_non_coding_RNAs_));
dna_replic_report_.write_to_tree_file(tree_file);
void ReplicationReport::update(Observable&, ObservableEvent e, void* arg) {
switch (e) {
case MUTATION :
dna_replic_report_.add_mut(reinterpret_cast<Mutation *>(arg));
Utils::ExitWithDevMsg("Event not handled", __FILE__, __LINE__);