library(taxonomizr)
# read.names.sql('names.dmp','accessionTaxa.sql')
# read.nodes.sql('nodes.dmp','accessionTaxa.sql')
# read.accession2taxid('~/prot.accession2taxid.gz','accessionTaxa.sql')
# prepareDatabase('accessionTaxa.sql')
path <- "/home/liu507/zhao/12.20-accnumber"
path2 <- "/home/liu507/zhao/12.20-nr-annotation"
fileName <- dir(path)
for(k in 1:length(fileName)){
blastAccessions<-read.table(file=paste(path,fileName[k],sep ="/"))
blastAccessions<-as.character(blastAccessions$V1)
ids<-accessionToTaxa(blastAccessions,'~/taxdump/accessionTaxa.sql')
tax = getTaxonomy(ids,'~/taxdump/accessionTaxa.sql')
write.table(tax,file=paste(path2,fileName[k],sep="/"),sep="\t",quote = F)
}
blastAccessions<-read.table(""file=paste(path,fileName[k],sep ="/"))
blastAccessions<-as.character(blastAccessions$V1)
ids<-accessionToTaxa("WP_059424346.1",'~/taxdump/accessionTaxa.sql')
tax = getTaxonomy(ids,'~/taxdump/accessionTaxa.sql')
write.table(tax,file=paste(path2,fileName[k],sep="/"),sep=";",quote = F,col.names = F)