2
2
struct IteratorOutput {
3
3
edges : Vec < tskit:: EdgeTableRow > ,
4
4
nodes : Vec < tskit:: NodeTableRow > ,
5
+ sites : Vec < tskit:: SiteTableRow > ,
6
+ mutations : Vec < tskit:: MutationTableRow > ,
7
+ migrations : Vec < tskit:: MigrationTableRow > ,
8
+ populations : Vec < tskit:: PopulationTableRow > ,
5
9
}
6
10
7
11
impl IteratorOutput {
8
12
fn new_from_tables ( tables : & tskit:: TableCollection ) -> Self {
9
13
let edges = tables. edges ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
10
14
let nodes = tables. nodes ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
11
- Self { edges, nodes }
15
+ let sites = tables. sites ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
16
+ let mutations = tables. mutations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
17
+ let populations = tables. populations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
18
+ let migrations = tables. migrations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
19
+ Self {
20
+ edges,
21
+ nodes,
22
+ sites,
23
+ mutations,
24
+ populations,
25
+ migrations,
26
+ }
12
27
}
13
28
14
29
fn new_from_treeseq ( treeseq : & tskit:: TreeSequence ) -> Self {
15
30
let edges = treeseq. tables ( ) . edges ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
16
31
let nodes = treeseq. tables ( ) . nodes ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
17
- Self { edges, nodes }
32
+ let sites = treeseq. tables ( ) . sites ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
33
+ let mutations = treeseq. tables ( ) . mutations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
34
+ let populations = treeseq. tables ( ) . populations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
35
+ let migrations = treeseq. tables ( ) . migrations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
36
+ Self {
37
+ edges,
38
+ nodes,
39
+ sites,
40
+ mutations,
41
+ populations,
42
+ migrations,
43
+ }
18
44
}
19
45
20
46
fn new_from_table_access < T > ( access : & T ) -> Self
@@ -23,7 +49,18 @@ impl IteratorOutput {
23
49
{
24
50
let edges = access. edges ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
25
51
let nodes = access. nodes ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
26
- Self { edges, nodes }
52
+ let sites = access. sites ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
53
+ let mutations = access. mutations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
54
+ let populations = access. populations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
55
+ let migrations = access. migrations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
56
+ Self {
57
+ edges,
58
+ nodes,
59
+ sites,
60
+ mutations,
61
+ populations,
62
+ migrations,
63
+ }
27
64
}
28
65
29
66
fn new_from_table_iteration < T > ( iterator : & T ) -> Self
@@ -32,13 +69,35 @@ impl IteratorOutput {
32
69
{
33
70
let edges = iterator. edges ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
34
71
let nodes = iterator. nodes ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
35
- Self { edges, nodes }
72
+ let sites = iterator. sites ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
73
+ let mutations = iterator. mutations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
74
+ let populations = iterator. populations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
75
+ let migrations = iterator. migrations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
76
+ Self {
77
+ edges,
78
+ nodes,
79
+ sites,
80
+ mutations,
81
+ populations,
82
+ migrations,
83
+ }
36
84
}
37
85
38
86
fn new_from_dyn ( dynamic : & dyn tskit:: ObjectSafeTableIteration ) -> Self {
39
87
let edges = dynamic. edges ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
40
88
let nodes = dynamic. nodes ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
41
- Self { edges, nodes }
89
+ let sites = dynamic. sites ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
90
+ let mutations = dynamic. mutations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
91
+ let populations = dynamic. populations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
92
+ let migrations = dynamic. migrations ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
93
+ Self {
94
+ edges,
95
+ nodes,
96
+ sites,
97
+ mutations,
98
+ populations,
99
+ migrations,
100
+ }
42
101
}
43
102
}
44
103
@@ -89,7 +148,9 @@ fn test_traits_with_table_collection() {
89
148
#[ test]
90
149
fn test_traits_with_tree_sequence ( ) {
91
150
let mut tables = make_tables ( ) ;
92
- tables. full_sort ( tskit:: TableSortOptions :: default ( ) ) . unwrap ( ) ;
151
+ tables
152
+ . full_sort ( tskit:: TableSortOptions :: default ( ) )
153
+ . unwrap ( ) ;
93
154
tables. build_index ( ) . unwrap ( ) ;
94
155
let treeseq = tskit:: TreeSequence :: try_from ( tables) . unwrap ( ) ;
95
156
validate_output_from_treeseq ( treeseq)
0 commit comments