Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 49e90f39 authored by LUISELLI Juliette's avatar LUISELLI Juliette Committed by David Parsons
Browse files

WIP add tests

parent f3810a01
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// ****************************************************************************
//
// 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/>.
//
//*****************************************************************************
// =================================================================
// Includes
// =================================================================
#include <inttypes.h>
#include <cstring>
#include <list>
#include <vector>
#include <memory>
#include <gtest/gtest.h>
#include "DnaFactory.h"
#include "ExpManager_7.h"
#include "ExpSetup.h"
#include "fuzzy/FuzzyFactory_7.h"
#include "Individual_7.h"
#include "legacy/biochemistry/Rna.h"
#include "legacy/biochemistry/Protein.h"
#include "macros.h"
#include "MutationParams.h"
#include "Strand.h"
using namespace aevol;
//############################################################################
// #
// Class IndividualTest #
// #
//############################################################################
class IndividualTest : public testing::Test
{
protected:
virtual void SetUp(void);
virtual void TearDown(void);
// We have an version of each individual for each fuzzy set flavor
Individual_7* indiv1;
};
// ===========================================================================
// Public Methods
// ===========================================================================
void IndividualTest::SetUp(void)
{
// Build ad-hoc genomes
// (and reverse to test the same things on the lagging strand.):
//
// indiv1: LEAD (prom-1 + AS + AG + AS + term)
// size 22+5+28+6+11=72
// AS = Arbitrary Sequence
// AG = Arbitrary Gene
// Do not modify the sequences !
// Define a few arbitrary sequences
char as[5][10] = {
"0011",
"11101",
"110011",
"11000",
"000101"
};
const char* SHINE_DAL_SEQ = "011011";
// const char* SHINE_DAL_SEQ_LAG = "001001";
// Define an arbitrary gene
char gene[100];
sprintf(gene, "%s0011000100110110010001", SHINE_DAL_SEQ);
// char lag_gene[100];
// sprintf(lag_gene, "1100111011001001101110%s", SHINE_DAL_SEQ_LAG);
// Define an arbitrary terminator
char term[TERM_SIZE+1] = "01000001101";
// char bad_term_end[TERM_SIZE] = "0100000110";
// char bad_term_beg[TERM_SIZE] = "1000001101";
// Define a few arbitrary promoters
// char prom[2][23] = {
// "0101010001110110010110", // dist from consensus: 2 => basal level: 0.6
// "0101011001110010010010" // dist from consensus: 1 => basal level: 0.8
// };
// char lag_prom[2][23] = {
// "1001011001000111010101", // dist from consensus: 2 => basal level: 0.6
// "1011011011000110010101" // dist from consensus: 1 => basal level: 0.8
// };
char bad_prom[2][23] = {
"101010001110110010110", // removed first base : add 0 at end
"010101100111001001001" // removed last base : add 0 at begin
};
// char bad_lag_prom[2][23] = {
// "001011001000111010101", // removed first base : add 1 at end
// "101101101100011001010" // removed last base : add 1 at begin
// };
// Initialize the experimental setup.
// These are needed in the GeneticUnit constructors.
ExpSetup* exp_s = new ExpSetup(nullptr);
MutationParams params_mut;
// Update fuzzy flavor and fuzzy factory // TODO<dpa> Still needed/useful?
FuzzyFlavor fuzzyFlavor = FuzzyFlavor::VECTOR;
exp_s->set_fuzzy_flavor(fuzzyFlavor);
DnaFactory* dna_factory = new DnaFactory(DnaFactory_Policy::LOCAL_GLOBAL_FIT, 48, 1000, 16);
FuzzyFactory_7* fuzzy_factory = new FuzzyFactory_7(fuzzyFlavor, 16, 300, 16);
// Build indiv1 LEAD (prom-1 + AS + AG + AS + term)
// Construct a genome with these arbitrary sequences
char* genome = new char[100];
sprintf(genome, "%s%s%s%s%s0",bad_prom[0], as[1], gene, as[2], term);
indiv1 = new Individual_7(1.0, dna_factory, fuzzy_factory);
indiv1->annotated_chromosome_[A]->dna_ = dna_factory->get_dna(strlen(genome));
indiv1->annotated_chromosome_[A]->dna_->ann_chrsm_ = indiv1->annotated_chromosome_[A];
indiv1->annotated_chromosome_[A]->dna_->dna_factory_ = dna_factory;
indiv1->annotated_chromosome_[A]->dna_->set_indiv(genome, strlen(genome), indiv1);
indiv1->annotated_chromosome_[B]->dna_ = dna_factory->get_dna(strlen(genome));
indiv1->annotated_chromosome_[B]->dna_->ann_chrsm_ = indiv1->annotated_chromosome_[B];
indiv1->annotated_chromosome_[B]->dna_->dna_factory_ = dna_factory;
indiv1->annotated_chromosome_[B]->dna_->set_indiv(genome, strlen(genome), indiv1);
genome = nullptr;
// Do transcription and translation
indiv1->start_stop_RNA();
indiv1->prom_compute_RNA(*exp_s);
indiv1->start_protein();
indiv1->compute_protein();
indiv1->translate_protein(*exp_s, 1.0);
}
void IndividualTest::TearDown() {
// for (auto indiv : indivs1) {
// delete indiv;
// }
}
// For each version of each individual constructed with a different
// fuzzy set implementation, we check that all values are correct.
// We don't need to change the fuzzy set implementation in the
// experimental setup again because it's only used at transcription and
// translation time.
TEST_F(IndividualTest, TestIndiv1) {
// Check that we have the right number of promoters, terminators etc
// and at the right positions
// "right" means those values we have computed by hand
for (auto chrsm: {A,B}){
// Check genome size
EXPECT_EQ(72, indiv1->annotated_chromosome_[chrsm]->dna_->length());
EXPECT_EQ(72, indiv1->annotated_chromosome_[chrsm]->length());
// Check Prom list
EXPECT_EQ(0, indiv1->annotated_chromosome_[chrsm]->promoter_list().promoter_count());
// Check RNA list
auto rna_list = indiv1->annotated_chromosome_[chrsm]->rnas();
EXPECT_EQ(0, rna_list.size());
// Check protein list
auto prot_list = indiv1->annotated_chromosome_[chrsm]->proteins();
EXPECT_EQ(0, prot_list.size());
}
}
// ===========================================================================
// Protected Methods
// ===========================================================================
// ===========================================================================
// Non inline accessors
// ===========================================================================
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment