light_phylogeny

Function summary

source
pub fn summary(tree: &mut ArenaTree<String>)
Expand description

Display a short summary of each node of a tree.

Examples found in repository?
examples/build_tree.rs (line 17)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
fn main() {
    let mut tree: ArenaTree<String> = ArenaTree::default();
    let mut options: Options = Options::new();
    let config: Config = Config::new();

    // Create a new node root
    let root = tree.new_node("root".to_string());
    // Create  new nodes
    let a1 = tree.new_node("a1".to_string());
    let a2 = tree.new_node("a2".to_string());
    let a = tree.new_node("a".to_string());
    let b = tree.new_node("b".to_string());
    let c = tree.new_node("c".to_string());
    let d = tree.new_node("d".to_string());
    println!("Initial tree :");
    summary(&mut tree);

    // Set names
    tree.arena[root].name = "MyRoot".to_string();
    tree.arena[a].name = "Gene A".to_string();
    tree.arena[a1].name = "Gene A1".to_string();
    tree.arena[a2].name = "Gene A2".to_string();
    tree.arena[b].name = "Gene B".to_string();
    tree.arena[c].name = "Gene C".to_string();
    tree.arena[d].name = "Gene D".to_string();
    println!("");
    println!("Tree after name attribution:");
    summary(&mut tree);
    // Set hierarchy
    //  a1 and a2 are children of a
    tree.arena[a1].parent = Some(a);
    tree.arena[a2].parent = Some(a);
    tree.arena[a].children.push(a1);
    tree.arena[a].children.push(a2);
    // a and b are children of c
    tree.arena[a].parent = Some(c);
    tree.arena[b].parent = Some(c);
    tree.arena[c].children.push(a);
    tree.arena[c].children.push(b);
    // c and d are children of root
    tree.arena[c].parent = Some(root);
    tree.arena[d].parent = Some(root);
    tree.arena[root].children.push(c);
    tree.arena[root].children.push(d);
    println!("");
    println!("Tree after hierarchy attribution:");
    summary(&mut tree);

    // set duplication
    tree.arena[a].e = Event::Duplication;
    println!("");
    println!("Event associated to gene {} ({}) : {:?}",a,tree.arena[a].name,tree.arena[a].e);
    // Display internal nodes
    options.gene_internal = true ;
    phyloxml_processing(&mut tree, &options, &config,"build_tree.svg".to_string());
    println!("Please open output file 'build_tree.svg' with your browser");
    println!("OK.");
}
More examples
Hide additional examples
examples/modify_tree.rs (line 20)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
fn main() {
    let mut tree: ArenaTree<String> = ArenaTree::default();
    let mut options: Options = Options::new();
    let config: Config = Config::new();

    // Create a new node root
    let root = tree.new_node("root".to_string());
    // Create  new nodes
    let a1 = tree.new_node("a1".to_string());
    let a2 = tree.new_node("a2".to_string());
    let a = tree.new_node("a".to_string());
    let b1 = tree.new_node("b1".to_string());
    let b2 = tree.new_node("b2".to_string());
    let b = tree.new_node("b".to_string());
    let c = tree.new_node("c".to_string());
    let d = tree.new_node("d".to_string());
    println!("Initial tree :");
    summary(&mut tree);

    // Set names
    tree.arena[root].name = "MyRoot".to_string();
    tree.arena[a].name = "Gene A".to_string();
    tree.arena[a1].name = "Gene A1".to_string();
    tree.arena[a2].name = "Gene A2".to_string();
    tree.arena[b].name = "Gene B".to_string();
    tree.arena[b1].name = "Gene B1".to_string();
    tree.arena[b2].name = "Gene B2".to_string();
    tree.arena[c].name = "Gene C".to_string();
    tree.arena[d].name = "Gene D".to_string();
    println!("");
    println!("Tree after name attribution:");
    summary(&mut tree);
    // Set hierarchy
    //  a1 and a2 are children of a
    add_child(&mut tree,a,a1);
    add_child(&mut tree,a,a2);
    //  a1 and a2 are children of a
    add_child(&mut tree,b,b1);
    add_child(&mut tree,b,b2);
    // a and b are children of c
    add_child(&mut tree,c,a);
    add_child(&mut tree,c,b);
    // c and d are children of root
    add_child(&mut tree,root,c);
    add_child(&mut tree,root,d);

    println!("");
    println!("Tree after hierarchy attribution:");
    summary(&mut tree);
    // Display internal nodes
    options.gene_internal = true ;

    phyloxml_processing(&mut tree, &options, &config,"modify_tree_ini.svg".to_string());
    // knuth_layout(&mut tree,root, &mut 1);
    // cladogramme(&mut tree);
    // check_contour_postorder(&mut tree, root);
    // shift_mod_xy(&mut tree, root, &mut 0.0, &mut 0.0);
    // set_middle_postorder(&mut tree, root);
    // draw_tree(&mut tree,"modify_tree_ini.svg".to_string(),&options,&config);

    println!("Add a loss to C");
    let loss = tree.new_node("loss".to_string());
    tree.arena[loss].name = "Loss".to_string();
    tree.arena[loss].e = Event::Loss;
    add_child(&mut tree,c,loss);

    println!("Add a node up to  B");
    let add = tree.new_node("add".to_string());
    tree.arena[add].name = "Added up to  B".to_string();
    println!("Move A to new node ");
    move_child(&mut tree, a, add);
    println!("Move B to new node ");
    move_child(&mut tree, b, add);
    println!("Move  new node to C ");
    add_child(&mut tree, c, add);

    println!("Tree after hierarchy modification:");
    summary(&mut tree);
    reset_pos(&mut tree);
    phyloxml_processing(&mut tree, &options, &config,"modify_tree_mod.svg".to_string());

    // knuth_layout(&mut tree,root, &mut 1);
    // cladogramme(&mut tree);
    // check_contour_postorder(&mut tree, root);
    // shift_mod_xy(&mut tree, root, &mut 0.0, &mut 0.0);
    // set_middle_postorder(&mut tree, root);
    // draw_tree(&mut tree,"modify_tree_mod.svg".to_string(),&options,&config);
    println!("Please open output files  'modify_tree_ini.svg' and 'modify_tree_mod.svg' with your browser");
    println!("OK.");
}
examples/read_recphyloxml_2.rs (line 76)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
fn main() {


    let mut options: Options = Options::new();
    let config: Config = Config::new();
    let transfers = vec![];
    let infile_gene_para = "examples/gene_parasite_page2.recphylo".to_string();
    let infile_para_host = "examples/hote_parasite_page2.recphylo".to_string();

    let outfile_gene_para = String::from("gene_para.svg");
    let outfile_para = String::from("para.svg");
    let outfile_para_rec = String::from("para_rec.svg");
    let outfile_para_host = String::from("para_host.svg");
    let outfile_host = String::from("host.svg");

    // On cree une structure Arena pour l'arbre d'espece
    // et un vecteur de  structures Arena pour le(s) arbres de gènes
    // -------------------------------------------------------------
    // Creation de la structure ArenaTree pour l'arbre d'espece
    // --------------------------------------------------------
    let mut tree_para_pipe: ArenaTree<String> = ArenaTree::default();
    // Creation du vecteur de structure ArenaTree pour les genes
    // ---------------------------------------------------------
    let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
    let mut global_roots: std::vec::Vec<usize> = Vec::new();
    read_recphyloxml_multi(infile_gene_para,&mut tree_para_pipe,&mut gene_trees, &mut global_roots);
    let  nb_gntree =  gene_trees.len().clone();
    println!("Number of gene trees : {}",nb_gntree);
    info!("List of gene trees : {:?}",gene_trees);
    recphyloxml_processing(&mut tree_para_pipe,&mut  gene_trees, &mut options, &config,true,
        &transfers,outfile_gene_para);
    reset_pos(&mut tree_para_pipe);
    phyloxml_processing(&mut tree_para_pipe, &mut options, &config,outfile_para);

    // On cree une structure Arena pour l'arbre d'espece
    // et un vecteur de  structures Arena pour le(s) arbres de gènes
    // -------------------------------------------------------------
    // Creation de la structure ArenaTree pour l'arbre d'espece
    // --------------------------------------------------------
    let mut tree_host_pipe: ArenaTree<String> = ArenaTree::default();
    // Creation du vecteur de structure ArenaTree pour les genes
    // ---------------------------------------------------------
    let mut para_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
    let mut global_roots: std::vec::Vec<usize> = Vec::new();
    read_recphyloxml_multi(infile_para_host,&mut tree_host_pipe,&mut para_trees, &mut  global_roots);
    let  nb_paratree =  para_trees.len().clone();
    println!("Number of gene trees : {}",nb_paratree);
    info!("List of gene trees : {:?}",para_trees);
    recphyloxml_processing(&mut tree_host_pipe,&mut  para_trees, &mut options, &config,
        true, &transfers,outfile_para_host);
    reset_pos(&mut tree_host_pipe);
    phyloxml_processing(&mut tree_host_pipe, &mut options, &config,outfile_host);
    reset_pos(&mut para_trees[0]);
    phyloxml_processing(&mut para_trees[0], &mut options, &config,outfile_para_rec);

    // Generation du svg 3 niveaux
    println!("Parasite trees as a 'gene tree' : {:?}",para_trees);
    println!("Parasite tree as a 'species tree' : {:?}",tree_para_pipe);
    println!("Map parasite as 'gene' to parasite as 'species'");
    println!("==============================================");
    map_parasite_g2s(&mut tree_para_pipe, &mut para_trees[0]);
    println!("Map parasite as 'species' to paraiste as 'gene'");
    println!("==============================================");
    map_parasite_s2g(&mut tree_para_pipe, &mut para_trees[0], &mut gene_trees);
    println!("Mapping again!");
    println!("Map parasite as 'gene' to parasite as 'species'");
    println!("==============================================");
    map_parasite_g2s(&mut tree_para_pipe, &mut para_trees[0]);
    summary(&mut tree_para_pipe);

    reset_pos(&mut tree_para_pipe);
    reset_pos(&mut gene_trees[0]);
    recphyloxml_processing(&mut tree_para_pipe, &mut gene_trees, &mut options, &config, false,
        &transfers,"test_mapped.svg".to_string());

    // Generation des svg hote parsite  +transfert gene

    let gene_transfers = get_gtransfer(&mut gene_trees[0]);
    println!("Transfers = {:?}",gene_transfers);
    let mapped_gene_transfers = map_transfer(gene_transfers, &mut para_trees[0]);
    println!("Mapped transfers = {:?}",mapped_gene_transfers);
    reset_pos(&mut tree_host_pipe);
    reset_pos(&mut para_trees[0]);
    recphyloxml_processing(&mut tree_host_pipe, &mut para_trees, &mut options, &config,
        false, &mapped_gene_transfers,"test_mapped_2levels.svg".to_string());



}
examples/read_recphyloxml_3.rs (line 91)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
fn main() {


    let mut options: Options = Options::new();
    let mut config: Config = Config::new();
    config.species_opacity = "0.7".to_string();
    config.gene_opacity = "0.9".to_string();
    let transfers = vec![];
    let infile_gene_para = "examples/recgs_dtl.recphyloxml".to_string();
    let infile_para_host = "examples/rechp_dtl.recphyloxml".to_string();

    // let infile_gene_para = "examples/gene_parasite_page4.recphylo".to_string();
    // let infile_para_host = "examples/hote_parasite_page4.recphylo".to_string();


    let outfile_gene_para = String::from("gene_para.svg");
    let outfile_para = String::from("para.svg");
    let outfile_para_rec = String::from("para_rec.svg");
    let outfile_para_host = String::from("para_host.svg");
    let outfile_host = String::from("host.svg");

    // On cree une structure Arena pour l'arbre d'espece
    // et un vecteur de  structures Arena pour le(s) arbres de gènes
    // -------------------------------------------------------------
    // Creation de la structure ArenaTree pour l'arbre d'espece
    // --------------------------------------------------------
    let mut tree_para_pipe: ArenaTree<String> = ArenaTree::default();
    // Creation du vecteur de structure ArenaTree pour les genes
    // ---------------------------------------------------------
    let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
    let mut global_roots: std::vec::Vec<usize> = Vec::new();
    read_recphyloxml_multi(infile_gene_para, &mut tree_para_pipe, &mut gene_trees, &mut global_roots);
    let  nb_gntree =  gene_trees.len().clone();
    // let mut gene_trees_clone:std::vec::Vec<ArenaTree<String>> = Vec::new();
    // let mut i = 0;
    // while i < nb_gntree {
    //  gene_trees_clone.push(gene_trees[i].clone());
    // i = i + 1;
    // }
    println!("Number of gene trees : {}",nb_gntree);
    info!("List of gene trees : {:?}",gene_trees);
    recphyloxml_processing(&mut tree_para_pipe,&mut  gene_trees, &mut options, &config,true,
        &transfers,outfile_gene_para);
    reset_pos(&mut tree_para_pipe);
    phyloxml_processing(&mut tree_para_pipe, &mut options, &config,outfile_para);

    // On cree une structure Arena pour l'arbre d'espece
    // et un vecteur de  structures Arena pour le(s) arbres de gènes
    // -------------------------------------------------------------
    // Creation de la structure ArenaTree pour l'arbre d'espece
    // --------------------------------------------------------
    let mut tree_host_pipe: ArenaTree<String> = ArenaTree::default();
    // Creation du vecteur de structure ArenaTree pour les genes
    // ---------------------------------------------------------
    let mut para_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
    let mut global_roots: std::vec::Vec<usize> = Vec::new();
    read_recphyloxml_multi(infile_para_host,&mut tree_host_pipe,&mut para_trees, &mut global_roots);
    let  nb_paratree =  para_trees.len().clone();
    assert_eq!(nb_paratree,1,"I want only one parasite tree");
    println!("Number of gene trees : {}",nb_paratree);
    info!("List of gene trees : {:?}",para_trees);
    recphyloxml_processing(&mut tree_host_pipe,&mut  para_trees, &mut options, &config,
        true, &transfers,outfile_para_host);
    reset_pos(&mut tree_host_pipe);
    phyloxml_processing(&mut tree_host_pipe, &mut options, &config,outfile_host);
    reset_pos(&mut para_trees[0]);
    phyloxml_processing(&mut para_trees[0], &mut options, &config,outfile_para_rec);

    // Generation du svg 3 niveaux
    println!("Parasite trees as a 'gene tree' : {:?}",para_trees);
    println!("Parasite tree as a 'species tree' : {:?}",tree_para_pipe);
    println!("Map parasite as 'gene' to parasite as 'species'");
    println!("==============================================");
    map_parasite_g2s(&mut tree_para_pipe, &mut para_trees[0]);
    println!("Map parasite as 'species' to paraiste as 'gene'");
    println!("==============================================");
    map_parasite_s2g(&mut tree_para_pipe, &mut para_trees[0], &mut gene_trees);
    println!("MAP AGAIN!");
    println!("MON GROS DEBUG PARAPIPE1{:?}",&mut tree_para_pipe);
    println!("Map parasite as 'gene' to parasite as 'species'");
    println!("==============================================");
    map_parasite_g2s(&mut tree_para_pipe, &mut para_trees[0]);
    summary(&mut tree_para_pipe);


    reset_pos(&mut tree_para_pipe);
    let mut i = 0;
    while i < nb_gntree {
    reset_pos(&mut gene_trees[i]);
    i = i + 1;
    }
    // reset_pos(&mut gene_trees[0]);
    // reset_pos(&mut gene_trees[1]);
    // reset_pos(&mut gene_trees[2]);
    // reset_pos(&mut gene_trees[2]);
    // options.species_internal = true;
    // options.gene_internal = true;
//     options.verbose = true;
//     env::set_var("RUST_LOG", "info");
// env_logger::init();
// info!("Verbosity set to Info");

    // attention on ne remape pas
    recphyloxml_processing(&mut tree_para_pipe, &mut gene_trees, &mut options, &config, false,
        &transfers,"visu_3levels_1.svg".to_string());

    // Generation des svg hote parsite  +transfert gene

    let gene_transfers = get_gtransfer(&mut gene_trees[0]);
    println!("Transfers = {:?}",gene_transfers);
    let mut mapped_gene_transfers = map_transfer(gene_transfers, &mut para_trees[0]);
    println!("Mapped transfers = {:?}",mapped_gene_transfers);
    let mut i = 1;
    while i < nb_gntree {
        let gene_transfers = get_gtransfer(&mut gene_trees[i]);
        println!("Transfers = {:?}",gene_transfers);
        let mapped = map_transfer(gene_transfers, &mut para_trees[0]);
        println!("Mapped transfers = {:?}",mapped);
        for val in mapped {
            mapped_gene_transfers.push(val);
        }
        i = i + 1;
    }
    reset_pos(&mut tree_host_pipe);
    reset_pos(&mut para_trees[0]);
    // attention on ne remape pas
    recphyloxml_processing(&mut tree_host_pipe, &mut para_trees, &mut options, &config,
        false, &mapped_gene_transfers,"visu_3levels_2.svg".to_string());


    // mapping des gene sur les hotes via les parasites
    map_gene_host(&mut gene_trees, &mut para_trees, &mut tree_host_pipe);
    reset_pos(&mut tree_host_pipe);
    let mut i = 0;
    while i < nb_gntree {
        reset_pos(&mut gene_trees[i]);
        i = i + 1;
    }
    recphyloxml_processing(&mut tree_host_pipe, &mut gene_trees, &mut options, &config,
        true, &vec![],"visu_3levels_3.svg".to_string());
}