-
Notifications
You must be signed in to change notification settings - Fork 54
/
test_var_window.R
43 lines (29 loc) · 1.28 KB
/
test_var_window.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
library(vcfR)
context("var_window functions")
data(vcfR_example)
# Global code.
#pinf_mt <- create.chromR('pinf_mt', seq=pinf_dna, vcf=pinf_vcf, ann=pinf_gff, verbose=FALSE)
pinf <- create.chromR('pinf', seq=dna, vcf=vcf, ann=gff, verbose=FALSE)
win1 <- .Call('vcfR_window_init', PACKAGE = 'vcfR', window_size=1e3, max_bp=length(dna))
win2 <- .Call('vcfR_windowize_fasta', PACKAGE = 'vcfR', wins=win1, seq=as.character(dna)[1,])
win3 <- .Call('vcfR_windowize_variants', PACKAGE = 'vcfR', windows=win2, variants=pinf@var.info[c('POS','mask')])
win4 <- .Call('vcfR_windowize_annotations', PACKAGE = 'vcfR', wins=win3,
ann_starts=as.numeric(as.character(gff[,4])),
ann_ends=as.numeric(as.character(gff[,5])),
chrom_length=length(dna))
test_that("vcfR_window_init works", {
expect_equal(ncol(win1), 4)
expect_equal(nrow(win1), ceiling(length(dna)/1e3))
})
test_that("vcfR_windowize_fasta works ", {
expect_equal(ncol(win2), 10)
expect_equal(nrow(win2), ceiling(length(dna)/1e3))
})
test_that("vcfR_windowize_variants works ", {
expect_equal(ncol(win3), 11)
expect_equal(nrow(win2), ceiling(length(dna)/1e3))
})
test_that("vcfR_windowize_annotations works ", {
expect_equal(ncol(win4), 12)
expect_equal(nrow(win2), ceiling(length(dna)/1e3))
})