Skip to content

Commit 523bd7e

Browse files
committed
Importing and linking against RcppTskit
1 parent 03cc840 commit 523bd7e

16 files changed

Lines changed: 292 additions & 4 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ src/*.gcno
2626
src/**/*.gcno
2727
src/*.o
2828
src/*.so
29+
src/Makevars
30+
src/Makevars.win
2931
vignettes/*.html
3032
vignettes/*.pdf

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ URL: https://github.com/gaynorr/AlphaSimR,
4040
https://www.edx.org/learn/animal-breeding/the-university-of-edinburgh-breeding-programme-modelling-with-alphasimr
4141
Encoding: UTF-8
4242
Depends: R (>= 4.0.0)
43-
Imports: Rcpp (>= 0.12.7), Rdpack, methods, R6
43+
Imports: Rcpp (>= 0.12.7), Rdpack, methods, R6, RcppTskit (>= 0.3.0)
4444
RdMacros: Rdpack
45-
LinkingTo: Rcpp, RcppArmadillo (>= 0.7.500.0.0), BH, dqrng (>= 0.4.1)
45+
LinkingTo: Rcpp, RcppArmadillo (>= 0.7.500.0.0), BH, dqrng (>= 0.4.1), RcppTskit
46+
RoxygenNote: 7.3.3
4647
Suggests: knitr, rmarkdown, testthat
4748
VignetteBuilder: knitr
4849
NeedsCompilation: true

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export(randCross)
8585
export(randCross2)
8686
export(reduceGenome)
8787
export(resetPop)
88+
export(rtsk_table_collection_summary2)
89+
export(rtsk_treeseq_get_num_individuals2)
8890
export(runMacs)
8991
export(runMacs2)
9092
export(sampleHaplo)
@@ -141,6 +143,7 @@ exportClasses(TraitAE)
141143
exportClasses(TraitAEG)
142144
exportClasses(TraitAG)
143145
import(Rcpp)
146+
import(RcppTskit)
144147
importFrom(R6,R6Class)
145148
importFrom(Rdpack,reprompt)
146149
importFrom(methods,.hasSlot)

R/AlphaSimR.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#' @useDynLib AlphaSimR, .registration = TRUE
44
#' @import Rcpp
5+
#' @import RcppTskit
56
#' @importFrom methods new validObject is .hasSlot slot
67
#' @importFrom methods show classLabel
78
#' @importFrom stats aggregate var cov2cor lm coef model.matrix

R/RcppExports.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,30 @@ MaCS <- function(args, maxSites, inbred, ploidy, nThreads, seed) {
399399
.Call(`_AlphaSimR_MaCS`, args, maxSites, inbred, ploidy, nThreads, seed)
400400
}
401401

402+
#' @title Summarise `tskit` table collection
403+
#' @param tc an external pointer to a \code{tsk_table_collection_t} object.
404+
#' @return A list.
405+
#' @examples
406+
#' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
407+
#' tc <- RcppTskit:::tc_load(ts_file)
408+
#' RcppTskit:::rtsk_table_collection_summary(tc$xptr)
409+
#' rtsk_table_collection_summary2(tc$xptr)
410+
#' @export
411+
rtsk_table_collection_summary2 <- function(tc) {
412+
.Call(`_AlphaSimR_rtsk_table_collection_summary2`, tc)
413+
}
414+
415+
#' @title Get number of individuals in tree sequence
416+
#' @param ts an external pointer to a \code{tsk_treeseq_t} object.
417+
#' @return integer number of individuals.
418+
#' @examples
419+
#' ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
420+
#' ts <- RcppTskit::ts_load(ts_file)
421+
#' ts$num_individuals()
422+
#' RcppTskit:::rtsk_treeseq_get_num_individuals(ts$xptr)
423+
#' rtsk_treeseq_get_num_individuals2(ts$xptr)
424+
#' @export
425+
rtsk_treeseq_get_num_individuals2 <- function(ts) {
426+
.Call(`_AlphaSimR_rtsk_treeseq_get_num_individuals2`, ts)
427+
}
428+

cleanup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
# Removing Makevars autogenerated via configure from src/Makevars.in
4+
rm -f src/Makevars
5+
6+
# Removing compilation files
7+
rm -f src/*.o src/*.so

cleanup.win

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
# Removing Makevars autogenerated via configure from src/Makevars.win.in
4+
rm -f src/Makevars.win
5+
6+
# Removing compilation files
7+
rm -f src/*.dll
8+
# TODO: Add other files to be removed here on Windows platform

configure

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
"${R_HOME}/bin/Rscript" tools/configure.R

configure.win

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
"${R_HOME}/bin${R_ARCH_BIN}/Rscript" tools/configure.R

man/rtsk_table_collection_summary2.Rd

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

0 commit comments

Comments
 (0)