Skip to content

Add opt-in support for chimeric ProForma parsing#210

Merged
levitsky merged 3 commits into
levitsky:masterfrom
josiehong:feature/chimeric-proforma
Jun 24, 2026
Merged

Add opt-in support for chimeric ProForma parsing#210
levitsky merged 3 commits into
levitsky:masterfrom
josiehong:feature/chimeric-proforma

Conversation

@josiehong

@josiehong josiehong commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Adds opt-in parsing support for chimeric ProForma strings using chimeric=True related to #209.

This keeps the default single-sequence behavior unchanged while allowing top-level + to separate chimeric peptidoform components when explicitly requested.

Changes

  • Add chimeric option to Parser, proforma.parse, and ProForma.parse.
  • Return a list of parse results / ProForma objects when chimeric=True.
  • Share fixed modifications, isotope labels, and peptidoform names across chimeric components.
  • Preserve the current default behavior for +, with an error message suggesting chimeric=True.
  • Add tests for opt-in parsing, shared metadata, empty components, charge/adduct boundaries, and shared fixed modifications.
  • Document chimeric parsing and component-wise use with existing downstream APIs.

@mobiusklein

Copy link
Copy Markdown
Contributor

@levitsky can you please approve workflow runs for this PR? I don't have permission.

Comment thread tests/test_proforma.py
self.assertEqual(forms[1].composition(), Composition(sequence='camCcamC', aa_comp=aa_comp))

def test_chimeric_shared_names_and_isotopes(self):
parsed = parse('(>sample)<13C>AC+CC', chimeric=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is tricky. Names defined with > and >> are specific to a single peptidoform and peptidoform ion respectively. Only >>> names apply to all peptidoforms in the set. This is section 8.2 of the forthcoming specification: https://docs.google.com/document/d/1HaSOMNmdFCxy0G6lq1Yci03z-4esmQoe_hSyoqTeRnc/edit?tab=t.0

So AC would have the name sample, but CC would have no name.

The example from the specification is (>Trypsin)AANSIPYQVSLNS+(>Keratin)AKEQFERQTA

@mobiusklein mobiusklein left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great other than the name sharing thing (which is trivial and can be fixed at a later date).

I'm happy to bundle that fix in with other changes when I do a coverage overhaul.

@levitsky levitsky merged commit 0f2116b into levitsky:master Jun 24, 2026
15 checks passed
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.

3 participants