bioinformatics BLAST Extract GI and taxid from blastdb


Example

Data can be extracted from a blastdb using blastdbcmd which should be included in a blast installation. You can specify from the options below as part of -outfmt what metadata to include and in what order.

From the man page:

 -outfmt <String>
   Output format, where the available format specifiers are:
       %f means sequence in FASTA format
       %s means sequence data (without defline)
       %a means accession
       %g means gi
       %o means ordinal id (OID)
       %i means sequence id
       %t means sequence title
       %l means sequence length
       %h means sequence hash value
       %T means taxid
       %X means leaf-node taxids
       %e means membership integer
       %L means common taxonomic name
       %C means common taxonomic names for leaf-node taxids
       %S means scientific name
       %N means scientific names for leaf-node taxids
       %B means BLAST name
       %K means taxonomic super kingdom
       %P means PIG

The example snippet shows how gi and taxid can be extracted from blastdb. The NCBI 16SMicrobial (ftp) blastdb was chosen for this example:

# Example:
# blastdbcmd -db <db label> -entry all -outfmt "%g %T" -out <outfile>
blastdbcmd -db 16SMicrobial -entry all -outfmt "%g %T" -out 16SMicrobial.gi_taxid.tsv

Which will produce a file 16SMicrobial.gi_taxid.tsv that looks like this:

939733319 526714
636559958 429001
645319546 629680