1mod arena;
12pub use self::arena::ArenaTree;
13pub use self::arena::Config;
14pub use self::arena::Event;
15pub use self::arena::Noeud;
16pub use self::arena::Options;
17
18pub use self::arena::add_child;
19pub use self::arena::bilan_mappings;
20pub use self::arena::bilan_mappings_reti;
21pub use self::arena::center_gene_nodes;
22pub use self::arena::check_contour_postorder;
23pub use self::arena::check_contour_postorder_tidy_tree;
24pub use self::arena::check_for_obsolete;
25pub use self::arena::check_is_rooted;
26pub use self::arena::check_vertical_contour_postorder;
27pub use self::arena::cladogramme;
28pub use self::arena::copie_fl;
29pub use self::arena::dmin_tidy;
30pub use self::arena::find_left_right;
31pub use self::arena::find_rgtrees;
32pub use self::arena::find_sptrees;
33pub use self::arena::fusion_mod_xy;
34pub use self::arena::get_contour_left;
35pub use self::arena::get_contour_right;
36pub use self::arena::get_contour_tidy_left;
37pub use self::arena::get_contour_tidy_right;
38pub use self::arena::get_maxdepth;
39pub use self::arena::knuth_layout;
40pub use self::arena::lca;
41pub use self::arena::map_gene_trees;
42pub use self::arena::map_species_trees;
43pub use self::arena::move_child;
44pub use self::arena::move_dupli_mappings;
45pub use self::arena::move_species_mappings;
46pub use self::arena::newick2tree;
47pub use self::arena::node_xpos;
48pub use self::arena::node_ypos;
49pub use self::arena::process_fl;
50pub use self::arena::push_down;
51pub use self::arena::push_right;
52pub use self::arena::push_right_tidy_tree;
53pub use self::arena::real_length;
54pub use self::arena::remplace_fl_inv;
55pub use self::arena::reset_pos;
56pub use self::arena::scale_heigth;
57pub use self::arena::scale_width;
58pub use self::arena::set_leaves_to_bottom;
59pub use self::arena::set_leaves_y_values;
60pub use self::arena::set_middle_postorder;
61pub use self::arena::set_species_width;
62pub use self::arena::shift_mod_xy;
63pub use self::arena::shift_nodes_y_values;
64pub use self::arena::species_uniformisation;
65pub use self::arena::summary;
66pub use self::arena::xml2tree;
67
68mod drawing;
69pub use self::drawing::close_chemin_sp;
70pub use self::drawing::close_chemin_sp_filled;
71pub use self::drawing::draw_sptree_gntrees;
72pub use self::drawing::draw_tree;
73pub use self::drawing::get_cadre;
74pub use self::drawing::get_carre;
75pub use self::drawing::get_chemin_carre;
76pub use self::drawing::get_chemin_sp;
77pub use self::drawing::get_chemin_sp_filled;
78pub use self::drawing::get_chemin_transfer;
79pub use self::drawing::get_circle;
80pub use self::drawing::get_cross;
81pub use self::drawing::get_default_color;
82pub use self::drawing::get_half_circle;
83pub use self::drawing::get_longest_name;
84pub use self::drawing::get_longest_name_mul;
85pub use self::drawing::get_longest_x_mul;
86pub use self::drawing::get_triangle;
87pub use self::drawing::set_color_index;
88
89mod building;
90pub use self::building::phyloxml_processing;
91pub use self::building::read_newick;
92pub use self::building::read_phyloxml;
93pub use self::building::read_recphyloxml_multi;
94pub use self::building::recphyloxml_processing;
95
96mod thirdlevel;
97pub use self::thirdlevel::get_gtransfer;
98pub use self::thirdlevel::map_gene_host;
99pub use self::thirdlevel::map_parasite_g2s;
100pub use self::thirdlevel::map_parasite_s2g;
101pub use self::thirdlevel::map_transfer;
102pub use self::thirdlevel::map_transfer_mul;
103pub use self::thirdlevel::select_transfer;
104#[cfg(test)]
105mod tests {
106 use super::*;
107
108 #[test]
109 fn check_set_event() {
110 let mut tree: ArenaTree<String> = ArenaTree::default();
111 let test = String::from("Test");
112 let index = tree.new_node(test);
113 let node = &mut tree.arena[index];
114 node.set_event(Event::Duplication);
115 assert_eq!(node.e, Event::Duplication);
116 }
117 #[test]
118 fn check_x_noref() {
119 let mut tree: ArenaTree<String> = ArenaTree::default();
120 let test = String::from("Test");
121 let index = tree.new_node(test);
122 let node = &mut tree.arena[index];
123 node.set_x_noref(10.0);
124 let x = node.x;
125 assert_eq!(x, 10.0);
126 }
127
128 #[test]
129 fn check_lca() {
130 let mut tree: ArenaTree<String> = ArenaTree::default();
131 let root = tree.new_node("root".to_string());
132 let a1 = tree.new_node("a1".to_string());
133 let a2 = tree.new_node("a2".to_string());
134 let a = tree.new_node("a".to_string());
135 let b = tree.new_node("b".to_string());
136 let c = tree.new_node("c".to_string());
137 let d = tree.new_node("d".to_string());
138 tree.arena[a1].parent = Some(a);
141 tree.arena[a2].parent = Some(a);
142 tree.arena[a].children.push(a1);
143 tree.arena[a].children.push(a2);
144 tree.arena[a].parent = Some(c);
146 tree.arena[b].parent = Some(c);
147 tree.arena[c].children.push(a);
148 tree.arena[c].children.push(b);
149 tree.arena[c].parent = Some(root);
151 tree.arena[d].parent = Some(root);
152 tree.arena[root].children.push(c);
153 tree.arena[root].children.push(d);
154 let lca_test = lca(&mut tree, a1, b);
155 assert_eq!(lca_test, c);
156 }
157 #[test]
158 fn check_read_newick() {
159 let mut tree: ArenaTree<String> = ArenaTree::default();
160 read_newick("examples/newick.txt".to_string(), &mut tree);
161 let options: Options = Options::new();
162 let config: Config = Config::new();
163 phyloxml_processing(&mut tree, &options, &config, "toto.svg".to_string());
164 }
165 #[test]
166 fn check_read_recphylo() {
167 let mut sp_tree: ArenaTree<String> = ArenaTree::default();
168 let mut gene_trees: std::vec::Vec<ArenaTree<String>> = Vec::new();
169 let mut global_roots: std::vec::Vec<usize> = Vec::new();
170 let transfers = vec![];
171 let config: Config = Config::new();
172 let mut options: Options = Options::new();
173 read_recphyloxml_multi(
174 "recphylo_examples/FAM000297_reconciliated.recphylo".to_string(),
175 &mut sp_tree,
176 &mut gene_trees,
177 &mut global_roots,
178 );
179 recphyloxml_processing(
180 &mut sp_tree,
181 &mut gene_trees,
182 &mut options,
183 &config,
184 true,
185 &transfers,
186 "toto.svg".to_string(),
187 );
188 println!("Tree {:?}", sp_tree);
189 }
190 #[test]
191 fn check_read_phylo() {
192 let mut tree: ArenaTree<String> = ArenaTree::default();
193 let options: Options = Options::new();
194 let config: Config = Config::new();
195 read_phyloxml("examples/FAM036542_gene.xml".to_string(), &mut tree);
196 phyloxml_processing(
197 &mut tree,
198 &options,
199 &config,
200 "read_phyloxml.svg".to_string(),
201 );
202 }
203 #[test]
204 fn check_get_index() {
205 let mut tree: ArenaTree<String> = ArenaTree::default();
206 let index = tree.new_node("test".to_string());
207 tree.arena[index].name = "Test".to_string();
208 let test = tree
209 .get_index("Test".to_string())
210 .expect("Error in test check_get_index");
211 assert_eq!(test, index);
212 }
213}