@@ -176,7 +176,7 @@ impl TableCollection {
176
176
self . add_edge_with_metadata ( left, right, parent, child, None )
177
177
}
178
178
179
- /// Add a row with metadata to the edge table
179
+ /// Add a row with optional metadata to the edge table
180
180
pub fn add_edge_with_metadata < P : Into < NodeId > , C : Into < NodeId > > (
181
181
& mut self ,
182
182
left : f64 ,
@@ -201,6 +201,18 @@ impl TableCollection {
201
201
handle_tsk_return_value ! ( rv, EdgeId :: from( rv) )
202
202
}
203
203
204
+ /// Add a row with metadata to the edge table
205
+ pub fn add_edge_with_some_metadata < P : Into < NodeId > , C : Into < NodeId > > (
206
+ & mut self ,
207
+ left : f64 ,
208
+ right : f64 ,
209
+ parent : P ,
210
+ child : C ,
211
+ metadata : & dyn MetadataRoundtrip ,
212
+ ) -> Result < EdgeId , TskitError > {
213
+ self . add_edge_with_metadata ( left, right, parent, child, Some ( metadata) )
214
+ }
215
+
204
216
/// Add a row to the individual table
205
217
pub fn add_individual < I : Into < IndividualId > > (
206
218
& mut self ,
@@ -235,6 +247,17 @@ impl TableCollection {
235
247
handle_tsk_return_value ! ( rv, IndividualId :: from( rv) )
236
248
}
237
249
250
+ /// Add a row with metadata to the individual table
251
+ pub fn add_individual_with_some_metadata < I : Into < IndividualId > > (
252
+ & mut self ,
253
+ flags : tsk_flags_t ,
254
+ location : & [ f64 ] ,
255
+ parents : & [ I ] ,
256
+ metadata : & dyn MetadataRoundtrip ,
257
+ ) -> Result < IndividualId , TskitError > {
258
+ self . add_individual_with_metadata ( flags, location, parents, Some ( metadata) )
259
+ }
260
+
238
261
/// Add a row to the migration table
239
262
///
240
263
/// # Warnings
@@ -251,7 +274,7 @@ impl TableCollection {
251
274
self . add_migration_with_metadata ( span, node, source_dest, time, None )
252
275
}
253
276
254
- /// Add a row with metadata to the migration table
277
+ /// Add a row with optional metadata to the migration table
255
278
///
256
279
/// # Warnings
257
280
///
@@ -286,6 +309,27 @@ impl TableCollection {
286
309
handle_tsk_return_value ! ( rv)
287
310
}
288
311
312
+ /// Add a row with metadata to the migration table
313
+ ///
314
+ /// # Warnings
315
+ ///
316
+ /// Migration tables are not currently supported
317
+ /// by tree sequence simplification.
318
+ pub fn add_migration_with_some_metadata <
319
+ N : Into < NodeId > ,
320
+ SOURCE : Into < PopulationId > ,
321
+ DEST : Into < PopulationId > ,
322
+ > (
323
+ & mut self ,
324
+ span : ( f64 , f64 ) ,
325
+ node : N ,
326
+ source_dest : ( SOURCE , DEST ) ,
327
+ time : f64 ,
328
+ metadata : & dyn MetadataRoundtrip ,
329
+ ) -> TskReturnValue {
330
+ self . add_migration_with_metadata ( span, node, source_dest, time, Some ( metadata) )
331
+ }
332
+
289
333
/// Add a row to the node table
290
334
pub fn add_node < I : Into < IndividualId > , POP : Into < PopulationId > > (
291
335
& mut self ,
@@ -297,7 +341,7 @@ impl TableCollection {
297
341
self . add_node_with_metadata ( flags, time, population, individual, None )
298
342
}
299
343
300
- /// Add a row with metadata to the node table
344
+ /// Add a row with optional metadata to the node table
301
345
pub fn add_node_with_metadata < I : Into < IndividualId > , POP : Into < PopulationId > > (
302
346
& mut self ,
303
347
flags : ll_bindings:: tsk_flags_t ,
@@ -322,6 +366,18 @@ impl TableCollection {
322
366
handle_tsk_return_value ! ( rv, rv. into( ) )
323
367
}
324
368
369
+ /// Add a row with metadata to the node table
370
+ pub fn add_node_with_some_metadata < I : Into < IndividualId > , POP : Into < PopulationId > > (
371
+ & mut self ,
372
+ flags : ll_bindings:: tsk_flags_t ,
373
+ time : f64 ,
374
+ population : POP ,
375
+ individual : I ,
376
+ metadata : & dyn MetadataRoundtrip ,
377
+ ) -> Result < NodeId , TskitError > {
378
+ self . add_node_with_metadata ( flags, time, population, individual, Some ( metadata) )
379
+ }
380
+
325
381
/// Add a row to the site table
326
382
pub fn add_site (
327
383
& mut self ,
@@ -331,7 +387,7 @@ impl TableCollection {
331
387
self . add_site_with_metadata ( position, ancestral_state, None )
332
388
}
333
389
334
- /// Add a row with metadata to the site table
390
+ /// Add a row with optional metadata to the site table
335
391
pub fn add_site_with_metadata (
336
392
& mut self ,
337
393
position : f64 ,
@@ -355,6 +411,16 @@ impl TableCollection {
355
411
handle_tsk_return_value ! ( rv, SiteId :: from( rv) )
356
412
}
357
413
414
+ /// Add a row with metadata to the site table
415
+ pub fn add_site_with_some_metadata (
416
+ & mut self ,
417
+ position : f64 ,
418
+ ancestral_state : Option < & [ u8 ] > ,
419
+ metadata : & dyn MetadataRoundtrip ,
420
+ ) -> Result < SiteId , TskitError > {
421
+ self . add_site_with_metadata ( position, ancestral_state, Some ( metadata) )
422
+ }
423
+
358
424
/// Add a row to the mutation table.
359
425
pub fn add_mutation < N : Into < NodeId > , M : Into < MutationId > , S : Into < SiteId > > (
360
426
& mut self ,
@@ -367,7 +433,7 @@ impl TableCollection {
367
433
self . add_mutation_with_metadata ( site, node, parent, time, derived_state, None )
368
434
}
369
435
370
- /// Add a row with metadata to the mutation table.
436
+ /// Add a row with optional metadata to the mutation table.
371
437
pub fn add_mutation_with_metadata < N : Into < NodeId > , M : Into < MutationId > , S : Into < SiteId > > (
372
438
& mut self ,
373
439
site : S ,
@@ -397,12 +463,29 @@ impl TableCollection {
397
463
handle_tsk_return_value ! ( rv, MutationId :: from( rv) )
398
464
}
399
465
466
+ /// Add a row with metadata to the mutation table.
467
+ pub fn add_mutation_with_some_metadata <
468
+ N : Into < NodeId > ,
469
+ M : Into < MutationId > ,
470
+ S : Into < SiteId > ,
471
+ > (
472
+ & mut self ,
473
+ site : S ,
474
+ node : N ,
475
+ parent : M ,
476
+ time : f64 ,
477
+ derived_state : Option < & [ u8 ] > ,
478
+ metadata : & dyn MetadataRoundtrip ,
479
+ ) -> Result < MutationId , TskitError > {
480
+ self . add_mutation_with_metadata ( site, node, parent, time, derived_state, Some ( metadata) )
481
+ }
482
+
400
483
/// Add a row to the population_table
401
484
pub fn add_population ( & mut self ) -> Result < PopulationId , TskitError > {
402
485
self . add_population_with_metadata ( None )
403
486
}
404
487
405
- /// Add a row with metadata to the population_table
488
+ /// Add a row with optional metadata to the population_table
406
489
pub fn add_population_with_metadata (
407
490
& mut self ,
408
491
metadata : Option < & dyn MetadataRoundtrip > ,
@@ -419,6 +502,14 @@ impl TableCollection {
419
502
handle_tsk_return_value ! ( rv, PopulationId :: from( rv) )
420
503
}
421
504
505
+ /// Add a row with metadata to the population_table
506
+ pub fn add_population_with_some_metadata (
507
+ & mut self ,
508
+ metadata : & dyn MetadataRoundtrip ,
509
+ ) -> Result < PopulationId , TskitError > {
510
+ self . add_population_with_metadata ( Some ( metadata) )
511
+ }
512
+
422
513
/// Build the "input" and "output"
423
514
/// indexes for the edge table.
424
515
///
0 commit comments