Repository navigation
feat(UniPEFF): native TOPP-tool port of the C# UniPEFF UniProtKB→PEFF converter - #9649
Conversation
… converter
Adds a new TOPP tool `UniPEFF` that converts UniProtKB XML protein databases
(plain or gzipped) to PEFF 1.0 with full annotation routing — modifications
(\ModResPsi/\ModResUnimod/\ModRes), variants (\VariantSimple/\VariantComplex),
processed regions (\Processed), and disulfide bonds (\DisulfideBond in
Option B). Output is byte-exact with the standalone C# UniPEFF tool
(github.com/timosachsenberg/UniPEFF, feat/merge-half-cystines branch),
verified by diffing against that project's golden expected_A.peff /
expected_B.peff.
Half-cystines synthesized from <feature type="disulfide bond"> are merged
into the main modified-residue list in position-sorted order (regular mods
before half-cystines on ties, unknown positions last), so Option B's
\DisulfideBond=(idA,idB) IDs resolve to the correct merged-list entries.
Adds a new OpenMS library class `UniProtXMLFile` (FORMAT/) with a private
`UniProtXMLHandler` SAX subclass; bounded subtree scoping for <gene>,
<organism>, <comment type="alternative products">, and <feature>; manual
UTF-16→UTF-8 transcoding (Xerces's default goes through the local
C-runtime encoding which silently loses non-Latin codepoints).
A snapshot of UniProt's ptmlist.txt is bundled under
share/OpenMS/CHEMISTRY/UniProt_ptmlist.txt; canonical PSI-MOD/Unimod
names come from the already-bundled PSI-MOD.obo and an optional
unimod.obo. Test fixtures (comprehensive.xml + golden PEFFs +
test-specific ptmlist/PSI-MOD/Unimod files) are committed from the
upstream UniPEFF testdata/ directory.
Tests:
* TOPP_UniPEFF_1/2/3 — Option A, Option B (-AnnotationIdentifiers),
and gzipped-input round-trip; each is a byte-exact FuzzyDiff against
the upstream golden output.
* UniProtXMLFile_test — class unit test covering load() and
loadStreaming() against an inline UniProtKB fixture.
Author: David L. Tabb (UMC Groningen) — original C# tool. This port
preserves the algorithm and output byte format.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… -out Addresses two issues from a code review of the initial commit. 1. Memory: the original implementation buffered every parsed UniProtEntry plus its annotation lists in a std::vector<PreparedEntry>, so converting SwissProt or TrEMBL would scale linearly with database size (~5-50 GB resident for TrEMBL) even though UniProtXMLFile is SAX-streaming. Replace that with a per-prefix spool: each parsed-and-prepared entry's serialized PEFF text is written to a small temp file as we go, and the final output is the file header + DB-description blocks + concatenated per-prefix spools. Memory now stays bounded (one entry in flight at a time) regardless of input size; the on-disk spool is bounded by the output PEFF size. Entry ordering within each prefix is preserved (the byte-exact golden tests still pass). 2. Compressed -out: TOPPBase's format validation accepts `.peff.gz`/`.bz2`/ `.zip` (it strips the compression suffix and rechecks the inner type), but the writer is a plain std::ofstream, so we would silently write uncompressed bytes under a compressed file name and break downstream tools that auto-detect compression. Reject compressed suffixes upfront with ILLEGAL_PARAMETERS. All UniPEFF and UniProtXMLFile tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughIntroduces a new ChangesUniPEFF: UniProtKB XML → PEFF 1.0 TOPP Tool
Sequence Diagram(s)sequenceDiagram
participant CLI
participant UniPEFF
participant UniProtXMLFile
participant UniProtXMLHandler
participant PEFFWriter
CLI->>UniPEFF: run main
UniPEFF->>UniProtXMLFile: loadStreaming input
UniProtXMLFile->>UniProtXMLHandler: parse with callback
UniProtXMLHandler-->>UniPEFF: stream UniProtEntry
UniPEFF->>PEFFWriter: write PEFF headers and entries
PEFFWriter-->>CLI: output file
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (5)
src/openms/include/OpenMS/FORMAT/HANDLERS/UniProtXMLHandler.h (1)
35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd Doxygen documentation for the public type alias.
The
EntryCallbacktype alias is part of the public interface but lacks a Doxygen comment. As per coding guidelines, public types should be documented with@brief.📝 Proposed documentation addition
+ /// `@brief` Callback signature for streaming UniProtEntry objects. using EntryCallback = std::function<void(UniProtEntry&&)>;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/FORMAT/HANDLERS/UniProtXMLHandler.h` at line 35, The EntryCallback type alias lacks Doxygen documentation required by coding guidelines. Add a Doxygen comment block before the EntryCallback type alias definition that includes a `@brief` tag describing what this callback function type is used for. The comment should follow the standard Doxygen format with /// or /** */ style comments and concisely explain that this is a callback type for processing UniProt entries.Source: Coding guidelines
src/topp/UniPEFF.cpp (4)
772-772: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse OpenMS size types for
.size()casts.
seq_lenhere (and the equivalent casts at Lines 653 and 679) caststd::string::size()toint. As per coding guidelines, useSize/SignedSize(fromOpenMS/CONCEPT/Types.h) for STL container.size()values rather than rawint.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/topp/UniPEFF.cpp` at line 772, Replace the raw `int` type with OpenMS's Size or SignedSize types when casting the result of `.size()` on the sequence string. Locate the three instances of this pattern in the file: the seq_len variable at line 772 and the equivalent casts at lines 653 and 679. Change the static_cast from `int` to `SignedSize` (or `Size` if appropriate for the context), and ensure that the header `OpenMS/CONCEPT/Types.h` is included if it is not already present. This aligns the code with OpenMS coding guidelines for handling STL container size values.Source: Coding guidelines
102-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace
std::endlwith\nin log statements.This and the other
OPENMS_LOG_*statements (Lines 170, 536, 549, 558, 1106, 1110, 1115, 1132, 1144, 1145, 1200) usestd::endl, which forces a flush on every call. As per coding guidelines, avoidstd::endland use\ninstead for performance reasons.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/topp/UniPEFF.cpp` around lines 102 - 103, The OPENMS_LOG_WARN and other OPENMS_LOG_* statements throughout the UniPEFF.cpp file use std::endl which triggers unnecessary buffer flushes and impacts performance. Replace all instances of std::endl with \n in the log statements at the specified locations (the warning about ptmlist on lines 102-103, and all other OPENMS_LOG_* statements at lines 170, 536, 549, 558, 1106, 1110, 1115, 1132, 1144, 1145, and 1200). This change applies to all OPENMS_LOG_WARN, OPENMS_LOG_INFO, and similar logging macros in the file to ensure consistent performance-conscious logging practices.Source: Coding guidelines
688-704: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDead/misleading disulfide-ID reservation in
assignAnnotationIds.This block only does
++next_idon the by-reference counter, butprepareEntry(Lines 1012-1014) discards that localnext_idimmediately after the call, so nothing is persisted. The disulfide tuple IDs are actually recomputed independently inwritePeffEntry(Lines 939-964). The reservation here has no effect and the comments describing a "sentinel" are misleading.Either store the disulfide IDs here (and consume them in
writePeffEntryinstead of re-deriving), or drop this block to avoid the impression that it feeds emission.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/topp/UniPEFF.cpp` around lines 688 - 704, The disulfide ID reservation block in the `assignAnnotationIds` function increments `next_id` locally, but this counter is discarded immediately after the function returns in `prepareEntry`, making the reservation ineffective. The actual disulfide tuple IDs are re-derived independently in the `writePeffEntry` function, making this reservation block and its comments misleading. Either remove this disulfide block entirely from `assignAnnotationIds` to eliminate the misleading comments about ID reservation, or alternatively refactor to properly persist the disulfide IDs generated here and consume them in `writePeffEntry` instead of recomputing them independently.
15-24: 📐 Maintainability & Code Quality | 🔵 TrivialAdd explicit
#include <functional>forstd::function.
std::functionis used at lines 805-806 in thewriteModslambda but relies on a transitive include fromUniProtXMLFile.h. While this compiles, adding an explicit include improves clarity and robustness against future changes to transitive dependencies.♻️ Add the include
`#include` <algorithm> `#include` <cctype> `#include` <cstdint> `#include` <fstream> +#include <functional> `#include` <map>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/topp/UniPEFF.cpp` around lines 15 - 24, Add an explicit `#include <functional>` to the includes section in UniPEFF.cpp. Currently, `std::function` is used in the writeMods lambda but relies on a transitive include from UniProtXMLFile.h. Add the include in alphabetical order with the other standard library includes (it should go after cctype and before fstream based on the current include list) to make the dependency explicit and improve robustness against future changes to transitive dependencies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@doc/doxygen/public/TOPP.doxygen`:
- Around line 34-35: The TOPP_UniPEFF documentation entry only advertises
support for XML format but the tool also accepts gzipped UniProtKB XML files
(.xml.gz). Update the description of the TOPP_UniPEFF subpage entry to
explicitly mention that the tool converts both uncompressed and gzipped
UniProtKB XML formats to PEFF 1.0, ensuring users are aware of the supported
compressed input mode.
In `@src/topp/UniPEFF.cpp`:
- Around line 129-142: The DR key parsing is brittle when handling files with
CRLF line endings because std::getline leaves a trailing \r character. When the
code extracts PSI-MOD and Unimod values using fixed offsets with rest.substr(9,
rest.size() - 10) and rest.substr(8, rest.size() - 9), it drops the wrong
trailing character (the \r instead of the period), silently corrupting the
accession value. To fix this, trim all trailing whitespace and carriage returns
from the line string immediately after reading it with std::getline, before
extracting the rest substring and performing the PSI-MOD and Unimod parsing
logic.
---
Nitpick comments:
In `@src/openms/include/OpenMS/FORMAT/HANDLERS/UniProtXMLHandler.h`:
- Line 35: The EntryCallback type alias lacks Doxygen documentation required by
coding guidelines. Add a Doxygen comment block before the EntryCallback type
alias definition that includes a `@brief` tag describing what this callback
function type is used for. The comment should follow the standard Doxygen format
with /// or /** */ style comments and concisely explain that this is a callback
type for processing UniProt entries.
In `@src/topp/UniPEFF.cpp`:
- Line 772: Replace the raw `int` type with OpenMS's Size or SignedSize types
when casting the result of `.size()` on the sequence string. Locate the three
instances of this pattern in the file: the seq_len variable at line 772 and the
equivalent casts at lines 653 and 679. Change the static_cast from `int` to
`SignedSize` (or `Size` if appropriate for the context), and ensure that the
header `OpenMS/CONCEPT/Types.h` is included if it is not already present. This
aligns the code with OpenMS coding guidelines for handling STL container size
values.
- Around line 102-103: The OPENMS_LOG_WARN and other OPENMS_LOG_* statements
throughout the UniPEFF.cpp file use std::endl which triggers unnecessary buffer
flushes and impacts performance. Replace all instances of std::endl with \n in
the log statements at the specified locations (the warning about ptmlist on
lines 102-103, and all other OPENMS_LOG_* statements at lines 170, 536, 549,
558, 1106, 1110, 1115, 1132, 1144, 1145, and 1200). This change applies to all
OPENMS_LOG_WARN, OPENMS_LOG_INFO, and similar logging macros in the file to
ensure consistent performance-conscious logging practices.
- Around line 688-704: The disulfide ID reservation block in the
`assignAnnotationIds` function increments `next_id` locally, but this counter is
discarded immediately after the function returns in `prepareEntry`, making the
reservation ineffective. The actual disulfide tuple IDs are re-derived
independently in the `writePeffEntry` function, making this reservation block
and its comments misleading. Either remove this disulfide block entirely from
`assignAnnotationIds` to eliminate the misleading comments about ID reservation,
or alternatively refactor to properly persist the disulfide IDs generated here
and consume them in `writePeffEntry` instead of recomputing them independently.
- Around line 15-24: Add an explicit `#include <functional>` to the includes
section in UniPEFF.cpp. Currently, `std::function` is used in the writeMods
lambda but relies on a transitive include from UniProtXMLFile.h. Add the include
in alphabetical order with the other standard library includes (it should go
after cctype and before fstream based on the current include list) to make the
dependency explicit and improve robustness against future changes to transitive
dependencies.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c320ffa0-af0f-4dcd-8482-8b0e253c5fec
⛔ Files ignored due to path filters (1)
src/tests/topp/UniPEFF_1_input.xml.gzis excluded by!**/*.gz
📒 Files selected for processing (24)
CHANGELOGdoc/doxygen/public/TOPP.doxygenshare/OpenMS/CHEMISTRY/UniProt_ptmlist.txtsrc/openms/include/OpenMS/FORMAT/HANDLERS/UniProtXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/sources.cmakesrc/openms/include/OpenMS/FORMAT/UniProtXMLFile.hsrc/openms/include/OpenMS/FORMAT/sources.cmakesrc/openms/source/APPLICATIONS/ToolHandler.cppsrc/openms/source/FORMAT/HANDLERS/UniProtXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/sources.cmakesrc/openms/source/FORMAT/UniProtXMLFile.cppsrc/openms/source/FORMAT/sources.cmakesrc/tests/class_tests/openms/data/UniProtXMLFile_test.xmlsrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/UniProtXMLFile_test.cppsrc/tests/topp/CMakeLists.txtsrc/tests/topp/UniPEFF_1_input.xmlsrc/tests/topp/UniPEFF_1_output_A.peffsrc/tests/topp/UniPEFF_1_output_B.peffsrc/tests/topp/UniPEFF_1_psi-mod.obosrc/tests/topp/UniPEFF_1_ptmlist.txtsrc/tests/topp/UniPEFF_1_unimod.obosrc/topp/UniPEFF.cppsrc/topp/executables.cmake
…EFFFile round-trip)
Adds 7 new TOPP tests + extends PEFFFile_test:
TOPP_UniPEFF_4 -prefix custom -> byte-exact golden
TOPP_UniPEFF_5 -OmitMolecularProcessing -> byte-exact golden (no \Processed)
TOPP_UniPEFF_6 -OmitAminoAcidModifications -> byte-exact golden (no \ModRes*/\DisulfideBond)
TOPP_UniPEFF_7 -OmitSequenceVariations -> byte-exact golden (no \Variant*)
TOPP_UniPEFF_8_reject_gz -out foo.peff.gz -> WILL_FAIL (must reject)
TOPP_UniPEFF_9 compact.xml (no inter-element whitespace) -> byte-exact golden
PEFFFile_test [EXTRA] round-trip: loads the UniPEFF Option-A golden via
PEFFFile::load() and asserts field counts (entries, modifications,
variants, processed regions, half-cystine count), exercises
PEFFEntry::getSequence() and ::getProcessedSequence("PEFF:0001020").
Guards against future drift in either the UniPEFF emitter or the
PEFFFile parser — a divergence in either direction will fail here.
Test count: 19/19 PASS (was 8/8 before this commit).
The new omit/prefix goldens were produced by the UniPEFF binary itself
after the Option-A/B paths had been verified byte-exact against the
upstream C# tool's expected_*.peff. The compact.xml fixture is taken
verbatim from the upstream UniPEFF testdata/.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/PEFFFile_test.cpp (1)
1628-1628: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
TEST_FALSEfor boolean assertion consistency.Line 1628 should use
TEST_FALSE(headers[0].has_annotation_identifiers)instead ofTEST_EQUAL(..., false)to match class-test conventions.Suggested patch
- TEST_EQUAL(headers[0].has_annotation_identifiers, false) // Option A golden + TEST_FALSE(headers[0].has_annotation_identifiers) // Option A goldenAs per coding guidelines, “Prefer
TEST_TRUE(expr)andTEST_FALSE(expr)overTEST_EQUAL(expr, true)andTEST_EQUAL(expr, false)for boolean assertions.”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/PEFFFile_test.cpp` at line 1628, The assertion on line 1628 uses TEST_EQUAL(headers[0].has_annotation_identifiers, false) which does not follow the coding guidelines for boolean assertions. Replace this with TEST_FALSE(headers[0].has_annotation_identifiers) to match the class-test conventions that prefer TEST_TRUE and TEST_FALSE macros for boolean checks instead of TEST_EQUAL with boolean literals.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/tests/class_tests/openms/source/PEFFFile_test.cpp`:
- Line 1628: The assertion on line 1628 uses
TEST_EQUAL(headers[0].has_annotation_identifiers, false) which does not follow
the coding guidelines for boolean assertions. Replace this with
TEST_FALSE(headers[0].has_annotation_identifiers) to match the class-test
conventions that prefer TEST_TRUE and TEST_FALSE macros for boolean checks
instead of TEST_EQUAL with boolean literals.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9c6b583a-468f-47fe-850a-85445ea63fa8
📒 Files selected for processing (9)
src/tests/class_tests/openms/data/PEFFFile_UniPEFF_test.peffsrc/tests/class_tests/openms/source/PEFFFile_test.cppsrc/tests/topp/CMakeLists.txtsrc/tests/topp/UniPEFF_2_input_compact.xmlsrc/tests/topp/UniPEFF_2_output_compact.peffsrc/tests/topp/UniPEFF_2_output_omitmods.peffsrc/tests/topp/UniPEFF_2_output_omitproc.peffsrc/tests/topp/UniPEFF_2_output_omitvar.peffsrc/tests/topp/UniPEFF_2_output_prefix.peff
✅ Files skipped from review due to trivial changes (7)
- src/tests/topp/UniPEFF_2_output_compact.peff
- src/tests/topp/UniPEFF_2_input_compact.xml
- src/tests/topp/UniPEFF_2_output_omitproc.peff
- src/tests/topp/UniPEFF_2_output_omitvar.peff
- src/tests/topp/UniPEFF_2_output_prefix.peff
- src/tests/topp/UniPEFF_2_output_omitmods.peff
- src/tests/class_tests/openms/data/PEFFFile_UniPEFF_test.peff
…e parser
Addresses the tag-team Opus+codex code review:
1. (Opus P0) UniPEFF.cpp main_(): when a spool file failed to open, the
lambda ran `prefixes.push_back(prefix)` BEFORE the open attempt, and on
failure returned without registering the prefix in `spools`. Later
`spools[p].count` then default-constructed a `PrefixSpool` for that
prefix, yielding `# NumberOfEntries=0` and an empty ifstream — the file
could silently contain a malformed 0-entry DB block whose entries were
nowhere. Now we open the spool BEFORE registering the prefix, latch a
`spool_open_failed` flag in the parse callback, and abort the whole run
with CANNOT_WRITE_OUTPUT_FILE + a user-actionable message. Verified by
running `-out /dev/null` (exit code 5, clean error, no malformed output).
2. (codex P2 / option B) UniPEFF emitter now writes \PName as a single-element
list `\PName=(value)` rather than as a bare scalar. PEFF 1.0 allows both
forms for single-value keys; the list form is unambiguous to parse — a
scalar value containing a balanced parenthetical (legal under PEFF's
"only UNPAIRED parens must be escaped" rule, and the common case for
UniProt names like "Insulin (Fragment)" or "...(EC 2.7.10.2)...") would
otherwise be silently truncated by a paren-list-greedy reader. All
committed UniPEFF goldens regenerated to match. This breaks byte-exact
parity with the upstream C# UniPEFF on the PName key only; everything
else still byte-matches, and a real-data run on human SwissProt confirms
PEFFFile::load() now returns the full protein name.
3. (codex P2 / option C) PEFFFile parser: PName parsing now accepts BOTH
the list form and the scalar form. A value whose first non-whitespace
char is '(' is parsed as a paren list (existing behaviour); otherwise
the whole value is taken verbatim as the single name. This guards
against silent truncation of scalar PName values containing embedded
balanced parentheticals — the same shape the upstream C# UniPEFF emits.
A new PEFFFile_test [EXTRA] section covers the scalar case.
4. PEFFFile_test round-trip section now asserts e1.protein_names content
(not just size); without (2) above, it returned 'test' instead of the
full "Kitchen-sink protein (test) ..." name. The asserted string is the
escape-preserved form because parseParenList_ deliberately passes
PEFF escape sequences (\|, \\, \\)) through to the caller; un-escaping
is the caller's responsibility (matches existing behaviour on every
other parenthesized PEFF list).
All 19 UniPEFF/UniProtXMLFile/PEFFFile tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Five follow-ups from the tag-team review, none of which were blocking but
all of which improve robustness / UX / convention compliance:
1. (Opus P1) Snake_case TOPP flag names. Rename:
-AnnotationIdentifiers -> -annotation_identifiers
-OmitMolecularProcessing -> -omit_molecular_processing
-OmitAminoAcidModifications -> -omit_amino_acid_modifications
-OmitSequenceVariations -> -omit_sequence_variations
Matches the convention used by DatabaseFilter, DecoyDatabase, Digestor,
and the rest of the TOPP suite. All test CMake lines updated.
2. (Opus P1) Defensive SAX handler: UniProtXMLHandler now matches against
local_name (with fallback to qname when empty). Real UniProtKB XML
carries xmlns="http://uniprot.org/uniprot"; a future switch to
namespace-aware Xerces would deliver qname as "uniprot:entry" but
local_name as "entry". Today (namespace-off mode, Xerces default)
local_name is empty and we fall through to qname unchanged.
3. (Opus P1) toAscii() transliteration table now covers the full Latin
Extended-A block (U+0100..U+017F, ~120 entries) in addition to Latin-1
Supplement. Closes the silent-? gap with C# NFKD on common Slavic,
Baltic and Hungarian diacritics in UniProt taxonomy names (Č, Đ, Ł,
Ő, Ř, Š, Ť, Ű, Ž, …).
4. (Opus P1) OBO fallback warning now reports both total occurrences and
distinct accession count: "2886 modification name(s) across 37 distinct
accession(s) fell back to ...". Tells the user "your OBO is 37 terms
out of date" (actionable refresh) rather than the previous ambiguous
single number. A new OboFallbackTracker struct threads the set through
writePeffEntry() in place of the previous size_t counter.
5. (codex P3 / round-trip quality) PEFFFile::parseParenList_ now reverses
PEFF escape rules on the way out: \\, \|, \(, \) -> \, |, (, ).
Previously the function preserved the raw on-wire form, forcing every
consumer to do its own un-escape (or, more likely, silently exposing
escape sequences in PEFFEntry fields). New helper peffUnescape() in
PEFFFile.cpp's anonymous namespace is also applied to the new scalar
PName parsing path. The PEFFFile_test round-trip assertion updated to
the now-correct logical content ("Kitchen-sink protein (test) |
alpha\\beta :-)" instead of the previously-escaped form).
All 19 UniPEFF/UniProtXMLFile/PEFFFile tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…nList_ Codex pass #3 found a regression in commit fe011da. parseParenList_'s un-escape ran BEFORE the structured-tuple parsers' splitByPipeEscapeAware call, so a valid \ModRes=(1|MOD:00046|A\|B) became "1|MOD:00046|A|B" after un-escape, and the pipe split then treated the escaped pipe as a field separator — name became "A", optional_tag became "B". Fix: parseParenList_ returns items with PEFF escapes intact. Per-field un-escape is applied at each call site that takes the item as a scalar (PName list, AltAC, Proteoform) or inside each tuple parser AFTER splitByPipeEscapeAware has done its job: parseModification_ -> peffUnescape(name), peffUnescape(optional_tag) parseVariantSimple_ -> peffUnescape(optional_tag) parseVariantComplex_ -> peffUnescape(replacement), peffUnescape(optional_tag) parseProcessedRegion_ -> peffUnescape(name), peffUnescape(optional_tag) parseDisulfideBond_ -> peffUnescape(optional_tag) AltAC, Proteoform, PName (list & scalar) -> peffUnescape() at call site Numeric fields (positions), CV accessions (which never contain reserved chars per PEFF spec), and disulfide id strings stay raw. New regression test [EXTRA] section asserts a \ModResPsi=(1|MOD:00046|name with \\| pipe) tuple parses with name="name with | pipe" and optional_tag="" — would have caught fe011da's bug. All 19 UniPEFF/UniProtXMLFile/PEFFFile tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/openms/source/FORMAT/PEFFFile.cpp (1)
2177-2190: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winOnly treat
PNameas list form when the full value is a paren list.Line 2178 classifies any value whose first non-whitespace character is
(as list form. A valid scalar such as\PName=(Fragment) insulinstill gets truncated toFragment, leaving the balanced-parenthetical scalar bug partially unfixed.🐛 Proposed direction
- size_t first_non_ws = value.find_first_not_of(" \t"); - const bool is_list_form = (first_non_ws != std::string::npos && value[first_non_ws] == '('); + const bool is_list_form = isCompleteParenList_(value);Implement
isCompleteParenList_()so it returns true only when the value is entirely composed of adjacent parenthesized items plus surrounding whitespace. Otherwise, preserve the whole scalar and unescape it once.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/PEFFFile.cpp` around lines 2177 - 2190, The current logic for determining if a value is in list form uses only the first non-whitespace character check (checking if it's `(`), which incorrectly classifies scalar values like `(Fragment) insulin` as list form and truncates them. Create a new method called `isCompleteParenList_()` that validates the entire value is fully composed of adjacent parenthesized items plus surrounding whitespace. Replace the simple character-based check on line 2178 with a call to this new method, so that only truly complete paren lists are treated with parseParenList_(), while all other cases (including partial paren expressions) treat the whole value as a single scalar to be unescaped once.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/FORMAT/PEFFFile.cpp`:
- Around line 30-33: The code is double-unescaping PEFF fields because
splitByPipeEscapeAware() already decodes escape sequences like \\, \|, \(, and
\), but then peffUnescape() is called again on the already-decoded values.
Remove the peffUnescape() calls in parseModification_(), parseVariantSimple_(),
parseVariantComplex_(), and parseProcessedRegion_() that are applied after
splitting with splitByPipeEscapeAware(). Instead, use a preserving splitter (one
that does not decode escape sequences) before the per-field peffUnescape()
calls, so escaping is only handled once per field.
In `@src/tests/class_tests/openms/source/PEFFFile_test.cpp`:
- Around line 1642-1645: Update the stale comment in the test file that
incorrectly describes how escape handling is performed. The comment currently
states that parseParenList_'s un-escape pass reverses PEFF reserved-char
escapes, but this behavior has changed. Revise the comment to accurately reflect
that parseParenList_() now keeps escapes intact and the PName call site is
responsible for calling peffUnescape() to handle the escaping, ensuring the
comment points future readers to the correct layer where this logic is
performed.
---
Outside diff comments:
In `@src/openms/source/FORMAT/PEFFFile.cpp`:
- Around line 2177-2190: The current logic for determining if a value is in list
form uses only the first non-whitespace character check (checking if it's `(`),
which incorrectly classifies scalar values like `(Fragment) insulin` as list
form and truncates them. Create a new method called `isCompleteParenList_()`
that validates the entire value is fully composed of adjacent parenthesized
items plus surrounding whitespace. Replace the simple character-based check on
line 2178 with a call to this new method, so that only truly complete paren
lists are treated with parseParenList_(), while all other cases (including
partial paren expressions) treat the whole value as a single scalar to be
unescaped once.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 91707614-2c5e-4f9d-8eb3-df2b997cdbab
📒 Files selected for processing (5)
src/openms/source/FORMAT/HANDLERS/UniProtXMLHandler.cppsrc/openms/source/FORMAT/PEFFFile.cppsrc/tests/class_tests/openms/source/PEFFFile_test.cppsrc/tests/topp/CMakeLists.txtsrc/topp/UniPEFF.cpp
🚧 Files skipped from review as they are similar to previous changes (3)
- src/openms/source/FORMAT/HANDLERS/UniProtXMLHandler.cpp
- src/tests/topp/CMakeLists.txt
- src/topp/UniPEFF.cpp
Four findings from CodeRabbit's automated review of the post-Opus+codex state: 1. (Major) Double-unescape in structured-tuple parsers. `splitByPipeEscapeAware()` already decodes \\, \|, \(, \) per-field, so the peffUnescape() calls I added in commit fe011da to parseModification_, parseVariantSimple_, parseVariantComplex_ and parseProcessedRegion_ were running a SECOND decode pass. A legitimate on-wire "\\\\" (representing a literal "\\") would survive the split as "\\" and the redundant pass would collapse it to "\". Removed the redundant calls; the only place a per-field un-escape is still needed is parseDisulfideBond_ — its description field is extracted with a plain find('|')+substr, not via splitByPipeEscapeAware. New regression test [EXTRA] section asserts a `\ModResPsi=(1|MOD:00046|name with \\\\ backslashes)` tuple parses with name="name with \\ backslashes" (two literal backslashes preserved). 2. (Major) PName list-form classification too greedy. The previous check `is_list_form = value[first_non_ws] == '('` would misclassify a legitimate scalar starting with a parenthesised qualifier, e.g. "(R)-amino acid hydroxylase", as list form and silently truncate the name to "R". The new check requires the trimmed value to be a sequence of paren-balanced groups (starts with '(', ends with ')', every zero-depth point is immediately followed by another '(') — only then do we treat it as a list. 3. (Minor) ptmlist.txt DR parsing brittle for CRLF. The accession extraction uses fixed offsets `rest.size() - 10` / `-9`; a Windows-edited ptmlist.txt with CRLF line endings would shift the end of "rest" by one and corrupt the accession. Trim trailing whitespace (including '\r') before parsing. 4. (Trivial nitpicks) - Add Doxygen comment for the EntryCallback public type alias in UniProtXMLHandler.h. - Mention .xml.gz support in the TOPP.doxygen subpage one-liner. - Use TEST_FALSE instead of TEST_EQUAL(..., false). - Refresh stale escape-handling comment in PEFFFile_test. All 19 UniPEFF / UniProtXMLFile / PEFFFile tests pass (one new regression test added). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
CI's Doxygen_Warning_test failed on this PR with two classes of warnings introduced by the recent edits: 1. `@type`, `@description`, `@dataset` (3 sites in UniProtXMLFile.h) — I used these as XML attribute references in field doc comments (`feature/@type`, `feature/@description`, `entry/@dataset`), but Doxygen parses an `@` followed by an identifier as a command and warns "Found unknown command '@type'". Escape with backslash: `feature/\@type`, etc. 2. `\PName \GName \NcbiTaxId \TaxName \Length \SV \EV \PE \ID \AltAC \ModResPsi \ModResUnimod \ModRes \VariantSimple \VariantComplex \Processed \DisulfideBond` (16 sites in the UniPEFF @page block) — I listed these as bare PEFF descriptor-line tag names; Doxygen sees `\Word` and treats them as Doxygen commands. Double-backslash each so the renderer prints a literal `\X`: `\\PName`, `\\GName`, … Matches the pattern already used elsewhere in OpenMS (e.g. PEFFFile.h). No source behavior changes; this is purely a doc-comment escaping fix. All 19 UniPEFF / UniProtXMLFile / PEFFFile tests still pass locally. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…9650, #9651 (#9652) - Add PR reference (#9650) to the error-message improvement entry (was issue #9636 only) - Add PR reference (#9642) to ProSE end-of-search report entry - Add PR reference (#9643) to PSMFeatureExtractor andes support entry - Add PR reference (#9649) to UniPEFF new-tool entry - Add Build System entry for #9648: Boost.Spirit → charconv, 30-40% faster build - Add Build System entry for #9651: missing <thread> header fix for clang 21+ Claude-Session: https://claude.ai/code/session_01DdyZmN6J65umScGRherQ9W Co-authored-by: Claude <[email protected]>
…on as the library class UniPEFFConverter UniPEFF (UniProtKB XML -> PEFF 1.0; Timo Sachsenberg's port of David L. Tabb's C# tool, OpenMS develop b40fd92, OpenMS#9649) with UniProtXMLFile, its SAX handler, the bundled UniProt ptmlist and the tool's tests. The conversion moved unchanged from the tool into UniPEFFConverter, so that FLASHTnT can read UniProtKB XML; the tool keeps its options and calls it. This branch has no PEFF file type, so -out is not restricted by extension. Output byte-identical to the develop tool: the 9 TOPP golden tests (run by hand) and the E. coli K-12 proteome (Option A and B); UniProtXMLFile_test passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
.xmlor.xml.gz) to PEFF 1.0 with full annotation routing — modifications (\ModResPsi/\ModResUnimod/\ModRes), variants (\VariantSimple/\VariantComplex), processed regions (\Processed), and disulfide bonds (\DisulfideBondin Option B).UniProtXMLFile(FORMAT/) — first native UniProtKB XML reader in OpenMS — with a privateUniProtXMLHandlerSAX subclass. Streams entries into a parser-neutralUniProtEntryPOD; transparent.xml.gzsupport via the existingCompressedInputSource.feat/merge-half-cystinesbranch). Output is byte-exact with the upstream tool's goldenexpected_A.peff/expected_B.pefffor every annotation tag except\PName(see "Deliberate divergence from C# UniPEFF" below).PEFFFileparser improvements as drive-by fixes: (a) accepts the scalar\PName=value (with parens)form that the C# UniPEFF emits, (b) reverses PEFF escape sequences (\\,\|,\(,\)) inparseParenList_so consumers see logical content not raw on-wire form.Approach
<feature type="disulfide bond">are merged into the main modified-residue list in position-sorted order (regular mods before half-cystines on ties; unknown positions last). Option B's\DisulfideBond=(idA,idB)IDs therefore resolve cleanly to the correct merged-list entries.<out>.sp.tmp,<out>.tr.tmp) as we go. After parsing, the final output is<file header> + <DB blocks per prefix> + <concatenated per-prefix spools>. Memory stays bounded (one entry in flight) regardless of input size; tested at 42 MB peak RSS on a 1 GB-uncompressed human SwissProt input. The spool is opened before registering the prefix so an open failure aborts the run cleanly rather than emitting a malformed 0-entry DB block.ptmlist.txtis bundled atshare/OpenMS/CHEMISTRY/UniProt_ptmlist.txt(overridable via-ptmlist).share/OpenMS/CHEMISTRY/PSI-MOD.oboand an optionalunimod.obo; both overridable (-psimod_obo,-unimod_obo).xercesc::XMLString::transcode, which silently goes through the local C-runtime encoding and loses non-Latin codepoints. Element-name matching useslocal_namewith fallback toqname, robust to either namespace-aware or namespace-unaware Xerces configurations.?.UniPEFF.cpp, not viaPEFFFile::writeStart) reproduces UniPEFF's exact byte format: unpaired-paren-only escape, 60-char sequence wrap, per-prefixsp/trDB blocks, and the bucketed\ModResPsi/\ModResUnimod/\ModRessplit.Deliberate divergence from C# UniPEFF:
\PNameemissionThe C# tool emits
\PName=Insulin (Fragment)as a bare scalar. This is legal under PEFF 1.0 (the spec permits both scalar and list forms for single-value keys), but a paren-list-greedy reader (including the OpenMSPEFFFile) can silently truncate it to"Fragment". To make the output unambiguous, this port emits\PName=(value)as a single-element list. This is the only annotation tag where output is not byte-identical with the C# tool. Companion fix inPEFFFile: parser now also accepts the scalar form (a value whose first non-whitespace char is not(is taken verbatim), so legacy C# UniPEFF output continues to round-trip cleanly.CLI
-in <file>.xmlor.xml.gz) — required-out <file>.gz/.bz2/.zip)-ptmlist <file>-psimod_obo <file>-unimod_obo <file>-prefix <p>-dbversion <v># DbVersion=PEFF header-annotation_identifiers\DisulfideBond)-omit_molecular_processing\Processed-omit_amino_acid_modifications\ModRes*and\DisulfideBond-omit_sequence_variations\Variant*Tests
All passing (
ctest -R "TOPP_UniPEFF|UniProtXMLFile_test|PEFFFile_test"→ 19/19):TOPP_UniPEFF_1+_outFuzzyDiffagainst committed goldenTOPP_UniPEFF_2+_out-annotation_identifiers), byte-exact against committed goldenTOPP_UniPEFF_3+_outTOPP_UniPEFF_4+_out-prefix custom— single DB block, all entries under>custom:TOPP_UniPEFF_5+_out-omit_molecular_processing—\ProcessedabsentTOPP_UniPEFF_6+_out-omit_amino_acid_modifications—\ModRes*and\DisulfideBondabsentTOPP_UniPEFF_7+_out-omit_sequence_variations—\Variant*absentTOPP_UniPEFF_8_reject_gz-out foo.peff.gz—WILL_FAIL TRUEguards the rejectionTOPP_UniPEFF_9+_outcompact.xml) — guards against future regressionTOPPWRITEINI_UniPEFF_SectionName/TOPPWRITECTD_UniPEFFUniProtXMLFile_testPEFFFile_test [EXTRA]round-tripPEFFFile::load()and asserts entry counts + un-escaped protein name content + 18 modifications (5 half cystines) + 2 simple + 5 complex variants + 5 processed regions +getSequence()/getProcessedSequence("PEFF:0001020").PEFFFile_test [EXTRA]scalar PName\PName=Insulin (Fragment)form.Real-data smoke test (human SwissProt)
\DisulfideBond(35:0,3)(36:1,5)(37:2,4)= 31-96, 43-109, 95-100PEFFFile::load()round-trip on 20K-entry output2886 modification name(s) across 37 distinct accession(s)Code review follow-ups
Commit
1b9c029873— first codex passMemory + compressed
-outrejection. Per-prefix spool replaces in-memory buffering;.gz/.bz2/.zipsuffixes are rejected upfront withILLEGAL_PARAMETERS.Commit
65b72363f0— Opus P0 + codex PNameSpool-open failure no longer silently emits malformed 0-entry DB blocks. UniPEFF emits
\PName=(value)in list form; PEFFFile parser also accepts scalar form.Commit
fe011dac11— all remaining deferred itemslocal_name(withqnamefallback) — robust to namespace-aware/unaware Xerces.PEFFFile::parseParenList_now reverses PEFF escape rules — consumers see logical content not raw on-wire form.Notes for reviewers
UniProt_ptmlist.txtis a snapshot of the upstream UniProt CV file; refresh is a docs/maintenance task, not a code change.xercesc::XMLString::transcode— see the comment block inxmlchToString()for the rationale.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes