4
$\begingroup$

I recently had a script fail due to poor handling of BLAST output. The BLAST -outfmt staxids field usually returns a single taxid, but occasionally it returns two or more taxids separated by a semicolon, such as 556514;701533. Fixing the script to handle this should be fairly straightforward. But the original failure happened when I was searching a local copy of the NCBI nt database, and I'd like to create a test case with a small query and small database that reproduces this issue more rapidly.

I am familiar with the -taxid and -taxid_map flags of the makeblastdb command, but I have been unable to reproduce this behavior with BLAST; that is, make BLAST return multiple taxids for a sequence.

  • If I provide 556514;701533 or 556514,701533 as a sequence's taxid with -taxid or -taxid_map, the makeblastdb command fails citing an integer conversion error.
  • If I provide 556514 701533 as the taxid in the taxid_map file, the database will be indexed successfully but BLAST will return the invalid value 0 for staxids.
  • If I duplicate each entry in the -taxid_map file so that there is an entry for each taxid (see below), only a single taxid is reported by BLAST.
    seq1 556514
    seq1 701533
    seq2 556514
    seq2 701533
    seq3 556514
    seq3 701533
    ...
    

When constructing a custom local BLAST database, how do I associated a database sequence with more than one taxid?


UPDATE: The offending entry (or one such entry) appears to be a duplicate or merged entry in the nt database. When I use blastdbcmd to retrieve the subject sequence by accession, nt returns a sequence with two deflines on single line, like so.

>accession1 plain text description >accession2 other description
ACGT...

Using either of the two accessions, blastdbcmd will return the exact same entry, and the two staxids shown above correspond to the two distinct accessions.

So part of the issue seems to be how to construct a BLAST database such that multiple accessions can point to a single entry/subject.

$\endgroup$
3
  • $\begingroup$ Can't you just jiggle it around in pandas? That was my approach leveraging local blast, albeit for something it was probably not intended to do $\endgroup$
    – M__
    Jan 25, 2022 at 15:27
  • $\begingroup$ @M__ I already have what I think is a solution, yes involving post-processing the BLAST tabular results in a dataframe. But I'll re-emphasize that I'm trying to construct a test case that will reproduce this behavior in BLAST. $\endgroup$ Jan 25, 2022 at 18:43
  • $\begingroup$ Thanks now I understand. If a Blast expert answers I'll be enlightened too. $\endgroup$
    – M__
    Jan 25, 2022 at 18:53

1 Answer 1

4
$\begingroup$

I inquired with the NCBI BLAST help desk today, and within an hour they provided a very helpful response.

To summarize, when redundant records in the database are collapsed, the deflines (accessions + descriptions) of the original entries are placed on a single line separated by an invisible control character (Ctrl-A or \x01). The makeblastdb program will recognize this and associate multiple accessions (from the combined defline) and taxids (from the taxid_map file) to a single entry. If you are retrieving entries from e.g. nt or nr with blastdbcmd, you can use the -ctrl_a flag to format the data with these invisible control characters—by default the > character is used.


tl;dr I can reproduce the behavior described in the original question by:

  1. creating a FASTA file containing an entry with multiple accessions separated by the invisible \x01 character
  2. create a taxid_map file mapping the accessions to different taxids
  3. format the FASTA file with makeblastdb -taxid_map ...
  4. perform a BLAST search with a query that matches the entry in question; -outfmt "6 staxids" will return a string with multiple taxids.
$\endgroup$
1
  • 2
    $\begingroup$ Thanks for answering your question. Its good to know the NCBI helpdesk is fast and knowledgeable. $\endgroup$
    – M__
    Jan 26, 2022 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.