tests/testthat/test_standardize_sites.R

context("Standardize intsites")

# Generated by gintools:::generate_test_granges()
input_gr <- GenomicRanges::GRanges(
  seqnames = S4Vectors::Rle(factor("chr1"), 100),
  ranges = IRanges::IRanges(
    start = c(
      598L, 598L, 599L, 599L, 599L, 599L, 599L, 599L, 600L, 600L, 600L, 600L, 
      600L, 600L, 600L, 600L, 601L, 601L, 601L, 602L, 657L, 657L, 658L, 658L, 
      658L, 659L, 659L, 659L, 659L, 659L, 659L, 659L, 660L, 660L, 660L, 660L, 
      661L, 661L, 661L, 661L, 743L, 743L, 743L, 744L, 744L, 744L, 744L, 745L, 
      745L, 745L, 745L, 745L, 746L, 746L, 746L, 746L, 746L, 746L, 747L, 747L, 
      780L, 781L, 781L, 781L, 781L, 781L, 781L, 782L, 782L, 782L, 782L, 782L, 
      783L, 783L, 783L, 783L, 783L, 783L, 784L, 784L, 834L, 835L, 835L, 835L, 
      835L, 835L, 835L, 836L, 836L, 837L, 837L, 837L, 837L, 837L, 837L, 837L, 
      837L, 837L, 838L, 838L
    ),
    width = c(
      89L, 99L, 32L, 32L, 41L, 58L, 60L, 95L, 33L, 34L, 39L, 47L, 65L, 72L, 76L,
      77L, 55L, 64L, 85L, 45L, 55L, 99L, 32L, 33L, 58L, 45L, 47L, 72L, 76L, 77L, 
      85L, 95L, 39L, 60L, 65L, 89L, 32L, 34L, 41L, 64L, 41L, 58L, 99L, 32L, 55L, 
      72L, 95L, 32L, 34L, 39L, 64L, 76L, 45L, 60L, 65L, 77L, 85L, 89L, 33L, 47L, 
      89L, 32L, 34L, 41L, 55L, 60L, 72L, 32L, 33L, 64L, 85L, 99L, 45L, 47L, 58L, 
      65L, 76L, 77L, 39L, 95L, 45L, 47L, 55L, 60L, 64L, 76L, 89L, 58L, 72L, 32L,
      34L, 39L, 41L, 65L, 77L, 85L, 95L, 99L, 32L, 33L
    )
  ),
  strand = S4Vectors::Rle(factor("+", levels = c("+", "-", "*")), lengths = 100)
)


test_that("Standardized start positions are expected", {
  
  set.seed(1)
  res <- standardize_sites(input_gr)
  observed_starts <- GenomicRanges::start(res)
  expected_starts <- rep(c(600, 659, 746, 781, 837), each = 20)
  expect_equal(observed_starts, expected_starts)
  
})
cnobles/gintools documentation built on Aug. 22, 2019, 10:36 a.m.