diff --git a/src/libaevol/ae_individual_X11.cpp b/src/libaevol/ae_individual_X11.cpp index 9b0eef65c345634ea3316facddac493023c70479..02f2801cb1e0111f1f8744e165e70eb4e816e5e8 100644 --- a/src/libaevol/ae_individual_X11.cpp +++ b/src/libaevol/ae_individual_X11.cpp @@ -129,9 +129,9 @@ void ae_individual_X11::display_cdss( ae_X11_window* win ) char display_string[40]; sprintf( display_string, "Main chromosome size : %" PRId32 "bp", genome_length ); win->draw_string( 15, 25, display_string ); - sprintf( display_string, "Leading : %" PRId32 " CDSs", gen_unit->get_protein_list()[LEADING]->get_nb_elts() ); + sprintf( display_string, "Leading : %" PRId32 " CDSs", static_cast<int32_t>(gen_unit->get_protein_list_std()[LEADING].size())); win->draw_string( 15, 40, display_string ); - sprintf( display_string, "Lagging : %" PRId32 " CDSs", gen_unit->get_protein_list()[LAGGING]->get_nb_elts() ); + sprintf( display_string, "Lagging : %" PRId32 " CDSs", static_cast<int32_t>(gen_unit->get_protein_list_std()[LAGGING].size())); win->draw_string( 15, 55, display_string ); // Compute display diameter according to genome length and window size diff --git a/src/post_treatments/create_eps.cpp b/src/post_treatments/create_eps.cpp index dbd268e88edaaa610fc16897de3faca1544dc6fe..f23ceef103966aa16d8cb5b3bd6f0345cbd45e46 100644 --- a/src/post_treatments/create_eps.cpp +++ b/src/post_treatments/create_eps.cpp @@ -459,14 +459,8 @@ void draw_triangles( ae_individual* indiv, Environment* env, char * directoryNam double h; - for (auto& gu: indiv->get_genetic_unit_list_std()) { - ae_list_node<ae_protein*>* prot_node = NULL; - ae_protein* prot = NULL; - - prot_node = (gu.get_protein_list())[LEADING]->get_first(); - while ( prot_node != NULL ) - { - prot = (ae_protein*) prot_node->get_obj(); + for (const auto& gu: indiv->get_genetic_unit_list_std()) { + for (const auto& prot: gu.get_protein_list_std()[LEADING]) { h = prot->get_height() * prot->get_concentration(); fprintf( drawingfile, "%lf %lf moveto\n", margin, 0.5); fprintf( drawingfile, "%lf %lf lineto\n", margin + scalex*(prot->get_mean() - prot->get_width()), 0.5); @@ -474,14 +468,9 @@ void draw_triangles( ae_individual* indiv, Environment* env, char * directoryNam fprintf( drawingfile, "%lf %lf lineto\n", margin + scalex*(prot->get_mean() + prot->get_width()), 0.5); fprintf( drawingfile, "%lf %lf moveto\n", margin + scalex*(1), 0.5); fprintf( drawingfile, "stroke\n" ); - prot_node = prot_node->get_next(); } - - prot_node = (gu.get_protein_list())[LAGGING]->get_first(); - while ( prot_node != NULL ) - { - prot = (ae_protein*) prot_node->get_obj(); + for (const auto& prot: gu.get_protein_list_std()[LAGGING]) { h = prot->get_height() * prot->get_concentration(); fprintf( drawingfile, "%lf %lf moveto\n", margin, 0.5); fprintf( drawingfile, "%lf %lf lineto\n", margin + scalex*(prot->get_mean() - prot->get_width()), 0.5); @@ -489,8 +478,6 @@ void draw_triangles( ae_individual* indiv, Environment* env, char * directoryNam fprintf( drawingfile, "%lf %lf lineto\n", margin + scalex*(prot->get_mean() + prot->get_width()), 0.5); fprintf( drawingfile, "%lf %lf moveto\n", margin + scalex*(1), 0.5); fprintf( drawingfile, "stroke\n" ); - - prot_node = prot_node->get_next(); } } @@ -777,9 +764,6 @@ void draw_genetic_unit_with_CDS( ae_genetic_unit* gen_unit, char * directoryName // genes // ----------- - ae_list_node<ae_protein*>* node = NULL; - ae_protein* prot = NULL; - int32_t first; int32_t last; int8_t layer = 0; @@ -811,10 +795,7 @@ void draw_genetic_unit_with_CDS( ae_genetic_unit* gen_unit, char * directoryName // printf("LEADING\n" ); - node = (gen_unit->get_protein_list())[LEADING]->get_first(); - while (node != NULL) - { - prot = (ae_protein *) node->get_obj(); + for (const auto& prot: gen_unit->get_protein_list_std()[LEADING]) { first = prot->get_first_translated_pos(); last = prot->get_last_translated_pos(); // h = prot->get_height() * prot->get_concentration(); @@ -906,16 +887,11 @@ void draw_genetic_unit_with_CDS( ae_genetic_unit* gen_unit, char * directoryName fprintf( drawingfile, "%lf %lf %lf %d %d arc\n", 0.5, 0.5, r + layer*0.02, theta_last, theta_first); fprintf( drawingfile, "stroke\n" ); } - - node = node->get_next(); } // printf("LAGGING\n" ); - node = (gen_unit->get_protein_list())[LAGGING]->get_first(); - while (node != NULL) - { - prot = (ae_protein *) node->get_obj(); + for (const auto& prot: gen_unit->get_protein_list_std()[LAGGING]) { first = prot->get_first_translated_pos(); last = prot->get_last_translated_pos(); // h = prot->get_height() * prot->get_concentration(); @@ -1007,8 +983,6 @@ void draw_genetic_unit_with_CDS( ae_genetic_unit* gen_unit, char * directoryName fprintf( drawingfile, "%lf %lf %lf %d %d arc\n", 0.5, 0.5, r - layer*0.02, theta_first, theta_last); fprintf( drawingfile, "stroke\n" ); } - - node = node->get_next(); } diff --git a/src/post_treatments/gene_families.cpp b/src/post_treatments/gene_families.cpp index 269a84a8b3fe5752912b5f41feeb3386df7f8d20..54660e016e078edc32fda8fd40a7e800a6b8c57d 100644 --- a/src/post_treatments/gene_families.cpp +++ b/src/post_treatments/gene_families.cpp @@ -265,22 +265,12 @@ int main(int argc, char** argv) // where the paralogs (gene copies created by duplication) will be monitored ae_list<ae_gene_tree*> * gene_trees = new ae_list<ae_gene_tree*>(); - ae_list_node<ae_protein*> *prot_node = NULL; - ae_protein *prot = NULL; for (const auto& unit: indiv->get_genetic_unit_list_std()) { - prot_node = (unit.get_protein_list()[LEADING])->get_first(); - while(prot_node != NULL) { - prot = prot_node->get_obj(); + for (const auto& prot: unit.get_protein_list_std()[LEADING]) gene_trees->add(new ae_gene_tree(begin_gener, prot)); - prot_node = prot_node->get_next(); - } - prot_node = (unit.get_protein_list()[LAGGING])->get_first(); - while(prot_node != NULL) { - prot = prot_node->get_obj(); + for (const auto& prot: unit.get_protein_list_std()[LAGGING]) gene_trees->add(new ae_gene_tree(begin_gener, prot)); - prot_node = prot_node->get_next(); - } } // =============================================================================== @@ -426,28 +416,16 @@ int main(int argc, char** argv) register_actual_mutation_effect_on_genes_in_trees(gene_trees, &mut, &*unit, num_gener, impact_on_metabolic_error); /* New genes that have been created "from scratch", i.e. not by duplication => new gene tree */ - prot_node = (unit->get_protein_list()[LEADING])->get_first(); - while (prot_node != NULL) - { - prot = prot_node->get_obj(); - search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); - if (genetreenode == NULL) - { - gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); - } - prot_node = prot_node->get_next(); - } - prot_node = (unit->get_protein_list()[LAGGING])->get_first(); - while (prot_node != NULL) - { - prot = prot_node->get_obj(); - search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); - if (genetreenode == NULL) - { - gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); - } - prot_node = prot_node->get_next(); - } + for (const auto& prot: unit->get_protein_list_std()[LEADING]) { + search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); + if (genetreenode == nullptr) + gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); + } + for (const auto& prot: unit->get_protein_list_std()[LAGGING]) { + search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); + if (genetreenode == nullptr) + gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); + } // print_gene_trees_to_screen(gene_trees);// DEBUG // indiv->print_protein_list(); // DEBUG } @@ -470,28 +448,16 @@ int main(int argc, char** argv) register_actual_mutation_effect_on_genes_in_trees(gene_trees, &mut, &*unit, num_gener, impact_on_metabolic_error); /* New genes that have been created "from scratch", i.e. not by duplication => new gene tree */ - prot_node = (unit->get_protein_list()[LEADING])->get_first(); - while (prot_node != NULL) - { - prot = prot_node->get_obj(); - search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); - if (genetreenode == NULL) - { - gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); - } - prot_node = prot_node->get_next(); - } - prot_node = (unit->get_protein_list()[LAGGING])->get_first(); - while (prot_node != NULL) - { - prot = prot_node->get_obj(); - search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); - if (genetreenode == NULL) - { - gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); - } - prot_node = prot_node->get_next(); - } + for (const auto& prot: unit->get_protein_list_std()[LEADING]) { + search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); + if (genetreenode == nullptr) + gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); + } + for (const auto& prot: unit->get_protein_list_std()[LAGGING]) { + search_protein_in_gene_trees(gene_trees, prot, &genetree, &genetreenode); + if (genetreenode == nullptr) + gene_trees->add(new ae_gene_tree(num_gener, prot, &mut)); + } } if ( check_now && ae_utils::mod(num_gener, backup_step) == 0)