Skip to content

Commit

Permalink
provenance feature
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Oct 10, 2023
1 parent d1fc02c commit 9e9a8bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/sys/table_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use super::bindings::tsk_migration_table_t;
use super::bindings::tsk_mutation_table_t;
use super::bindings::tsk_node_table_t;
use super::bindings::tsk_population_table_t;
#[cfg(feature = "provenance")]
use super::bindings::tsk_provenance_table_t;
use super::bindings::tsk_site_table_t;
use super::bindings::tsk_table_collection_free;
use super::bindings::tsk_table_collection_init;
Expand Down Expand Up @@ -85,6 +87,12 @@ impl TableCollection {
unsafe { &mut (*self.as_mut_ptr()).populations }
}

#[cfg(feature = "provenance")]
pub fn provenances_mut(&mut self) -> &mut tsk_provenance_table_t {
// SAFETY: self pointer is not null
unsafe { &mut (*self.as_mut_ptr()).provenances }
}

pub fn sites_mut(&mut self) -> &mut tsk_site_table_t {
// SAFETY: self pointer is not null
unsafe { &mut (*self.as_mut_ptr()).sites }
Expand Down
2 changes: 1 addition & 1 deletion src/table_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ impl TableCollection {
// to create with null pointers.
let rv = unsafe {
ll_bindings::tsk_provenance_table_set_columns(
&mut self.inner.provenances,
self.inner.provenances_mut(),
(*provenances.as_ptr()).num_rows,
(*provenances.as_ptr()).timestamp,
(*provenances.as_ptr()).timestamp_offset,
Expand Down
2 changes: 1 addition & 1 deletion src/table_views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl TableViews {
migrations: crate::MigrationTable::new_from_table(tables.migrations_mut())?,
#[cfg(feature = "provenance")]
provenances: crate::provenance::ProvenanceTable::new_from_table(
&mut tables.as_mut().provenances,
tables.provenances_mut(),
)?,
})
}
Expand Down

0 comments on commit 9e9a8bb

Please sign in to comment.