Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip query hits above user-defined threshold #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tools/ncbi_blast_plus/blastxml_to_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (defaults to all query hits)"
)
(options, args) = parser.parse_args()

colnames = (
Expand Down Expand Up @@ -242,6 +249,11 @@ def convert(blastxml_filename, output_handle):
# <Hit_def>chrIII gi|240255695|ref|NC_003074.8| Arabidopsis
# thaliana chromosome 3, complete sequence</Hit_def>
# <Hit_accession>2</Hit_accession>

# 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(
Expand Down