Skip to content

Read an uncomputed annotation score from either Console notation - #11

Open
htsugawa wants to merge 1 commit into
mainfrom
fix/uncomputed-annotation-score-null
Open

Read an uncomputed annotation score from either Console notation#11
htsugawa wants to merge 1 commit into
mainfrom
fix/uncomputed-annotation-score-null

Conversation

@htsugawa

@htsugawa htsugawa commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Consumer-side counterpart to systemsomicslab/MsdialWorkbench#785, which changes how MS-DIAL Console writes an annotation score that was never computed.

Problem

parse_mdpeak and parse_mdscan depended on the -1 sentinel:

if all(value is not None for value in (weighted, simple, reverse, matched_percentage, matched_count)):
    if all(value >= 0 for value in (...)):
        scored_count += 1
    scores.append({...})

So a precursor-only row was a candidate but not scored — which is what the tuning panel shows as MSP reference candidates versus MS/MS-scored candidates.

A Console that includes the shared AnnotationScoreFormat writes null into every score column of such a row instead of 0.000 dot products plus -1 matched-peak values. Read with the old rule those cells are None, the row drops out of both counts, and the two numbers collapse to the same value.

Change

  • Candidate count now comes from the annotated name, which is independent of the score notation. Any name other than Unknown or empty is a reference candidate, including the no MS2: , w/o MS2: and low score: prefixes. This reproduces today's number against both an older and a newer Console, so the app works with an official Console package and a local source build alike.
  • Scored count keeps its meaning — rows with a spectral comparison. A row whose comparison genuinely produced zero still counts as scored, because those zeros are measurements.
  • Both parsers now share one _annotation_score_row helper, so they agree.

One corrected number

The .mdscan fixture's candidate count changes from 2 to 1, and that is a fix. GcmsAnalysisMetadataAccessor writes -1 into every score column when there is no match result at all, so the old rule counted an Unknown GC-MS row as a reference candidate.

Tests

python -m unittest discover -s tests — 66 pass.

  • test_parse_ascii_mdpeak keeps its assertions, with the fixture given the Name column that a real .mdpeak always carries.
  • test_parse_ascii_mdpeak_reports_same_counts_for_null_uncomputed_scores is new: the same counts from the new notation.
  • test_parse_ascii_mdpeak_keeps_a_comparison_that_scored_zero is new: an all-zero row that a real comparison produced still counts as scored.

🤖 Generated with Claude Code

MS-DIAL is changing how it writes an annotation score that was never
computed. Both text exports now write null for such a score, where .mdpeak
previously wrote 0.000 for the three dot products and both exports wrote -1
into Matched peaks count and Matched peaks percentage.

parse_mdpeak and parse_mdscan depended on that -1. They counted a row as a
candidate when all five score cells were present, and as scored when all five
were also non-negative, so a precursor-only row was a candidate but not
scored. Read against the new notation those cells are null, both counts
collapse to the same number, and the tuning panel loses the distinction it
shows as "MSP reference candidates" versus "MS/MS-scored candidates".

The candidate count now comes from the annotated name instead, which is
independent of the score notation: any name other than Unknown or empty is a
reference candidate, including the no MS2:, w/o MS2: and low score: prefixes.
The scored count keeps its meaning, rows with a spectral comparison, and both
parsers now share one _annotation_score_row helper so they agree. A row whose
comparison genuinely produced zero still counts as scored, because those
zeros are measurements.

Both notations now yield the same numbers, so the app works against an older
official Console package and a newer local source build alike.

The .mdscan candidate count changes from 2 to 1 in the test fixture, and that
is a correction. GcmsAnalysisMetadataAccessor writes -1 into every score
column when there is no match result at all, so the old rule counted an
Unknown GC-MS row as a reference candidate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant