Skip to content

Commit

Permalink
Changing rhdf5 h5write call to h5writeDataset based on some prior fai…
Browse files Browse the repository at this point in the history
…led runs -- might need to revisit this if in the new context we need to revert back to h5write .
  • Loading branch information
ryanchrist committed Sep 23, 2024
1 parent bd5eb3c commit 073ec63
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/IndividualSequenceIO_H5.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ WriteHaplotypes <- function(hdf5.file, haps,
write.loci.ids <- TRUE
}

# NOTE: this previously had to be removed to allow running on WashU cluster -- if error triggers here again LA and RC to discuss
if(length(find.package("rhdf5", quiet = TRUE)) == 0) {
stop("The WriteHaplotypes function requires the optional rhdf5 package to be installed (see Bioconductor https://bioconductor.org/packages/rhdf5)")
}
Expand Down Expand Up @@ -248,12 +249,12 @@ WriteHaplotypes <- function(hdf5.file, haps,
# Write
message(glue("Writing {N} haplotype(s) of size {L} ...\n"))

rhdf5::h5write(as.array(haps), h5, haps.name, index = list(NULL, (N.old+1):(N.old+N)))
rhdf5::h5writeDataset(as.array(haps), h5, haps.name, index = list(NULL, (N.old+1):(N.old+N)))
if(write.hap.ids) {
rhdf5::h5write(as.array(as.character(hap.ids)), h5, hap.ids.name, index = list((N.old+1):(N.old+N)))
rhdf5::h5writeDataset(as.array(as.character(hap.ids)), h5, hap.ids.name, index = list((N.old+1):(N.old+N)))
}
if(write.loci.ids) {
rhdf5::h5write(as.array(as.character(loci.ids)), h5, loci.ids.name, index = list(1:L))
rhdf5::h5writeDataset(as.array(as.character(loci.ids)), h5, loci.ids.name, index = list(1:L))
}

rhdf5::h5closeAll()
Expand Down Expand Up @@ -351,6 +352,7 @@ ReadHaplotypes <- function(hdf5.file,
if(!identical(loci.ids, NA) && !identical(loci.idx, NA)) {
stop("Can only specify one of loci.ids or loci.idx argument.")
}
# NOTE: this previously had to be removed to allow running on WashU cluster -- if error triggers here again LA and RC to discuss
if(length(find.package("rhdf5", quiet = TRUE)) == 0) {
stop("The ReadHaplotypes function requires the optional rhdf5 package to be installed (see Bioconductor https://bioconductor.org/packages/rhdf5)")
}
Expand Down

0 comments on commit 073ec63

Please sign in to comment.