@@ -1365,14 +1365,16 @@ void rtsk_table_collection_drop_index(SEXP tc, int options = 0) {
13651365 // # nocov end
13661366}
13671367
1368- // TODO: model this after
1369- // https://github.com/tskit-dev/tskit/blob/2f26dc6f0d033cdf7d6fb1adfbab96468dde8831/python/_tskitmodule.c#L4526
13701368// PUBLIC, wrapper for tsk_table_collection_sort
13711369// @title Sort a table collection
13721370// @param tc an external pointer to table collection as a
13731371// \code{tsk_table_collection_t} object.
13741372// @param edge_start integer scalar edge-table start row index (0-based) used in
13751373// sorting bookmark.
1374+ // @param site_start integer scalar site-table start row index (0-based) used in
1375+ // sorting bookmark.
1376+ // @param mutation_start integer scalar mutation-table start row index (0-based)
1377+ // used in sorting bookmark.
13761378// @param options passed to \code{tskit C}; this wrapper supports
13771379// \code{TSK_NO_CHECK_INTEGRITY}.
13781380// @details This function calls
@@ -1383,19 +1385,36 @@ void rtsk_table_collection_drop_index(SEXP tc, int options = 0) {
13831385// tc_xptr <- RcppTskit:::rtsk_table_collection_load(ts_file)
13841386// RcppTskit:::rtsk_table_collection_sort(tc_xptr)
13851387// [[Rcpp::export]]
1386- void rtsk_table_collection_sort (SEXP tc, int edge_start = 0 , int options = 0 ) {
1388+ void rtsk_table_collection_sort (SEXP tc, int edge_start = 0 , int site_start = 0 ,
1389+ int mutation_start = 0 , int options = 0 ) {
13871390 if (Rcpp::IntegerVector::is_na (edge_start)) {
13881391 Rcpp::stop (
13891392 " edge_start must not be NA_integer_ in rtsk_table_collection_sort" );
13901393 }
13911394 if (edge_start < 0 ) {
13921395 Rcpp::stop (" edge_start must be >= 0 in rtsk_table_collection_sort" );
13931396 }
1397+ if (Rcpp::IntegerVector::is_na (site_start)) {
1398+ Rcpp::stop (
1399+ " site_start must not be NA_integer_ in rtsk_table_collection_sort" );
1400+ }
1401+ if (site_start < 0 ) {
1402+ Rcpp::stop (" site_start must be >= 0 in rtsk_table_collection_sort" );
1403+ }
1404+ if (Rcpp::IntegerVector::is_na (mutation_start)) {
1405+ Rcpp::stop (
1406+ " mutation_start must not be NA_integer_ in rtsk_table_collection_sort" );
1407+ }
1408+ if (mutation_start < 0 ) {
1409+ Rcpp::stop (" mutation_start must be >= 0 in rtsk_table_collection_sort" );
1410+ }
13941411 const tsk_flags_t flags = validate_supported_options (
13951412 options, kTableSortSupportedFlags , " rtsk_table_collection_sort" );
13961413 rtsk_table_collection_t tc_xptr (tc);
13971414 tsk_bookmark_t start = {0 };
13981415 start.edges = static_cast <tsk_size_t >(edge_start);
1416+ start.sites = static_cast <tsk_size_t >(site_start);
1417+ start.mutations = static_cast <tsk_size_t >(mutation_start);
13991418 int ret = tsk_table_collection_sort (tc_xptr, &start, flags);
14001419 if (ret != 0 ) {
14011420 Rcpp::stop (tsk_strerror (ret));
0 commit comments