Repository navigation
UniPEFF: implement selective disulfide labeling (issue #9829) - #9964
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Review follow-up on #9964: UniProtXMLHandler accepts any begin/end value, so a malformed entry could get labels and a \DisulfideBond tuple referencing a residue outside the sequence. Pairs with a known endpoint past the sequence end are now invalidated (with a warning) before either id-assignment pass, in both the default and -annotation_identifiers modes; unknown ('?') endpoints remain valid as before. The half-cystine ModRes tuples themselves are still written, consistent with all other modifications. No output change for well-formed input (all goldens byte-identical). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XqvdSzxdXr7JVMczmX9d6Y
UniPEFF previously emitted \DisulfideBond only under -annotation_identifiers (Option B); a default run annotated half-cystines without saying which ones pair up. Default output now labels the half-cystines of each documented intrachain bond in bond order -- the k-th bond labels its begin/end residues 2k-1 and 2k inside \ModResPsi and emits \DisulfideBond=(k:2k-1,2k) -- while interchain half-cystines and all other annotations stay unlabeled. For P00711 this produces \DisulfideBond=(1:1,2)(2:3,4)(3:5,6)(4:7,8), matching the output requested in the issue verbatim. Both labeling modes now share one id model (annotation_id with a kNoId sentinel, stamped by one assignment pass per mode) and one mode-agnostic writer: Option B ids switch from 0-based to 1-based, the bond tuples' ids are stored during assignment instead of being re-derived at write time via max(all ids)+1, and the dead id-reservation loop is gone. Option B output therefore intentionally diverges from the upstream C# golden (all ids shift by +1). Golden files regenerated by running the tool; PEFFFile round-trips the new mixed labeled/unlabeled form without parser changes (covered by new pins and a store->reload assertion in PEFFFile_test). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XqvdSzxdXr7JVMczmX9d6Y
Review follow-up on #9964: UniProtXMLHandler accepts any begin/end value, so a malformed entry could get labels and a \DisulfideBond tuple referencing a residue outside the sequence. Pairs with a known endpoint past the sequence end are now invalidated (with a warning) before either id-assignment pass, in both the default and -annotation_identifiers modes; unknown ('?') endpoints remain valid as before. The half-cystine ModRes tuples themselves are still written, consistent with all other modifications. No output change for well-formed input (all goldens byte-identical). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XqvdSzxdXr7JVMczmX9d6Y
Repo guideline (AGENTS.md): avoid std::endl for performance. Only the line added in 00f3ce5 is changed; pre-existing warnings keep their style. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XqvdSzxdXr7JVMczmX9d6Y
9fbff8f to
e8c04ab
Compare
Dropping connectivity for disulfide pairs with an endpoint beyond the sequence end changes output in both labeling modes, but no fixture exercised it. UniPEFF_3_input_disulfide_bounds.xml has a bond ending past the sequence, a bond with both endpoints past it, a bond ending exactly on the last residue and an in-range bond. TOPP_UniPEFF_10 (default mode) and TOPP_UniPEFF_11 (-annotation_identifiers) pin that the first two keep their half-cystine tuples but get no labels, no \DisulfideBond tuple and no bond number, while the other two are kept. Turning the check's '>' into '>=', or removing the check, fails both tests; the existing goldens caught neither. The tool docs and comments equated <begin>/<end> bonds with intrachain bonds and single-position ones with interchain bonds. UniProt also writes bonds between chains of one precursor (insulin's "Interchain (between B and A chains)") as <begin>/<end>, and those are, correctly, reported. Describe the rule by UniProt location instead, and update the stale comment on DisulfidePairItem::valid, which the range check now clears. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FAJgN8xNB3ZWbR51q1o79t
timosachsenberg
left a comment
There was a problem hiding this comment.
Rebased onto develop (79d6d8a) and reviewed.
Rebase
- Only
CHANGELOGconflicted: develop shortened the "New tools" entries, so the UniPEFF bullet now follows that style and keeps #9829. UniPEFF.cppmoved tosrc/topp/UniPEFF/in #10239, and this PR's changes carried over unchanged.- I built it locally and all UniPEFF,
PEFFFile_testandUniProtXMLFile_testtests pass. The real P00711 entry gives\DisulfideBond=(1:1,2)(2:3,4)(3:5,6)(4:7,8), as the issue asks.
Added in a95f7b4
- New tests
TOPP_UniPEFF_10/_11, withUniPEFF_3_input_disulfide_bounds.xml. They cover the out-of-range check in both modes: a bond ending past the sequence, a bond with both ends past it, a bond ending on the last residue, and an in-range bond. Changing the check's>to>=, or removing the check, fails both tests; the existing goldens caught neither. - Docs and comments: they now describe which bonds get connectivity by their UniProt location (
<begin>/<end>vs. a single<position>) instead of "intrachain" vs. "interchain". Insulin-style "Interchain (between B and A chains)" bonds are written as<begin>/<end>and are (correctly) reported. I also fixed the outdated comment onDisulfidePairItem::valid.
Needs a decision (inline comments)
The default output now carries annotation ids, which:
- breaks Comet's PEFF reader,
- lacks the
HasAnnotationIdentifiers=trueheader the spec requires, and - reuses the same ids for bonds and half-cystines within an entry.
All three follow from the output format requested in #9829, so they need @dtabb73's input. The inline comments also cover the Option B renumbering and one optional nit.
Other notes
- UniProt sometimes lists the same bond twice with different evidence (P01857: 144–204 and 250–308), and each copy now becomes its own
\DisulfideBondtuple. The duplicate half-cystine tuples existed before this PR. - The UniProt bond description isn't copied into the
\DisulfideBondoptional tag (the spec's insulin example uses|between chains). This could be a follow-up; it's not a blocker. - #9829 was closed on Sep 21 with a comment saying develop already resolves it. That's not the case: develop's default output has no
\DisulfideBond, which is exactly what the reporter found. The issue should be reopened, or this PR should say "Fixes #9829". - The PR description still names the old path
src/topp/UniPEFF.cppand says Option B is unchanged.
Generated by Claude Code
The fixture added in the previous commit copied the simplified shape of the existing UniPEFF inputs and did not validate against uniprot.xsd: it lacked the entry's created/modified dates, a <reference>, and the sequence's checksum/modified attributes. Add them, plus the UniProt namespace, so `xmllint --schema uniprot.xsd` accepts it. Sequence mass and CRC64 checksum are computed the way UniProt does (the same code reproduces the published values of P00711, P01308 and P01857). The only intentional defect left is semantic (endpoints beyond the sequence end), which the schema cannot express. UniPEFF output is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FAJgN8xNB3ZWbR51q1o79t
UniPEFF already dropped variants and processed regions that lie beyond the sequence end (with a warning) but wrote modifications at any position. With the disulfide-bounds fixture this produced \ModResPsi tuples at 31, 35 and 150 on a 30-residue protein, which PEFF 1.0 (3.3.10/3.3.11) calls an error in the file and which OpenMS' own PEFFFile reader warns about. The writer now omits such modifications with a warning, and the -annotation_identifiers id pass skips them too, so ids stay consecutive. Disulfide pairs with such an endpoint were already invalidated, so no \DisulfideBond tuple can reference an omitted half-cystine. Only the new fixture's goldens change: the out-of-range half-cystines are gone, and in Option B the bond ids move from 10/11 to 7/8. All other UniPEFF goldens are byte-identical, and both new goldens now load through PEFFFile without warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FAJgN8xNB3ZWbR51q1o79t
This comment was marked as resolved.
This comment was marked as resolved.
Resolves the CHANGELOG conflict with #10255, which reworded the FeatureLinkerWNet bullet next to the UniPEFF bullet: keep both changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FAJgN8xNB3ZWbR51q1o79t
The -annotation_identifiers help text said that by default only the half-cystines of disulfide bonds get ids. The \DisulfideBond tuples get one too: bond k is labeled k, its half-cystines 2k-1 and 2k. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0154SXArrtJiK1yY4Qxfc371
Resolves the CHANGELOG conflict with #10278, which added the #10255 citation to the FeatureLinkerWNet bullet next to the UniPEFF bullet: keep both changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0154SXArrtJiK1yY4Qxfc371
timosachsenberg
left a comment
There was a problem hiding this comment.
Reviewed the current head and the existing unresolved threads. I would hold this PR before merging. The range checks and regression tests look sound, and CI passes, but two output-format decisions still affect correctness:
- Default output now puts
id:prefixes on half-cystines and bonds without# HasAnnotationIdentifiers=true, and each bond IDkduplicates a half-cystine ID. PEFF annotation identifiers are entry-wide unique; the PSI's valid insulin example sets the header flag and numbers bond tuples after the other annotations. Setting the flag alone cannot repair the collisions. The OpenMS store/load round-trip shows that our reader accepts the output, not that it is interoperable PEFF. - Changing the default
\ModResPsipositions from25|…to1:25|…makes Comet's PEFF parser interpret the site as residue 1. That silently changes modification placement for users searching a UniPEFF output directly with Comet. This is already documented in the open inline thread; please settle whether connectivity is opt-in or whether a default-format change with that incompatibility is intended, and coordinate it with #9829's reporter.
The literal (1:1,2) example in #9829 conflicts with globally unique IDs, so the format choice needs to be explicit rather than inferred from that example. Also, when integrating #9966, both branches currently register TOPP_UniPEFF_10/_11 and modify the same golden PEFF files; renumber the tests and combine the goldens after the first merge. I am summarizing the already-open blockers here rather than duplicating their inline comments.
|
Decisions:
|
…ault output Settles the open format questions of this PR as decided in the review discussion: the default output keeps its disulfide labels (the Comet incompatibility is accepted for now), and the bond labels no longer have to start at 1. PEFF 1.0 section 3.4.2 makes annotation ids optional per annotation, but requires them to be unique within an entry and requires HasAnnotationIdentifiers=true for a database that uses them. The default mode broke both rules: bond k was labeled k, reusing an id of its own half-cystines, and no header declared the ids. - Of K reported bonds, bond k now gets the id 2K+k; its half-cystines keep 2k-1 and 2k. The ids of an entry are 1..3K, all unique. P00711: \DisulfideBond=(9:1,2)(10:3,4)(11:5,6)(12:7,8). - A database block declares HasAnnotationIdentifiers=true when one of its entries carries ids. -annotation_identifiers still declares it for every block. - Option B output is unchanged. Expected outputs: the default-mode goldens with disulfide bonds get the new bond ids and the header line in the block that holds the bonded entry (sp, or the forced prefix); the tr block, -omit_amino_acid_modifications and the compact input stay without ids and without the header. PEFFFile_test checks the new bond ids and the per-block header flag. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0154SXArrtJiK1yY4Qxfc371
PEFF 1.0 section 3.4.2 describes annotation identifiers as "a non-negative consecutive integer identifier (0,1,2,3,...) unique within each protein entry", and the PSI's valid insulin example numbers its annotations from 0. UniPEFF on develop and the C# UniPEFF did the same for -annotation_identifiers; this PR had switched to 1. - -annotation_identifiers (Option B) numbers from 0 again, so its output is the same as on develop: UniPEFF_1_output_B.peff is byte-identical to develop's again. - Default mode: of K reported bonds, bond k (counting from 0) labels its half-cystines 2k and 2k+1 and is itself labeled 2K+k, so an entry's ids are 0..3K-1. P00711: \DisulfideBond=(8:0,1)(9:2,3)(10:4,5)(11:6,7). Expected outputs and PEFFFile_test shift every id down by one; the header flags are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0154SXArrtJiK1yY4Qxfc371
Brings in #10266 (isoform-scoped UniProt features are no longer applied to the canonical entry). Conflict in src/topp/UniPEFF/UniPEFF.cpp at the writePeffEntry() call: keep develop's isoform_scoped_tracker.add() and this branch's writePeffEntry() signature, which no longer takes option_b. TOPP_UniPEFF_12 (new on develop) runs in default mode on an entry with a canonical 6-18 disulfide bond, so its expected output UniPEFF_4_output_location_sequence.peff gains the half-cystine labels (0:6|...)(1:18|...), \DisulfideBond=(2:0,1) and "# HasAnnotationIdentifiers=true" in the sp block header. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0154SXArrtJiK1yY4Qxfc371
|
@claude merge once ci passes |
Brings in #9964 (selective disulfide labeling), which also registered TOPP_UniPEFF_10/_11 and changed the same expected outputs. - Tests: develop keeps TOPP_UniPEFF_10/_11 (disulfide bounds); the isoform tests become TOPP_UniPEFF_13 (-omit_isoforms) and TOPP_UniPEFF_14 (isoform expansion). - UniPEFF.cpp: default-mode disulfide labels are assigned before the isoforms are reconstructed. A database block is flagged HasAnnotationIdentifiers by its canonical entries only; isoform entries carry no annotations. - UniPEFF_2_output_omitiso.peff: the -omit_isoforms output equals the default output without isoform expansion, so it gains #9964's labels and is now identical to develop's UniPEFF_1_output_A.peff. - The auto-merged UniPEFF_1_output_A.peff and UniPEFF_2_output_omitproc/ omitvar/prefix.peff hold develop's canonical entries and headers plus this branch's isoform entries and NumberOfEntries (checked entry by entry). - CMakeLists: drop the claim that annotation identifiers are 1-based; they are 0-based on develop, in the code and in the expected outputs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015br53P8rFQMnErUa4SiMSX
Description
Fixes #9829.
UniPEFF turns each UniProt
disulfide bondfeature into half-cystine modifications (MOD:00798). Ondevelop, it writes which half-cystines are bonded to each other (\DisulfideBond) only with-annotation_identifiers, so the default output loses the connectivity. With this PR the default output reports it, as #9829 asks, with the bond ids numbered after the half-cystines so that every id is unique, as PEFF requires. P00711 has bonds 25–139, 47–130, 80–96 and 92–110 (excerpt;…isMOD:00798|half cystine):The database header then declares
# HasAnnotationIdentifiers=true.#9829 was closed on Sep 21 as already resolved on
develop. It isn't: ondevelop, the default output the reporter ran still has no\DisulfideBond.Default mode (no
-annotation_identifiers)2kand its end half-cystine2k+1, and is written as(2K+k:2k,2k+1). An entry's ids are 0..3K-1, all unique (PEFF 1.0 §3.4.2). Labels follow bond order, so they are not ascending in the position-sorted\ModResPsi.# HasAnnotationIdentifiers=truewhen one of its entries carries ids; blocks without ids don't (PEFF sets the flag per database). InUniPEFF_1_output_A.peff, thespblock declares it and thetrblock doesn't.<begin>/<end>, i.e. both half-cystines are in this sequence. That covers intrachain bonds and bonds between chains cut from the same precursor (insulin's "Interchain (between B and A chains)"). A bond given as a single<position>(partner in another molecule) gets no connectivity, and its half-cystine is written unlabeled.?) endpoint is still reported: inUniPEFF_1_output_A.peff, the second bond,(5:2,3), pairs(2:?|MOD:00798|half cystine)with(3:90|…).-annotation_identifiers(PEFF Option B)Unchanged for well-formed input: every annotation tuple gets a global sequential id starting at 0, with the
\DisulfideBondtuples numbered last, and every database block declaresHasAnnotationIdentifiers=true.UniPEFF_1_output_B.peffis byte-identical todevelop. The bond ids are now assigned together with all other ids instead of being re-derived by the writer, so they only differ fromdevelopfor malformed input (next section).Positions beyond the sequence end (malformed input, both modes)
\DisulfideBondtuple, no bond number and, in default mode, no half-cystine labels. UniPEFF logs a warning. A bond ending on the last residue is kept.Implementation (
src/topp/UniPEFF/UniPEFF.cpp)kNoIdsentinel, and the writer prints anid:prefix exactly for tuples that have one, sowritePeffEntry()no longer takesoption_b.assignDisulfideLabels()(default mode) orassignAnnotationIds()(Option B) assigns all ids before writing, including each bond's own id (DisulfidePairItem::annotation_id). The writer no longer re-derives bond ids from the highest id.hasAnnotationIds()); its database block then getsHasAnnotationIdentifiers=true. Option B still sets it for every block.invalidateOutOfRangeDisulfides()runs after the half-cystine merge and before either id pass. With UniPEFF: do not apply isoform-scoped features to the canonical entry #10266, features scoped to other isoforms are dropped before both, so they never get ids.-annotation_identifiershelp text andCHANGELOGupdated.Tests
UniPEFF_1_output_A.peff,UniPEFF_2_output_{omitproc,omitvar,prefix}.peff,PEFFFile_UniPEFF_test.peffandUniPEFF_4_output_location_sequence.peff(TOPP_UniPEFF_12, added by UniPEFF: do not apply isoform-scoped features to the canonical entry #10266). They gain the labels,\DisulfideBondand the header flag in the block of the bonded entry. The Option B outputUniPEFF_1_output_B.peffis unchanged. The outputs without bonds (-omit_amino_acid_modifications, the compact input) keep no ids and no flag.TOPP_UniPEFF_10(default mode) andTOPP_UniPEFF_11(Option B) run onUniPEFF_3_input_disulfide_bounds.xml. This schema-valid UniProt entry has a bond ending past the sequence, a bond with both ends past it, a bond ending on the last residue and an in-range bond. Removing any of the new range checks fails at least one of the two tests.PEFFFile_testchecks the default-mode labels, the bond tuples and the per-block header flag, and that the labels and bonds survive aPEFFFilestore/load round-trip.Format decisions
(2:47|…)as residue 2 instead of Cys47, and(2:?|…)inUniPEFF_1_output_A.peffas residue 2, where it used to skip?. Only Comet run directly on UniPEFF output is affected; OpenMS's CometAdapter setspeff_format = 0.(1:1,2)…in UniPEFF disulfide reporting #9829, so ids are unique within an entry, and the header declares them (both required by PEFF 1.0 §3.4.2). Starting at 0 matches the spec ("0,1,2,3,…") and its insulin example, the C# UniPEFF anddevelop's Option B.\DisulfideBond. The bond's UniProt description isn't copied into the optional tag (the spec's insulin example has|between chains), and doesn't need to be.Possible follow-ups (not in this PR)
\DisulfideBondtuple. The duplicate half-cystine tuples predate this PR.TOPP_UniPEFF_10/_11and changes the same expected outputs, so whichever PR merges second needs its tests renumbered and the expected outputs combined.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_0154SXArrtJiK1yY4Qxfc371