Skip to contents

Find accessions numbers for a given taxa ID the NCBI taxonomy. This will be pretty slow unless the database was built with indexTaxa=TRUE since the database would not have an index for taxaId.

Usage

getAccessions(taxaId, sqlFile, version = c("version", "base"), limit = NULL)

Arguments

taxaId

a vector of taxonomic IDs

sqlFile

a string giving the path to a SQLite file created by read.accession2taxid

version

either 'version' indicating that taxaids are versioned e.g. Z17427.1 or 'base' indicating that taxaids do not have version numbers e.g. Z17427 (default: 'version')

limit

return only this number of accessions or NULL for no limits

Value

a vector of character strings giving taxa IDs (potentially comma concatenated for any taxa with ambiguous names)

Examples

taxa<-c(
  "accession\taccession.version\ttaxid\tgi",
  "Z17427\tZ17427.1\t3702\t16569",
  "Z17428\tZ17428.1\t3702\t16570",
  "Z17429\tZ17429.1\t3702\t16571",
  "Z17430\tZ17430.1\t3702\t16572"
)
inFile<-tempfile()
sqlFile<-tempfile()
writeLines(taxa,inFile)
read.accession2taxid(inFile,sqlFile,vocal=FALSE)
getAccessions(3702,sqlFile)
#>   taxa accession
#> 1 3702  Z17427.1
#> 2 3702  Z17428.1
#> 3 3702  Z17429.1
#> 4 3702  Z17430.1