VEuPathDB / VEuPathDB/ApiCommonModel
"All" pathway semantics behave as "any": HAVING compares a per-gene group count to a total row count
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 1
- Forks
- 1
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 5
Description
In Model/lib/wdk/model/questions/queries/pathwayQueries.xml, the any_or_all_pathway "all" branch does not implement "all". It is a no-op in at least one search and probably close to one in the others.
The defect
Take PathwaysByGeneList:
GROUP BY tp.pathway_source_id, tp.pathway_source, tp.gene_source_id, tp.ec_number_gene, tp.ec_number_pathway
HAVING (
('$$any_or_all_pathway$$' = 'any')
OR (count(*) <= (SELECT count (*)
FROM apidbtuning.TranscriptPathway tp , dsGene ds
WHERE tp.gene_source_id = ds.gene
)
))
The GROUP BY includes tp.gene_source_id, so each group is one gene in one pathway with one EC pair — count(*) per group is typically 1. The subquery counts every pathway-gene row for the entire input list. So the comparison is roughly 1 <= (large number), which is true for every group. The all branch filters nothing.
For "pathways containing all of these genes", the comparison needs to be at the pathway level — something like count(distinct gene_source_id) = <number of input genes> after grouping by pathway alone, not per gene.
Evidence
EXPLAIN ANALYZE of PathwaysByGeneList against genomicsdb_071n, 5-gene input (PF3D7_0103700, PF3D7_0109500, PF3D7_0109850, PF3D7_0110600, PF3D7_0202900), pathways_source=1, exclude_incomplete_ec=0, exact_match_only=0:
| mode | rows out |
|---|---|
any |
3687 |
all |
3687 |
Identical. With any the planner constant-folds ('any' = 'any') and drops the subquery entirely; with all it evaluates it as an InitPlan and every group still passes.
Affected sites
| Query | Line (approx) | Comparison |
|---|---|---|
PathwaysByGeneList |
~234 | count(*) <= — never filters |
PathwaysByGeneIds |
~414 | count(*) = — same grouping problem, also grouped per gene |
PathwaysByCompounds |
~307 | count(*) = — same shape, worth checking against compound grouping |
The <= in PathwaysByGeneList is the most clearly wrong; the = variants may filter something, but not the intended thing, since the group is still per-gene.
Why this wasn't caught
It fails open. "All" silently returns the "any" result set, which is a superset containing the correct answer — so results look plausible and nothing errors. Only a count comparison between the two modes reveals it.
Not in scope of #227
Noticed while fixing the gene-alias resolution in these same queries (#227), and deliberately left untouched there — it is pre-existing and needs a semantics decision, not a mechanical fix. Someone should confirm what "all" is meant to mean in the UI before rewriting the grouping.
🤖 Generated with Claude Code
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Model/lib/wdk/model/questions/queries/pathwayQueries.xml and inspect the all branches of PathwaysByGeneList, PathwaysByGeneIds, and PathwaysByCompounds. Confirm the UI’s intended meaning of “all,” then compare any and all using the five-gene example from the issue. Done means all returns only pathways satisfying that meaning rather than the any result set across the affected queries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100