From 2d0e358855c14fda8b35c6f9636aac56f409f84a Mon Sep 17 00:00:00 2001 From: Nuno Agostinho Date: Fri, 18 Nov 2022 12:11:18 +0000 Subject: [PATCH 1/2] Skip query hits above user-defined threshold --- tools/ncbi_blast_plus/blastxml_to_tabular.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/ncbi_blast_plus/blastxml_to_tabular.py b/tools/ncbi_blast_plus/blastxml_to_tabular.py index 73c6333a..b3946c56 100755 --- a/tools/ncbi_blast_plus/blastxml_to_tabular.py +++ b/tools/ncbi_blast_plus/blastxml_to_tabular.py @@ -132,6 +132,13 @@ help="[std|ext|col1,col2,...] standard 12 columns, " "extended 25 columns, or list of column names", ) +parser.add_option( + "--hits", + dest="hits", + type=int, + default=float("inf"), + help="number of query hits to display (default to displaying all hits)" +) (options, args) = parser.parse_args() colnames = ( @@ -242,6 +249,11 @@ def convert(blastxml_filename, output_handle): # chrIII gi|240255695|ref|NC_003074.8| Arabidopsis # thaliana chromosome 3, complete sequence # 2 + + # Skip query hits above user-defined threshold + if int(hit.findtext("Hit_num")) > options.hits: + continue + sseqid = hit.findtext("Hit_id").split(None, 1)[0] hit_def = sseqid + " " + hit.findtext("Hit_def") if re_default_subject_id.match(sseqid) and sseqid == hit.findtext( From 5418d52f38b51663c7da16bf0207d5d060a6a432 Mon Sep 17 00:00:00 2001 From: Nuno Agostinho Date: Fri, 18 Nov 2022 12:17:30 +0000 Subject: [PATCH 2/2] Update blastxml_to_tabular.py --- tools/ncbi_blast_plus/blastxml_to_tabular.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ncbi_blast_plus/blastxml_to_tabular.py b/tools/ncbi_blast_plus/blastxml_to_tabular.py index b3946c56..c6f387ac 100755 --- a/tools/ncbi_blast_plus/blastxml_to_tabular.py +++ b/tools/ncbi_blast_plus/blastxml_to_tabular.py @@ -137,7 +137,7 @@ dest="hits", type=int, default=float("inf"), - help="number of query hits to display (default to displaying all hits)" + help="number of query hits to display (defaults to all query hits)" ) (options, args) = parser.parse_args()