Skip to content

Commit

Permalink
added FASTA support to read
Browse files Browse the repository at this point in the history
  • Loading branch information
egenn committed Jun 7, 2024
1 parent 1330caf commit a5d571f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' - **Delimited** files using `data.table:fread()`, `arrow:read_delim_arrow()`,
#' `vroom::vroom()`, `duckdb::duckdb_read_csv()`
# or `polars::pl$read_csv()`
#' - **FASTA** files using `seqinr::read.fasta()`
#'
#' @param filename Character: filename or full path if `datadir = NULL`
#' @param datadir Character: Optional path to directory where `filename`
Expand Down Expand Up @@ -126,6 +127,18 @@ read <- function(filename,
}
.dat <- haven::read_dta(path, ...)
if (output == "data.table") setDT(.dat)
} else if (ext == "fasta") {
dependency_check("seqinr")
if (verbose) {
msg20(
bold(green("\u25B6")), " Reading ",
hilite(basename(path)), " using seqinr::read.fasta()..."
)
}
.dat <- seqinr::read.fasta(path, ...)
# if single sequence, return as character
if (length(.dat) == 1) .dat <- as.character(.dat[[1]])
return(.dat)
} else {
if (verbose) {
msg20(
Expand Down Expand Up @@ -245,7 +258,8 @@ read <- function(filename,
}

if (timed) outro(start.time)
.dat

return(.dat)
} # rtemis::read

msgread <- function(x, caller = "", use_basename = TRUE) {
Expand Down
1 change: 1 addition & 0 deletions man/read.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a5d571f

Please sign in to comment.