Skip to contents

Return a vector of all IDs in a database.

Usage

list_db_ids(db = "nucleotide", n = 100)

Arguments

db

character, database name

n

Maximum number of IDs to return, if NULL returns all

Value

vector of characters

Details

Warning: can return very large vectors for large databases.

See also

Examples

library(restez)
restez_path_set(filepath = tempdir())
#> ... Creating '/tmp/RtmpUhc9R4/restez'
#> ... Creating '/tmp/RtmpUhc9R4/restez/downloads'
demo_db_create(n = 5)
# Warning: not recommended for real databases
#  with potentially millions of IDs
all_ids <- list_db_ids()
#> Warning: Number of ids returned was limited to [100].
#> Set `n=NULL` to return all ids.


# What shall we do with these IDs?
# ... how about make a mock fasta file
seqs <- gb_sequence_get(id = all_ids)
defs <- gb_definition_get(id = all_ids)
# paste together
fasta_seqs <- paste0('>', defs, '\n', seqs)
fasta_file <- paste0(fasta_seqs, collapse = '\n')
cat(fasta_file)
#> >A demonstration sequence | id demo_1
#> AGGCGTCTGC
#> >A demonstration sequence | id demo_2
#> ATCCTTGCAT
#> >A demonstration sequence | id demo_3
#> AAAGCACCGT
#> >A demonstration sequence | id demo_4
#> AAGCATGGAC
#> >A demonstration sequence | id demo_5
#> TTTATGGGTT


# delete after example
db_delete(everything = TRUE)