"All" pathway semantics behave as "any": HAVING compares a per-gene group count to a total row count

オープン
#228 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
sql
領域
databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Perl
スター
1
フォーク
1
平均マージ
2日 10分
マージ済み PR(30日)
15

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

VEuPathDB/ApiCommonModel のほかの issue

VEuPathDB/ApiCommonModel の issue をすべて見る

似ている issue

Perl の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。