query
pykmhelpers.pipeline.query
KmindexQuery
Source code in pykmhelpers/pipeline/query.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
execute(registry_path, output_dir='query', index_ids=None, z=6, threshold=0.01, single_query=None, aggregate=False, threads=1, fast=True, is_compressed=False, method='seq', vec=False)
Run a query against the kmindex registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry_path
|
str
|
Path to the kmindex registry. |
required |
output_dir
|
str
|
Output directory for query results. |
'query'
|
index_ids
|
list[str]
|
Index IDs to query against; empty list queries all. |
None
|
z
|
int
|
Z-value (error rate parameter) for kmindex. |
6
|
threshold
|
float
|
Minimum score threshold for reported hits. |
0.01
|
single_query
|
str
|
Query identifier; treats all sequences as one query. |
None
|
aggregate
|
bool
|
Whether to aggregate batch results into a single file. |
False
|
threads
|
int
|
Number of threads to use. |
1
|
fast
|
bool
|
Enable fast mode (disabled automatically when |
True
|
is_compressed
|
bool
|
Whether the index is stored in compressed form. |
False
|
method
|
str
|
Query method passed to kmindex (e.g. |
'seq'
|
vec
|
bool
|
Use |
False
|
Source code in pykmhelpers/pipeline/query.py
QueryRunnerConfig
dataclass
Configuration for a QueryRunner instance.
Attributes:
| Name | Type | Description |
|---|---|---|
registry_path |
str
|
Path to the kmindex registry directory. |
output_dir |
str
|
Root output directory; per-query subdirectories are created here. |
index_ids |
list[str]
|
Index IDs to query against. Empty means all indices. |
zvalue |
int
|
Z-value for the findere false-positive filter. |
threshold |
float
|
Score threshold applied when filtering results. |
threads |
int
|
Number of threads passed to kmindex. |
single_query |
Optional[str]
|
When set, all sequences are merged under this identifier. |
batch |
bool
|
Concatenate all input files into one query before running. |
aggregate |
bool
|
Aggregate batch results into a single output file. |
compressed |
bool
|
Whether the index is stored in compressed form. |
output_format |
str
|
Output format for result conversion ( |
timestamp |
bool
|
Append a |
on_existing |
str
|
Behaviour when the output directory already exists
( |
parallel |
str
|
Parallelisation strategy passed to kmindex ( |
force |
bool
|
Skip confirmation prompts (e.g. when |
print_output |
bool
|
Write converted results to stdout instead of saving to
file. Only meaningful when |
on_result |
Optional[Callable[[list[KmindexQueryResult]], None]]
|
Optional callback invoked with each per-query result list as it completes. Useful for streaming results to the caller without waiting for the full run to finish. |
Source code in pykmhelpers/pipeline/query.py
QueryRunner
Orchestrates one or more kmindex query operations.
Accepts a list of query file paths (or "-" for stdin), resolves them to
concrete files, optionally batches them, and runs each query via
KmindexQuery. Output-directory conflict resolution, format conversion,
and temp-file cleanup are all handled internally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
QueryRunnerConfig
|
Runtime configuration. See |
required |
Source code in pykmhelpers/pipeline/query.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | |
run(query_files)
Run queries for all provided input paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_files
|
Iterable[str]
|
Paths to FASTA/FASTQ files or directories. Pass
|
required |
Returns:
| Type | Description |
|---|---|
list[list[KmindexQueryResult]]
|
A list of per-query result lists, in the same order as the resolved |
list[list[KmindexQueryResult]]
|
input files (one entry per executed query). |