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. NOTE: This function is now deprecated for getId
(using SQLite rather than data.table).
Arguments
- taxa
a vector of taxonomic names
- taxaNames
a names data.table from
read.names
Value
a vector of character strings giving taxa IDs (potentially comma concatenated for any taxa with ambiguous names)
Examples
namesText<-c(
"1\t|\tall\t|\t\t|\tsynonym\t|",
"1\t|\troot\t|\t\t|\tscientific name\t|",
"3\t|\tMulti\t|\tBacteria <prokaryotes>\t|\tscientific name\t|",
"4\t|\tMulti\t|\tBacteria <prokaryotes>\t|\tscientific name\t|",
"2\t|\tBacteria\t|\tBacteria <prokaryotes>\t|\tscientific name\t|",
"2\t|\tMonera\t|\tMonera <Bacteria>\t|\tin-part\t|",
"2\t|\tProcaryotae\t|\tProcaryotae <Bacteria>\t|\tin-part\t|"
)
tmpFile<-tempfile()
writeLines(namesText,tmpFile)
names<-read.names(tmpFile)
#> Warning: taxonomizr is moving from data.table to SQLite databases to improve performance. This will require changing nodes and names processing. Please see ?read.names.sql or ?taxonomizrSwitch
getId2('Bacteria',names)
#> Warning: taxonomizr is moving from data.table to SQLite databases to improve performance. This will require changing nodes and names processing. Please see ?getId or ?taxonomizrSwitch
#> [1] "2"
getId2('Not a real name',names)
#> Warning: taxonomizr is moving from data.table to SQLite databases to improve performance. This will require changing nodes and names processing. Please see ?getId or ?taxonomizrSwitch
#> [1] NA
getId2('Multi',names)
#> Warning: taxonomizr is moving from data.table to SQLite databases to improve performance. This will require changing nodes and names processing. Please see ?getId or ?taxonomizrSwitch
#> Warning: Multiple taxa ids found for Multi. Collapsing with commas
#> [1] "3,4"