Skip to content

Commit a5d571f

Browse files
committed
added FASTA support to read
1 parent 1330caf commit a5d571f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

R/read.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#' - **Delimited** files using `data.table:fread()`, `arrow:read_delim_arrow()`,
2020
#' `vroom::vroom()`, `duckdb::duckdb_read_csv()`
2121
# or `polars::pl$read_csv()`
22+
#' - **FASTA** files using `seqinr::read.fasta()`
2223
#'
2324
#' @param filename Character: filename or full path if `datadir = NULL`
2425
#' @param datadir Character: Optional path to directory where `filename`
@@ -126,6 +127,18 @@ read <- function(filename,
126127
}
127128
.dat <- haven::read_dta(path, ...)
128129
if (output == "data.table") setDT(.dat)
130+
} else if (ext == "fasta") {
131+
dependency_check("seqinr")
132+
if (verbose) {
133+
msg20(
134+
bold(green("\u25B6")), " Reading ",
135+
hilite(basename(path)), " using seqinr::read.fasta()..."
136+
)
137+
}
138+
.dat <- seqinr::read.fasta(path, ...)
139+
# if single sequence, return as character
140+
if (length(.dat) == 1) .dat <- as.character(.dat[[1]])
141+
return(.dat)
129142
} else {
130143
if (verbose) {
131144
msg20(
@@ -245,7 +258,8 @@ read <- function(filename,
245258
}
246259

247260
if (timed) outro(start.time)
248-
.dat
261+
262+
return(.dat)
249263
} # rtemis::read
250264

251265
msgread <- function(x, caller = "", use_basename = TRUE) {

man/read.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)