Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion R/VcfStack-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ readVcfStack <- function(x, i, j=colnames(x), param=ScanVcfParam())
gr <- GRanges()
} else { # use param
gr <- GRanges(vcfWhich(param))
i = intersect(names(files(x)), as.character(seqnames(gr)))
if (length(gr)) {
i = intersect(names(files(x)), as.character(seqnames(gr)))
} else {
## param provided but no which= specified: read all files
i = names(files(x))
}
}
x = x[i]

Expand Down
8 changes: 8 additions & 0 deletions inst/unitTests/test_VcfStack-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ test_VcfStack_readVcfStack <- function(){
Rstack = RangedVcfStack(stack, gr)
temp7 = readVcfStack(Rstack)
checkTrue(all(dim(temp7) == dim(temp5)))

# test param=ScanVcfParam() with no which= reads all variants (#50)
# Previously returned 0-row VCF because empty which= intersected to empty i
tempParam = readVcfStack(Rstack, param=ScanVcfParam())
checkTrue(all(dim(tempParam) == dim(temp7)))

tempParamStack = readVcfStack(stack, param=ScanVcfParam())
checkTrue(all(dim(tempParamStack) == dim(temp)))
}

test_VcfStack_vcfFields <- function(){
Expand Down