Learn R Programming

taxonomizr (version 0.10.6)

getId: Find a given taxa by name

Description

Find a taxa by string in the NCBI taxonomy. Note that NCBI species are stored as Genus species e.g. "Bos taurus". Ambiguous taxa names will return a comma concatenated string e.g. "123,234" and generate a warning.

Usage

getId(taxa, sqlFile = "nameNode.sqlite", onlyScientific = TRUE)

Value

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

Arguments

taxa

a vector of taxonomic names

sqlFile

a string giving the path to a SQLite file containing a names tables

onlyScientific

If TRUE then only match to scientific names. If FALSE use all names in database for matching (potentially increasing ambiguous matches).

See Also

getTaxonomy, read.names.sql, getCommon

Examples

Run this code
namesText<-c(
  "1\t|\tall\t|\t\t|\tsynonym\t|",
  "1\t|\troot\t|\t\t|\tscientific name\t|",
  "3\t|\tMulti\t|\tBacteria \t|\tscientific name\t|",
  "4\t|\tMulti\t|\tBacteria \t|\tscientific name\t|",
  "2\t|\tBacteria\t|\tBacteria \t|\tscientific name\t|",
  "2\t|\tMonera\t|\tMonera \t|\tin-part\t|",
  "2\t|\tProcaryotae\t|\tProcaryotae \t|\tin-part\t|"
)
tmpFile<-tempfile()
writeLines(namesText,tmpFile)
sqlFile<-tempfile()
read.names.sql(tmpFile,sqlFile)
getId('Bacteria',sqlFile)
getId('Not a real name',sqlFile)
getId('Multi',sqlFile)

Run the code above in your browser using DataLab