Created
April 18, 2020 07:48
-
-
Save joelnitta/a7268ed7729b3610f163fc749deef95b to your computer and use it in GitHub Desktop.
Write out a list of fasta files in chunks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Write out a list of DNA sequences in chunks | |
#' | |
#' The list will be split into a list of lists, to | |
#' save memory when writing out sequences. | |
#' | |
#' @param fasta_list The list of DNA sequences | |
#' @param chunk_size Size of chunks to split up list into. | |
#' @param out_dir Directory to write to | |
#' | |
#' @return List of hashes; digest of each chunk. Externally, the | |
#' sequences will be written to out_dir | |
#' | |
write_fasta_files_chunked <- function(fasta_list, chunk_size = 100, out_dir) { | |
# Split list of fasta files to write out into chunks | |
n <- length(fasta_list) | |
r <- rep(1:ceiling(n/chunk_size), each=chunk_size)[1:n] | |
fasta_list_split <- split(fasta_list, r) | |
# Write out in chunks | |
purrr::map(fasta_list_split, ~baitfindR::write_fasta_files(., out_dir = out_dir)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment