Skip to content

Commit e1d7f44

Browse files
committed
feat: TableCollection::compute_mutation_parents
1 parent 0787f9f commit e1d7f44

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/sys/flags.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use crate::sys::bindings as ll_bindings;
77
use crate::RawFlags;
88
use bitflags::bitflags;
99

10+
use super::bindings::tsk_flags_t;
11+
1012
macro_rules! impl_from_for_flag_types {
1113
($flagstype: ty) => {
1214
impl From<$crate::RawFlags> for $flagstype {
@@ -746,6 +748,15 @@ impl From<RawFlags> for IndividualFlags {
746748
}
747749
}
748750

751+
#[derive(Copy, Clone, Default, Debug)]
752+
pub struct MutationParentsFlags(tsk_flags_t);
753+
754+
impl From<MutationParentsFlags> for tsk_flags_t {
755+
fn from(value: MutationParentsFlags) -> Self {
756+
value.0
757+
}
758+
}
759+
749760
#[cfg(test)]
750761
mod tests {
751762
use super::*;

src/sys/table_collection.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use super::bindings;
2+
use super::flags::MutationParentsFlags;
13
use super::bindings::tsk_edge_table_t;
24
use super::bindings::tsk_individual_table_t;
35
use super::bindings::tsk_migration_table_t;
@@ -119,6 +121,14 @@ impl TableCollection {
119121
pub fn into_raw(self) -> *mut tsk_table_collection_t {
120122
self.0.into_raw()
121123
}
124+
125+
pub fn compute_mutation_parents(&mut self, options: MutationParentsFlags) -> Result<(), TskitError> {
126+
// SAFETY: as_mut_ptr is safe because the internal pointer cannot be null
127+
let code = unsafe {
128+
bindings::tsk_table_collection_compute_mutation_parents(self.as_mut_ptr(), options.into())
129+
};
130+
handle_tsk_return_value!(code, ())
131+
}
122132
}
123133

124134
#[test]

src/table_collection.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,4 +1564,9 @@ impl TableCollection {
15641564
Ok(Some(tables))
15651565
}
15661566
}
1567+
1568+
/// Compute the parents of each mutation.
1569+
pub fn compute_mutation_parents(&mut self, options: crate::MutationParentsFlags) -> Result<(), TskitError> {
1570+
self.inner.compute_mutation_parents(options)
1571+
}
15671572
}

0 commit comments

Comments
 (0)