Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kga1978
    Senior Member
    • Nov 2010
    • 100

    #1

    BLAST filtering out 'no hits' in output

    Hi,

    I am using a local install of blastn to look for hits to a custom database from a bunch of short reads. In my final output file, I really only care about reads that found a 'hit' and so want to filter out all reads with 'no hits'. My strategy is as follows:

    Read 1
    Read 2
    .
    .
    Read X

    -> Put into one big FASTA file
    -> Run blastn against the custom database
    -> Save to file reads with hits only.

    Right now (the standard blast output) would be:
    Read 1 -> hit 1
    Read 2 -> no hit
    . -> no hit
    . -> no hit
    Read X -> hit X

    But I want my output to only show:
    Read 1 -> hit 1
    Read x -> hit X

    Since I have many reads and very few hits, my output file very rapidly gets filled with all the 'no hits' reads slowing down the whole process. Is there a way to filter my output directly via the command line, or do I need to build a script to do this?

    Thanks in advance,
    Kristian
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    I would use the tabular output, which just writes nothing at all for no hits.

    Comment

    • kga1978
      Senior Member
      • Nov 2010
      • 100

      #3
      Hmm, tried that and I get the following error:
      BLAST query/options error: No hits are being saved

      I run the following command:
      blastn -query reads.fasta -db nt -num_descriptions 1 -num_alignments 0 -out reads_blastNT.txt -num_threads 8 -outfmt 6

      Instead of "-outfmt 6", I have also used:
      "7 sseqid ssac qstart qend sstart send qseq evalue bitscore"

      but I get the same result. Any thoughts? The output file is also empty.

      Thanks very much.

      Comment

      • kga1978
        Senior Member
        • Nov 2010
        • 100

        #4
        Okay, so I solved the error, which was caused by my "-num_alignments 0" handle. However, the output still contains my reads with no hits - it just writes '0 hits found' under the read. This is not what I am after - I want to completely ignore '0 hits' reads so they don't even get written to the file.

        Comment

        • maubp
          Peter (Biopython etc)
          • Jul 2009
          • 1544

          #5
          What exactly is the new command line you are running?

          Comment

          • kga1978
            Senior Member
            • Nov 2010
            • 100

            #6
            Hi maubp.

            Sorry, I don't understand that question - I'm not running a new command line - I'm just trying to figure out whether I can tell blastn not to store my 'no hits' hits in the output file.

            Comment

            • maubp
              Peter (Biopython etc)
              • Jul 2009
              • 1544

              #7
              I would expect you to use something like this command line:

              blastn -query reads.fasta -db nt -out reads_blastNT.txt -num_threads 8 -outfmt 6

              Rather than messing about with -num_descriptions and/or -num_alignments which only really apply to the plain text and HTML output, from memory I would use -max_target_seqs instead.

              Comment

              • kga1978
                Senior Member
                • Nov 2010
                • 100

                #8
                I tried that one, but I still have the same problem - the '0 hits' hits are still recorded in the output file, rather than discarded.

                I guess I just have to pipe it and make a script - but it would have been easier if it could have been done directly from the command line.

                Comment

                • maubp
                  Peter (Biopython etc)
                  • Jul 2009
                  • 1544

                  #9
                  I am surprised. What version of BLAST+ do you have? And could you post a bit of the example output?

                  Comment

                  • kga1978
                    Senior Member
                    • Nov 2010
                    • 100

                    #10
                    I should have the newest version:
                    blastn: 2.2.25+
                    Package: blast 2.2.25, build Mar 21 2011 12:21:32

                    An example output looks like this (tabular format):
                    # BLASTN 2.2.25+
                    # Query: ILLUMINA:203:C07LRACXX:5:1101:1348:1952 1:N:0:TAGCTT
                    # Database: custom
                    # 0 hits found
                    # BLASTN 2.2.25+
                    # Query: ILLUMINA:203:C07LRACXX:5:1101:1366:1952 1:Y:0:TAGCTT
                    # Database: custom
                    # 0 hits found
                    # BLASTN 2.2.25+
                    # Query: ILLUMINA:203:C07LRACXX:5:1101:1472:1955 1:N:0:TAGCTT
                    # Database: custom
                    # 0 hits found
                    # BLASTN 2.2.25+
                    # Query: ILLUMINA:203:C07LRACXX:5:1101:1456:1981 1:N:0:TAGCTT
                    # Database: custom
                    # 0 hits found
                    # BLASTN 2.2.25+
                    # Query: ILLUMINA:203:C07LRACXX:5:1101:1414:1981 1:N:0:TAGCTT
                    # Database: custom
                    # 0 hits found

                    Basically, these are all the reads I don't want listed in the file as they have no hits.

                    Thanks a bunch.

                    Comment

                    • maubp
                      Peter (Biopython etc)
                      • Jul 2009
                      • 1544

                      #11
                      All those lines starting with a hash (#) are comments which you asked BLAST to produce by using -outfmt 7,
                      Code:
                      $ blastn -help
                      ...
                       *** Formatting options
                       -outfmt <String>
                         alignment view options:
                           0 = pairwise,
                           1 = query-anchored showing identities,
                           2 = query-anchored no identities,
                           3 = flat query-anchored, show identities,
                           4 = flat query-anchored, no identities,
                           5 = XML Blast output,
                           6 = tabular,
                           7 = tabular with comment lines,
                           8 = Text ASN.1,
                           9 = Binary ASN.1,
                          10 = Comma-separated values,
                          11 = BLAST archive format (ASN.1)
                      Use -outfmt 6 as I suggested, and they'll go away.

                      P.S. That does mean for this example as there are no hits at all, the output file will be empty.

                      Comment

                      • kga1978
                        Senior Member
                        • Nov 2010
                        • 100

                        #12
                        Yes! That worked - thanks so much. I skipped the -outfmt 6 handle when it initially failed due to my "-num_alignments 0".

                        Thanks for your help - that's exactly what I needed.

                        Comment

                        • maubp
                          Peter (Biopython etc)
                          • Jul 2009
                          • 1544

                          #13
                          Great

                          Thanks for confirming it worked.

                          Comment

                          • jmjensen
                            Junior Member
                            • Sep 2011
                            • 3

                            #14
                            I made the same mistake just now by choosing -outfmt 7

                            However, it's a rather easy fix to remove the comments:

                            Code:
                            awk '!/^\#/' file > newfile
                            Should do the trick.
                            Last edited by jmjensen; 06-01-2013, 12:50 AM.

                            Comment

                            • JonB
                              Member
                              • Jan 2010
                              • 85

                              #15
                              This is maybe not the right thread, but I am interested in only the queries with 'no hits'. So far I can only extract the reads with hits, and then compare the differences between the original query file and the file with hits only.

                              Any good tips on how to directly extract the queries with no hits?

                              Thanks, Jon

                              Comment

                              Latest Articles

                              Collapse

                              • SEQadmin2
                                Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                                by SEQadmin2



                                Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                                Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                                ...
                                10-14-2026, 09:55 AM
                              • SEQadmin2
                                New Genomics Technologies Take Aim at Long-Standing Limits
                                by SEQadmin2


                                Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                                We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                                ...
                                09-28-2026, 10:25 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, 10-22-2026, 11:13 AM
                              0 responses
                              23 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-22-2026, 10:48 AM
                              0 responses
                              20 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-15-2026, 10:52 AM
                              0 responses
                              36 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-14-2026, 05:39 AM
                              0 responses
                              42 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...