diff --git a/R/class-Bin.R b/R/class-Bin.R index 82c65d1..a2302e8 100644 --- a/R/class-Bin.R +++ b/R/class-Bin.R @@ -97,14 +97,16 @@ check_bin_range_list <- function(object) { errors <- c(errors, msg) } - # no overlapping ranges - sortOrder <- order(binStarts) - binStarts <- binStarts[sortOrder] - binEnds <- binEnds[sortOrder] - binValues <- binValues[sortOrder] - if (any(binStarts[2:length(binStarts)] < binEnds[1:(length(binEnds)-1)], na.rm=TRUE)) { - msg <- "Some provided bins overlap." - errors <- c(errors, msg) + # no overlapping ranges (only useful when multiple bins in the BinList) + if (length(binStarts) > 1) { + sortOrder <- order(binStarts) + binStarts <- binStarts[sortOrder] + binEnds <- binEnds[sortOrder] + binValues <- binValues[sortOrder] + if (any(binStarts[2:length(binStarts)] < binEnds[1:(length(binEnds)-1)], na.rm=TRUE)) { + msg <- "Some provided bins overlap." + errors <- c(errors, msg) + } } } diff --git a/man/as.Date-Bin-method.Rd b/man/as.Date-Bin-method.Rd deleted file mode 100644 index 6a064aa..0000000 --- a/man/as.Date-Bin-method.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/methods-Bin.R -\name{as.Date,Bin-method} -\alias{as.Date,Bin-method} -\title{Convert a Bin's start and end values to dates} -\usage{ -\S4method{as.Date}{Bin}(x) -} -\arguments{ -\item{x}{Bin} -} -\value{ -Bin -} -\description{ -Given a Bin object with slots binStart and binEnd, convert -the binStart and binEnd to dates -} diff --git a/man/as.Date-BinList-method.Rd b/man/as.Date-BinList-method.Rd deleted file mode 100644 index 0d5138c..0000000 --- a/man/as.Date-BinList-method.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/methods-Bin.R -\name{as.Date,BinList-method} -\alias{as.Date,BinList-method} -\title{Convert BinList bin starts and ends to dates} -\usage{ -\S4method{as.Date}{BinList}(x) -} -\arguments{ -\item{x}{BinList} -} -\value{ -BinList -} -\description{ -Given a BinList object, convert all binStarts and binEnds to dates and return the BinList. -} diff --git a/man/getVariableSpec.Rd b/man/getVariableSpec.Rd index e607e12..a7978f6 100644 --- a/man/getVariableSpec.Rd +++ b/man/getVariableSpec.Rd @@ -4,7 +4,7 @@ \alias{getVariableSpec} \title{get a VariableSpec} \usage{ -getVariableSpec(object) +getVariableSpec(object, ...) } \arguments{ \item{object}{An object containing a veupathUtils::VariableSpec} diff --git a/tests/testthat/test-class-Bin.R b/tests/testthat/test-class-Bin.R index f2b3408..74393c6 100644 --- a/tests/testthat/test-class-Bin.R +++ b/tests/testthat/test-class-Bin.R @@ -46,4 +46,12 @@ test_that("BinList validation works", { # none have start or ends or value and thats ok expect_equal(length(BinList(S4Vectors::SimpleList(c(bin6, bin7)))), 2) +}) + +test_that("BinList can handle a list of one", { + + bin1 <- Bin(binStart=1, binEnd=2, binLabel='1-2') + lonelyBinList <- BinList(S4Vectors::SimpleList(c(bin1))) + expect_equal(length(lonelyBinList), 1) + }) \ No newline at end of file