Skip to content

Commit 0b76639

Browse files
committed
Use new RcppTskit names
1 parent 9402f8b commit 0b76639

6 files changed

Lines changed: 94 additions & 35 deletions

File tree

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export(randCross)
7979
export(randCross2)
8080
export(reduceGenome)
8181
export(resetPop)
82+
export(rtsk_table_collection_summary2)
83+
export(rtsk_treeseq_get_num_individuals2)
8284
export(runMacs)
8385
export(runMacs2)
8486
export(sampleHaplo)
@@ -105,7 +107,6 @@ export(solveRRBLUP_EM)
105107
export(solveRRBLUP_EM2)
106108
export(solveRRBLUP_EM3)
107109
export(solveUVM)
108-
export(tc_xptr_summary2)
109110
export(usefulness)
110111
export(varA)
111112
export(varAA)

R/RcppExports.R

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,25 @@ MaCS <- function(args, maxSites, inbred, ploidy, nThreads, seed) {
378378
#' @return A list.
379379
#' @examples
380380
#' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
381-
#' tc <- RcppTskit:::tc_xptr_load(ts_file)
382-
#' RcppTskit:::tc_xptr_summary(tc)
383-
#' AlphaSimR:::tc_xptr_summary2(tc) # a bit simpler at this stage ...
384-
#' tc <- RcppTskit::TableCollection$new(ts_file)
385-
#' RcppTskit:::tc_xptr_summary(tc$pointer)
386-
#' AlphaSimR:::tc_xptr_summary2(tc$pointer) # a bit simpler at this stage ...
381+
#' tc <- RcppTskit:::tc_load(ts_file)
382+
#' RcppTskit:::rtsk_table_collection_summary(tc$xptr)
383+
#' rtsk_table_collection_summary2(tc$xptr)
387384
#' @export
388-
tc_xptr_summary2 <- function(tc) {
389-
.Call(`_AlphaSimR_tc_xptr_summary2`, tc)
385+
rtsk_table_collection_summary2 <- function(tc) {
386+
.Call(`_AlphaSimR_rtsk_table_collection_summary2`, tc)
387+
}
388+
389+
#' @title Get number of individuals in tree sequence
390+
#' @param ts an external pointer to a \code{tsk_treeseq_t} object.
391+
#' @return integer number of individuals.
392+
#' @examples
393+
#' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
394+
#' ts <- RcppTskit::ts_load(ts_file)
395+
#' ts$num_individuals()
396+
#' RcppTskit:::rtsk_treeseq_get_num_individuals(ts$xptr)
397+
#' rtsk_treeseq_get_num_individuals2(ts$xptr)
398+
#' @export
399+
rtsk_treeseq_get_num_individuals2 <- function(ts) {
400+
.Call(`_AlphaSimR_rtsk_treeseq_get_num_individuals2`, ts)
390401
}
391402

Lines changed: 6 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rtsk_treeseq_get_num_individuals2.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RcppExports.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -860,14 +860,25 @@ BEGIN_RCPP
860860
return rcpp_result_gen;
861861
END_RCPP
862862
}
863-
// tc_xptr_summary2
864-
Rcpp::List tc_xptr_summary2(const SEXP tc);
865-
RcppExport SEXP _AlphaSimR_tc_xptr_summary2(SEXP tcSEXP) {
863+
// rtsk_table_collection_summary2
864+
Rcpp::List rtsk_table_collection_summary2(const SEXP tc);
865+
RcppExport SEXP _AlphaSimR_rtsk_table_collection_summary2(SEXP tcSEXP) {
866866
BEGIN_RCPP
867867
Rcpp::RObject rcpp_result_gen;
868868
Rcpp::RNGScope rcpp_rngScope_gen;
869869
Rcpp::traits::input_parameter< const SEXP >::type tc(tcSEXP);
870-
rcpp_result_gen = Rcpp::wrap(tc_xptr_summary2(tc));
870+
rcpp_result_gen = Rcpp::wrap(rtsk_table_collection_summary2(tc));
871+
return rcpp_result_gen;
872+
END_RCPP
873+
}
874+
// rtsk_treeseq_get_num_individuals2
875+
int rtsk_treeseq_get_num_individuals2(const SEXP ts);
876+
RcppExport SEXP _AlphaSimR_rtsk_treeseq_get_num_individuals2(SEXP tsSEXP) {
877+
BEGIN_RCPP
878+
Rcpp::RObject rcpp_result_gen;
879+
Rcpp::RNGScope rcpp_rngScope_gen;
880+
Rcpp::traits::input_parameter< const SEXP >::type ts(tsSEXP);
881+
rcpp_result_gen = Rcpp::wrap(rtsk_treeseq_get_num_individuals2(ts));
871882
return rcpp_result_gen;
872883
END_RCPP
873884
}
@@ -928,7 +939,8 @@ static const R_CallMethodDef CallEntries[] = {
928939
{"_AlphaSimR_getNumThreads", (DL_FUNC) &_AlphaSimR_getNumThreads, 0},
929940
{"_AlphaSimR_packHaplo", (DL_FUNC) &_AlphaSimR_packHaplo, 3},
930941
{"_AlphaSimR_MaCS", (DL_FUNC) &_AlphaSimR_MaCS, 6},
931-
{"_AlphaSimR_tc_xptr_summary2", (DL_FUNC) &_AlphaSimR_tc_xptr_summary2, 1},
942+
{"_AlphaSimR_rtsk_table_collection_summary2", (DL_FUNC) &_AlphaSimR_rtsk_table_collection_summary2, 1},
943+
{"_AlphaSimR_rtsk_treeseq_get_num_individuals2", (DL_FUNC) &_AlphaSimR_rtsk_treeseq_get_num_individuals2, 1},
932944
{NULL, NULL, 0}
933945
};
934946

src/ts.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@
1616
//' @return A list.
1717
//' @examples
1818
//' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
19-
//' tc <- RcppTskit:::tc_xptr_load(ts_file)
20-
//' RcppTskit:::tc_xptr_summary(tc)
21-
//' AlphaSimR:::tc_xptr_summary2(tc) # a bit simpler at this stage ...
22-
//' tc <- RcppTskit::TableCollection$new(ts_file)
23-
//' RcppTskit:::tc_xptr_summary(tc$pointer)
24-
//' AlphaSimR:::tc_xptr_summary2(tc$pointer) # a bit simpler at this stage ...
19+
//' tc <- RcppTskit:::tc_load(ts_file)
20+
//' RcppTskit:::rtsk_table_collection_summary(tc$xptr)
21+
//' rtsk_table_collection_summary2(tc$xptr)
2522
//' @export
2623
// [[Rcpp::export]]
27-
Rcpp::List tc_xptr_summary2(const SEXP tc) {
28-
RcppTskit_table_collection_xptr tc_xptr(tc);
24+
Rcpp::List rtsk_table_collection_summary2(const SEXP tc) {
25+
rtsk_table_collection_t tc_xptr(tc);
2926
const tsk_table_collection_t *tables = tc_xptr;
3027
return Rcpp::List::create(
3128
Rcpp::_["num_provenances"] = tables->provenances.num_rows,
@@ -37,8 +34,25 @@ Rcpp::List tc_xptr_summary2(const SEXP tc) {
3734
Rcpp::_["num_sites"] = tables->sites.num_rows,
3835
Rcpp::_["num_mutations"] = tables->mutations.num_rows,
3936
Rcpp::_["sequence_length"] = tables->sequence_length,
40-
Rcpp::_["has_reference_sequence"] = tc_xptr_has_reference_sequence(tc),
41-
Rcpp::_["time_units"] = tc_xptr_time_units(tc),
42-
Rcpp::_["file_uuid"] = tc_xptr_file_uuid(tc),
43-
Rcpp::_["has_index"] = tc_xptr_has_index(tc));
37+
Rcpp::_["has_reference_sequence"] =
38+
rtsk_table_collection_has_reference_sequence(tc),
39+
Rcpp::_["time_units"] = rtsk_table_collection_get_time_units(tc),
40+
Rcpp::_["file_uuid"] = rtsk_table_collection_get_file_uuid(tc),
41+
Rcpp::_["has_index"] = rtsk_table_collection_has_index(tc));
42+
}
43+
44+
//' @title Get number of individuals in tree sequence
45+
//' @param ts an external pointer to a \code{tsk_treeseq_t} object.
46+
//' @return integer number of individuals.
47+
//' @examples
48+
//' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
49+
//' ts <- RcppTskit::ts_load(ts_file)
50+
//' ts$num_individuals()
51+
//' RcppTskit:::rtsk_treeseq_get_num_individuals(ts$xptr)
52+
//' rtsk_treeseq_get_num_individuals2(ts$xptr)
53+
//' @export
54+
// [[Rcpp::export]]
55+
int rtsk_treeseq_get_num_individuals2(const SEXP ts) {
56+
rtsk_treeseq_t ts_xptr(ts);
57+
return static_cast<int>(tsk_treeseq_get_num_individuals(ts_xptr));
4458
}

0 commit comments

Comments
 (0)