pub fn reset_pos(tree: &mut ArenaTree<String>)
Expand description
Reset all positions x y xmod ymod of a tree.
Examples found in repository?
examples/modify_tree.rs (line 81)
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.");
}
More examples
examples/read_recphyloxml_2.rs (line 39)
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 52)
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());
}
examples/read_recphyloxml_multi.rs (line 22)
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 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
fn main() {
let transfers = vec![];
let mut options: Options = Options::new();
options.species_internal = true;
let config: Config = Config::new();
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/recgs_mult_host_dtl.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi.svg".to_string());
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/ex2comp.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi_2.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi_2.svg".to_string());
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/ex3comp.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi_3.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi_3.svg".to_string());
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/ex4comp.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi_4.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi_4.svg".to_string());
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/ex5comp.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi_5.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi_5.svg".to_string());
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/ex6comp.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi_6.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi_6.svg".to_string());
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/ex7comp.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi_7.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi_7.svg".to_string());
let mut sp_tree: ArenaTree<String> = ArenaTree::default();
let mut gene_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi("examples/ex8comp.recphyloxml".to_string(),
&mut sp_tree, &mut gene_trees, &mut global_roots);
// Version recphylo
recphyloxml_processing(&mut sp_tree, &mut gene_trees, &mut options, &config, true,
&transfers, "read_recphyloxml_multi_8.svg".to_string());
// Version phylo
reset_pos(&mut sp_tree);
phyloxml_processing(&mut sp_tree, &mut options, &config,
"read_phyloxml_multi_8.svg".to_string());
println!("Please open output files 'read_recphyloxml_multi.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi.svg' with your browser");
println!("Please open output files 'read_recphyloxml_multi_2.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi_2.svg' with your browser");
println!("Please open output files 'read_recphyloxml_multi_3.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi_3.svg' with your browser");
println!("Please open output files 'read_recphyloxml_multi_4.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi_4.svg' with your browser");
println!("Please open output files 'read_recphyloxml_multi_5.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi_5.svg' with your browser");
println!("Please open output files 'read_recphyloxml_multi_6.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi_6.svg' with your browser");
println!("Please open output files 'read_recphyloxml_multi_7.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi_7.svg' with your browser");
println!("Please open output files 'read_recphyloxml_multi_8.svg' with your browser");
println!("Please open output files 'read_phyloxml_multi_8.svg' with your browser");
}
examples/read_recphyloxml_thirdlevel_5.rs (line 92)
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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
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_gs = "examples/test4/gene_parasite_page4.recphylo".to_string();
let infile_sh = "examples/test4/hote_parasite_page4.recphylo".to_string();
// Traitement de 2 fichier fichiers recPhyloXML
println!("Two reconciled files => displaying 3-levels reconciliations. ");
let outfile_gene_para = String::from("gene_para.svg");
let outfile_para_host = String::from("para_host.svg");
let outfile_mapped_1 = String::from("mapped_1.svg");
let outfile_mapped_2 = String::from("mapped_2.svg");
// ---------------------------------------------------------
// Create a structure Arena for the global parasite pipe
// tree and a vector of structures Arena for gene path trees
// ---------------------------------------------------------
let mut global_pipe_parasite: ArenaTree<String> = ArenaTree::default();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
let mut path_genes: std::vec::Vec<ArenaTree<String>> = Vec::new();
// ---------------------------------------------------------
// Fill global parasite pipe tree and is roots and path
// genes trees
// ---------------------------------------------------------
read_recphyloxml_multi(infile_gs,&mut global_pipe_parasite,&mut path_genes,&mut global_roots);
let nb_gntree = path_genes.len().clone();
println!("Number of gene trees : {}",nb_gntree);
info!("List of gene trees : {:?}",path_genes);
let nb_parasite_pipe = global_roots.len().clone();
println!("Number of parasite trees : {}",nb_parasite_pipe);
println!("List of species trees roots : {:?}",global_roots);
info!("Global parasite pipe tree : {:?}",global_pipe_parasite);
// ---------------------------------------------------------
// Generate svg of the lobal parasite pipe tree and path
// genes trees
// ---------------------------------------------------------
recphyloxml_processing(&mut global_pipe_parasite,&mut path_genes, &mut options, &config,true,
&transfers,outfile_gene_para);
// ---------------------------------------------------------
// Create a structure Arena for the host pipe tree and a
// vector of structures Arena for parasite path trees
// ---------------------------------------------------------
let mut tree_host_pipe: ArenaTree<String> = ArenaTree::default();
let mut path_para_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
// ---------------------------------------------------------
// Fill host pipe tree and is roots and path parasite trees
// ---------------------------------------------------------
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi(infile_sh,&mut tree_host_pipe,&mut path_para_trees, &mut global_roots);
let nb_parasite_path = path_para_trees.len().clone();
println!("Number of pipe parasite trees in gene-parasite file : {}",nb_parasite_pipe);
println!("Number of path parasite trees in parasite-host file : {}",nb_parasite_path);
if nb_parasite_path != nb_parasite_pipe {
println!();
println!("==============================================");
println!("Error! Different number of parasite trees in the 2 files!");
println!(" Resulting svg will be incomplete.");
println!("==============================================");
println!();
}
// ---------------------------------------------------------
// Generate svg of the host pipe tree and path parasite trees
// ---------------------------------------------------------
recphyloxml_processing(&mut tree_host_pipe,&mut path_para_trees, &mut options, &config,
true, &transfers,outfile_para_host);
// ---------------------------------------------------------
// Generation of first 3 levels svg
// ---------------------------------------------------------
info!("Parasite trees as a 'path tree' : {:?}",path_para_trees);
info!("Parasite tree as a 'pipe tree' : {:?}",global_pipe_parasite);
println!("==============================================");
println!("Map parasite as 'path' to parasite as 'pipe'");
println!("==============================================");
let mut i = 0;
while i < nb_parasite_pipe {
map_parasite_g2s(&mut global_pipe_parasite, &mut path_para_trees[i]);
i = i + 1;
}
info!("Global parasite tree wih events : {:?}",global_pipe_parasite);
reset_pos(&mut global_pipe_parasite);
let mut i = 0;
while i < nb_gntree {
reset_pos(&mut path_genes[i]);
i = i + 1;
}
println!("==============================================");
println!("Map parasite as 'species' to parasite as 'gene'");
println!("==============================================");
let mut i = 0;
while i < nb_parasite_pipe {
map_parasite_s2g(&mut global_pipe_parasite, &mut path_para_trees[i],&mut path_genes);
i = i + 1;
}
info!("Global pipe parasite after mapping s2g : {:?}",global_pipe_parasite);
println!("==============================================");
println!("Map parasite as 'gene' to parasite as 'species' again");
println!("==============================================");
let mut i = 0;
while i < nb_parasite_pipe {
map_parasite_g2s(&mut global_pipe_parasite, &mut path_para_trees[i]);
i = i + 1;
}
reset_pos(&mut global_pipe_parasite);
let mut i = 0;
while i < nb_gntree {
reset_pos(&mut path_genes[i]);
i = i + 1;
}
// attention on ne remape pas
recphyloxml_processing(&mut global_pipe_parasite,&mut path_genes, &mut options, &config,false,
&transfers,outfile_mapped_1);
// ---------------------------------------------------------
// Generation of second 3 levels svg
// ---------------------------------------------------------
let mut i = 0;
let gene_transfers = get_gtransfer(&mut path_genes[i]);
info!("Transfers = {:?}",gene_transfers);
let mut mapped_gene_transfers = map_transfer_mul(gene_transfers, &mut path_para_trees);
info!("Mapped transfers = {:?}",mapped_gene_transfers);
i = i + 1;
while i < nb_gntree {
let gene_transfers = get_gtransfer(&mut path_genes[i]);
info!("Transfers = {:?}",gene_transfers);
let mapped = map_transfer(gene_transfers, &mut path_para_trees[0]);
info!("Mapped transfers = {:?}",mapped);
for val in mapped {
mapped_gene_transfers.push(val);
}
i = i + 1;
}
reset_pos(&mut tree_host_pipe);
let mut i = 0;
while i < nb_parasite_pipe {
reset_pos(&mut path_para_trees[i]);
i = i + 1;
}
println!("Building svg 2: parasite tree within host pipe tree and mapped tarnsfers {}",
outfile_mapped_2);
// attention on ne remape pas
recphyloxml_processing(&mut tree_host_pipe, &mut path_para_trees, &mut options, &config,
false, &mapped_gene_transfers,outfile_mapped_2);
reset_pos(&mut global_pipe_parasite);
phyloxml_processing(&mut global_pipe_parasite, &mut options, &config,"para_simple.svg".to_string());
reset_pos(&mut tree_host_pipe);
phyloxml_processing(&mut tree_host_pipe, &mut options, &config,"host_simple.svg".to_string());
let mut i = 0;
while i < nb_parasite_pipe {
reset_pos(&mut path_para_trees[i]);
phyloxml_processing(&mut path_para_trees[i], &mut options, &config,("gene_simple_".to_owned()+&i.to_string()+".svg").to_string());
i = i + 1;
}
//llmlmlmlmlmlm
// mapping des gene sur les hotes via les parasites
// let mut i = 0;
// while i < nb_parasite_pipe {
// map_gene_host(&mut path_genes, &mut path_para_trees[i], &mut tree_host_pipe);
// i = i + 1;
// }
map_gene_host(&mut path_genes, &mut path_para_trees, &mut tree_host_pipe);
// map_gene_host(&mut path_genes, &mut path_para_trees[1], &mut tree_host_pipe);
reset_pos(&mut tree_host_pipe);
let mut i = 0;
while i < nb_gntree {
reset_pos(&mut path_genes[i]);
i = i + 1;
}
recphyloxml_processing(&mut tree_host_pipe, &mut path_genes, &mut options, &config,
true, &vec![],"mapped_3.svg".to_string());
// lmlmlmlm
println!("Output files:");
println!(" - host_simple.svg ...... 1 level: host tree");
let mut i = 0;
while i < nb_parasite_pipe {
println!(" - para_simple.svg ...... 2 levels: gene_simple_{}.svg",&i);
i = i + 1;
}
println!(" - para_simple.svg ...... 2 levels: parasite tree(s)");
println!(" - gene_para.svg ........ 2 levels: pipe parasite tree(s) with gene tree(s) inside");
println!(" - para_host.svg ........ 2 levels: pipe host tree with parasite tree(s) inside");
println!(" - mapped_1.svg ........ 3 levels: reconciled pipe parasite tree(s) with gene tree(s)");
println!(" - mapped_2.svg ........ 3 levels: parasite-host reconciliation plus gene transfers");
println!(" - mapped_3.svg ........ 3 levels: pipe host tree with gene tree(s) inside");
if nb_parasite_path != nb_parasite_pipe {
println!();
println!("==============================================");
println!("Error! Different number of parasite trees in the 2 files!");
println!(" Resulting svg will be incomplete.");
println!("==============================================");
println!();
}
}
examples/read_recphyloxml_thirdlevel_6.rs (line 95)
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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
fn main() {
// env::set_var("RUST_LOG", "info");
// env_logger::init();
let mut options: Options = Options::new();
options.gene_internal = true;
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_gs = "examples/rec0.recphyloxml".to_string();
let infile_sh = "examples/rec0upper.recphyloxml".to_string();
// Traitement de 2 fichier fichiers recPhyloXML
println!("Two reconciled files => displaying 3-levels reconciliations. ");
let outfile_gene_para = String::from("gene_para.svg");
let outfile_para_host = String::from("para_host.svg");
let outfile_mapped_1 = String::from("mapped_1.svg");
let outfile_mapped_2 = String::from("mapped_2.svg");
// ---------------------------------------------------------
// Create a structure Arena for the global parasite pipe
// tree and a vector of structures Arena for gene path trees
// ---------------------------------------------------------
let mut global_pipe_parasite: ArenaTree<String> = ArenaTree::default();
let mut global_roots: std::vec::Vec<usize> = Vec::new();
let mut path_genes: std::vec::Vec<ArenaTree<String>> = Vec::new();
// ---------------------------------------------------------
// Fill global parasite pipe tree and is roots and path
// genes trees
// ---------------------------------------------------------
read_recphyloxml_multi(infile_gs,&mut global_pipe_parasite,&mut path_genes,&mut global_roots);
let nb_gntree = path_genes.len().clone();
println!("Number of gene trees : {}",nb_gntree);
info!("List of gene trees : {:?}",path_genes);
let nb_parasite_pipe = global_roots.len().clone();
println!("Number of parasite trees : {}",nb_parasite_pipe);
println!("List of species trees roots : {:?}",global_roots);
info!("Global parasite pipe tree : {:?}",global_pipe_parasite);
// ---------------------------------------------------------
// Generate svg of the lobal parasite pipe tree and path
// genes trees
// ---------------------------------------------------------
recphyloxml_processing(&mut global_pipe_parasite,&mut path_genes, &mut options, &config,true,
&transfers,outfile_gene_para);
// ---------------------------------------------------------
// Create a structure Arena for the host pipe tree and a
// vector of structures Arena for parasite path trees
// ---------------------------------------------------------
let mut tree_host_pipe: ArenaTree<String> = ArenaTree::default();
let mut path_para_trees:std::vec::Vec<ArenaTree<String>> = Vec::new();
// ---------------------------------------------------------
// Fill host pipe tree and is roots and path parasite trees
// ---------------------------------------------------------
let mut global_roots: std::vec::Vec<usize> = Vec::new();
read_recphyloxml_multi(infile_sh,&mut tree_host_pipe,&mut path_para_trees, &mut global_roots);
let nb_parasite_path = path_para_trees.len().clone();
println!("Number of pipe parasite trees in gene-parasite file : {}",nb_parasite_pipe);
println!("Number of path parasite trees in parasite-host file : {}",nb_parasite_path);
if nb_parasite_path != nb_parasite_pipe {
println!();
println!("==============================================");
println!("Error! Different number of parasite trees in the 2 files!");
println!(" Resulting svg will be incomplete.");
println!("==============================================");
println!();
}
// ---------------------------------------------------------
// Generate svg of the host pipe tree and path parasite trees
// ---------------------------------------------------------
recphyloxml_processing(&mut tree_host_pipe,&mut path_para_trees, &mut options, &config,
true, &transfers,outfile_para_host);
// ---------------------------------------------------------
// Generation of first 3 levels svg
// ---------------------------------------------------------
info!("Parasite trees as a 'path tree' : {:?}",path_para_trees);
info!("Parasite tree as a 'pipe tree' : {:?}",global_pipe_parasite);
println!("==============================================");
println!("Map parasite as 'path' to parasite as 'pipe'");
println!("==============================================");
let mut i = 0;
while i < nb_parasite_pipe {
map_parasite_g2s(&mut global_pipe_parasite, &mut path_para_trees[i]);
i = i + 1;
}
info!("Global parasite tree wih events : {:?}",global_pipe_parasite);
reset_pos(&mut global_pipe_parasite);
let mut i = 0;
while i < nb_gntree {
reset_pos(&mut path_genes[i]);
i = i + 1;
}
println!("==============================================");
println!("Map parasite as 'species' to parasite as 'gene'");
println!("==============================================");
let mut i = 0;
while i < nb_parasite_pipe {
map_parasite_s2g(&mut global_pipe_parasite, &mut path_para_trees[i],&mut path_genes);
i = i + 1;
}
info!("Global pipe parasite after mapping s2g : {:?}",global_pipe_parasite);
println!("==============================================");
println!("Map parasite as 'gene' to parasite as 'species' again");
println!("==============================================");
let mut i = 0;
while i < nb_parasite_pipe {
map_parasite_g2s(&mut global_pipe_parasite, &mut path_para_trees[i]);
i = i + 1;
}
reset_pos(&mut global_pipe_parasite);
let mut i = 0;
while i < nb_gntree {
reset_pos(&mut path_genes[i]);
i = i + 1;
}
// attention on ne remape pas
recphyloxml_processing(&mut global_pipe_parasite,&mut path_genes, &mut options, &config,false,
&transfers,outfile_mapped_1);
// ---------------------------------------------------------
// Generation of second 3 levels svg
// ---------------------------------------------------------
let mut i = 0;
let gene_transfers = get_gtransfer(&mut path_genes[i]);
info!("Transfers = {:?}",gene_transfers);
let mut mapped_gene_transfers = map_transfer_mul(gene_transfers, &mut path_para_trees);
info!("Mapped transfers = {:?}",mapped_gene_transfers);
i = i + 1;
while i < nb_gntree {
let gene_transfers = get_gtransfer(&mut path_genes[i]);
info!("Transfers = {:?}",gene_transfers);
let mapped = map_transfer(gene_transfers, &mut path_para_trees[0]);
info!("Mapped transfers = {:?}",mapped);
for val in mapped {
mapped_gene_transfers.push(val);
}
i = i + 1;
}
reset_pos(&mut tree_host_pipe);
let mut i = 0;
while i < nb_parasite_pipe {
reset_pos(&mut path_para_trees[i]);
i = i + 1;
}
println!("Building svg 2: parasite tree within host pipe tree and mapped tarnsfers {}",
outfile_mapped_2);
// attention on ne remape pas
recphyloxml_processing(&mut tree_host_pipe, &mut path_para_trees, &mut options, &config,
false, &mapped_gene_transfers,outfile_mapped_2);
reset_pos(&mut global_pipe_parasite);
phyloxml_processing(&mut global_pipe_parasite, &mut options, &config,"para_simple.svg".to_string());
reset_pos(&mut tree_host_pipe);
phyloxml_processing(&mut tree_host_pipe, &mut options, &config,"host_simple.svg".to_string());
let mut i = 0;
while i < nb_parasite_pipe {
reset_pos(&mut path_para_trees[i]);
phyloxml_processing(&mut path_para_trees[i], &mut options, &config,("gene_simple_".to_owned()+&i.to_string()+".svg").to_string());
i = i + 1;
}
//llmlmlmlmlmlm
// mapping des gene sur les hotes via les parasites
println!("Building svg 3: gene tree within host pipe tree");
map_gene_host(&mut path_genes, &mut path_para_trees, &mut tree_host_pipe);
// map_gene_host(&mut path_genes, &mut path_para_trees[1], &mut tree_host_pipe);
reset_pos(&mut tree_host_pipe);
let mut i = 0;
while i < nb_gntree {
reset_pos(&mut path_genes[i]);
i = i + 1;
}
recphyloxml_processing(&mut tree_host_pipe, &mut path_genes, &mut options, &config,
true, &vec![],"mapped_3.svg".to_string());
// println!("DEBUG FINAL HOST = {:?}",tree_host_pipe);
// lmlmlmlm
println!("Output files:");
println!(" - host_simple.svg ...... 1 level: host tree");
let mut i = 0;
while i < nb_parasite_pipe {
println!(" - para_simple.svg ...... 2 levels: gene_simple_{}.svg",&i);
i = i + 1;
}
println!(" - para_simple.svg ...... 2 levels: parasite tree(s)");
println!(" - gene_para.svg ........ 2 levels: pipe parasite tree(s) with gene tree(s) inside");
println!(" - para_host.svg ........ 2 levels: pipe host tree with parasite tree(s) inside");
println!(" - mapped_1.svg ........ 3 levels: reconciled pipe parasite tree(s) with gene tree(s)");
println!(" - mapped_2.svg ........ 3 levels: parasite-host reconciliation plus gene transfers");
println!(" - mapped_3.svg ........ 3 levels: pipe host tree with gene tree(s) inside");
if nb_parasite_path != nb_parasite_pipe {
println!();
println!("==============================================");
println!("Error! Different number of parasite trees in the 2 files!");
println!(" Resulting svg will be incomplete.");
println!("==============================================");
println!();
}
}
Additional examples can be found in:
- examples/read_recphyloxml_thirdlevel_bug.rs
- examples/read_recphyloxml_thirdlevel_1.rs
- examples/read_recphyloxml_thirdlevel_3.rs
- examples/read_recphyloxml_thirdlevel_1_midist.rs
- examples/read_recphyloxml_thirdlevel_2.rs
- examples/read_recphyloxml_thirdlevel_stroke.rs
- examples/read_recphyloxml_thirdlevel_fl.rs
- examples/read_recphyloxml_thirdlevel_alex.rs
- examples/read_recphyloxml_thirdlevel_4.rs
- examples/read_recphyloxml_thirdlevel_4_landscape.rs