Skip to content
Browse files

sapply(DataFrame, FUN) doesn't work anymore(?)

I thought I had fixed this before.
  • Loading branch information...
1 parent 3b5b6f0 commit eea8f04dea9c8580eb4bd7084ddfa00d218b4d9e @lianos committed Mar 30, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 R/pkg/R/sam.R
View
15 R/pkg/R/sam.R
@@ -106,10 +106,17 @@ toSamTable <- function(x, is.paired=FALSE, tag.prefix="tag.") {
##' @param .use.c Use C code for combining tags for uber quickness.
combineIntoSamTagsVector <- function(x, tag.prefix="tag.", sep="\t", .use.c=TRUE) {
## Ensure that all items in data.frame/list container are the same length
- lengths <- unique(sapply(x, length))
- if (length(lengths) != 1L) {
- stop("The elements in `x` aren't uniform length")
+ if (is.list(x)) {
+ lengths <- unique(sapply(x, length))
+ if (length(lengths) != 1L) {
+ stop("The elements in `x` aren't uniform length")
+ }
+ } else {
+ if (!inherits(x, 'DataFrame') && !inherits(x, "data.frame")) {
+ stop("Expected data.frame-like object for `x`")
+ }
}
+
tag.cols <- grep(tag.prefix, names(x), fixed=TRUE)
if (length(tag.cols) == 0L) {
return(NULL)
@@ -259,7 +266,7 @@ function(x) {
if (ext != 'sam') {
stop("seqinfo,character is only defined for sam or bam files")
}
-
+
lines <- readLines(x, n=1000)
take <- grep("@SQ", lines)
## @SQ SN:chr1 LN:247249719

0 comments on commit eea8f04

Please sign in to comment.
Something went wrong with that request. Please try again.