A one-step replacement for the shell commands previously needed to build metacleaner databases: downloads all NCBI Nucleotide records that match `term`, simplifies the headers to accessions, removes empty and (optionally) duplicate sequences and writes one sequence per line.
Usage
build_reference_db(
term,
file,
dereplicate = FALSE,
min_length = 0,
max_records = Inf,
keep_download = FALSE,
api_key = Sys.getenv("ENTREZ_KEY"),
verbose = TRUE
)Arguments
- term
NCBI Nucleotide search term, e.g. `'(ITS2) AND Embryophyta[Organism] AND ("0"[SLEN] : "10000"[SLEN])'`.
- file
Output FASTA file for the finished database.
- dereplicate
Remove duplicate sequences (see [dereplicate()])? Default `FALSE`. Recommended for contaminant databases; **not** recommended for the reference database, because identical sequences from different genera are what reveals ambiguous or mislabeled entries.
- min_length
Remove sequences shorter than this. Default 0.
- max_records
Maximum number of records to download. Default: all.
- keep_download
Keep the raw download next to `file` (with suffix `.raw.fasta`)? Default `FALSE`.
- api_key
Optional NCBI API key. Defaults to the `ENTREZ_KEY` environment variable.
- verbose
Print progress. Default `TRUE`.
Examples
if (FALSE) { # \dontrun{
# Plant ITS1/ITS2 reference database (as used by Crone et al. 2023)
build_reference_db(
'((((ITS1) OR 5.8S) OR 28S) OR ITS2) AND Embryophyta[Organism] AND ("0"[SLEN] : "10000"[SLEN])',
"ITS_plants.fasta")
# Non-plant (contaminant) database
build_reference_db(
'((((ITS1) OR 5.8S) OR 28S) OR ITS2) NOT Embryophyta[Organism] AND ("0"[SLEN] : "10000"[SLEN])',
"ITS_nonplants.fasta", dereplicate = TRUE)
} # }