@@ -13,45 +13,39 @@ struct IndividualMetadata {
1313}
1414
1515fn main ( ) {
16- let ts = make_treeseq ( ) ;
16+ let ts = make_treeseq ( ) . unwrap ( ) ;
1717 ts. dump ( "with_json_metadata.trees" , 0 ) . unwrap ( ) ;
1818}
1919
20- fn make_tables ( ) -> tskit:: TableCollection {
21- let mut tables = tskit:: TableCollection :: new ( 100.0 ) . unwrap ( ) ;
22- let pop0 = tables. add_population ( ) . unwrap ( ) ;
23- let ind0 = tables
24- . add_individual_with_metadata (
25- 0 ,
26- None ,
27- None ,
28- & IndividualMetadata {
29- name : "Jerome" . to_string ( ) ,
30- phenotypes : vec ! [ 0 , 1 , 2 , 0 ] ,
31- } ,
32- )
33- . unwrap ( ) ;
34- let node0 = tables
35- . add_node ( tskit:: NodeFlags :: new_sample ( ) , 0.0 , pop0, ind0)
36- . unwrap ( ) ;
37- let site0 = tables. add_site ( 50.0 , Some ( "A" . as_bytes ( ) ) ) . unwrap ( ) ;
38- let _ = tables
39- . add_mutation_with_metadata (
40- site0,
41- node0,
42- tskit:: MutationId :: NULL ,
43- 1.0 ,
44- Some ( "G" . as_bytes ( ) ) ,
45- & MutationMetadata {
46- effect_size : -1e-3 ,
47- dominance : 0.1 ,
48- } ,
49- )
50- . unwrap ( ) ;
51- tables. build_index ( ) . unwrap ( ) ;
52- tables
20+ fn make_tables ( ) -> anyhow:: Result < tskit:: TableCollection > {
21+ let mut tables = tskit:: TableCollection :: new ( 100.0 ) ?;
22+ let pop0 = tables. add_population ( ) ?;
23+ let ind0 = tables. add_individual_with_metadata (
24+ 0 ,
25+ None ,
26+ None ,
27+ & IndividualMetadata {
28+ name : "Jerome" . to_string ( ) ,
29+ phenotypes : vec ! [ 0 , 1 , 2 , 0 ] ,
30+ } ,
31+ ) ?;
32+ let node0 = tables. add_node ( tskit:: NodeFlags :: new_sample ( ) , 0.0 , pop0, ind0) ?;
33+ let site0 = tables. add_site ( 50.0 , Some ( "A" . as_bytes ( ) ) ) ?;
34+ let _ = tables. add_mutation_with_metadata (
35+ site0,
36+ node0,
37+ tskit:: MutationId :: NULL ,
38+ 1.0 ,
39+ Some ( "G" . as_bytes ( ) ) ,
40+ & MutationMetadata {
41+ effect_size : -1e-3 ,
42+ dominance : 0.1 ,
43+ } ,
44+ ) ?;
45+ tables. build_index ( ) ?;
46+ Ok ( tables)
5347}
5448
55- fn make_treeseq ( ) -> tskit:: TreeSequence {
56- make_tables ( ) . tree_sequence ( 0 ) . unwrap ( )
49+ fn make_treeseq ( ) -> anyhow :: Result < tskit:: TreeSequence > {
50+ Ok ( make_tables ( ) ? . tree_sequence ( 0 ) ? )
5751}
0 commit comments