mzannotate 0.1.0

Handle fragmentation of (complex) peptidoforms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
use std::{
    borrow::Cow,
    cmp::Ordering,
    fmt::{Debug, Display},
};

use itertools::Itertools;
use serde::{Deserialize, Serialize};
use thin_vec::ThinVec;

use crate::fragment::DiagnosticPosition;
use mzcore::{
    chemistry::SatelliteLabel,
    glycan::{BackboneFragmentKind, GlycanPosition, GlycanSelection, MonoSaccharide},
    prelude::*,
    sequence::{PeptidePosition, SemiAmbiguous},
};

/// A variant, meaning ±H so z· is variant +1 is z+H
pub type Variant = i8;

/// The possible types of fragments
#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[expect(non_camel_case_types)]
pub enum FragmentType {
    /// a
    a(PeptidePosition, Variant),
    /// b
    b(PeptidePosition, Variant),
    /// c
    c(PeptidePosition, Variant),
    /// d a position, originating amino acid, distance from a break, variant,
    d(PeptidePosition, AminoAcid, u8, Variant, SatelliteLabel),
    /// v
    v(PeptidePosition, AminoAcid, u8, Variant),
    /// w
    w(PeptidePosition, AminoAcid, u8, Variant, SatelliteLabel),
    /// x
    x(PeptidePosition, Variant),
    /// y
    y(PeptidePosition, Variant),
    /// z
    z(PeptidePosition, Variant),
    // glycan A fragment (Never generated)
    //A(GlycanPosition),
    /// glycan B fragment
    // B(GlycanPosition),
    // glycan C fragment (Never generated)
    //C(GlycanPosition),
    // glycan X fragment (Never generated)
    //X(GlycanPosition),
    /// glycan Y fragment, generated by one or more branches broken
    Y(Vec<GlycanPosition>),
    // glycan Z fragment (Never generated)
    // Z(GlycanPosition),
    /// B glycan fragment, potentially with additional Y breakages
    B {
        /// The root break
        b: GlycanPosition,
        /// The branch breakages
        y: ThinVec<GlycanPosition>,
        /// All branches that are not broken
        end: ThinVec<GlycanPosition>,
    },
    /// A B or internal glycan fragment for a glycan where only the composition is known, also saves the attachment (AA + sequence index)
    BComposition(
        Vec<(MonoSaccharide, isize)>,
        Option<(AminoAcid, SequencePosition)>,
    ),
    /// A B or internal glycan fragment for a glycan where only the composition is known, also saves the attachment (AA + sequence index)
    YComposition(
        Vec<(MonoSaccharide, isize)>,
        Option<(AminoAcid, SequencePosition)>,
    ),
    /// Immonium ion
    Immonium(Option<PeptidePosition>, SequenceElement<SemiAmbiguous>),
    /// Precursor with amino acid side chain loss
    PrecursorSideChainLoss(PeptidePosition, AminoAcid),
    /// Diagnostic ion for a given position
    Diagnostic(DiagnosticPosition),
    /// An internal fragment, potentially with the named bonds that resulted in this fragment
    Internal(
        Option<(BackboneNFragment, BackboneCFragment)>,
        PeptidePosition,
        PeptidePosition,
    ),
    /// An unknown series, with potentially the series number
    Unknown(Option<usize>),
    /// precursor
    #[default]
    Precursor,
}

impl Ord for FragmentType {
    #[allow(clippy::match_same_arms)] // This ordering is helpful for human readers
    fn cmp(&self, other: &Self) -> Ordering {
        // Sort of type first (precursor/abcxyz/dw/v)
        match (self, other) {
            // Peptide
            (Self::Precursor, Self::Precursor) => Ordering::Equal,
            (Self::Precursor, _) => Ordering::Less,
            (_, Self::Precursor) => Ordering::Greater,
            (Self::a(s, sv), Self::a(o, ov)) => s.cmp(o).then(sv.cmp(ov)),
            (Self::a(_, _), _) => Ordering::Less,
            (_, Self::a(_, _)) => Ordering::Greater,
            (Self::b(s, sv), Self::b(o, ov)) => s.cmp(o).then(sv.cmp(ov)),
            (Self::b(_, _), _) => Ordering::Less,
            (_, Self::b(_, _)) => Ordering::Greater,
            (Self::c(s, sv), Self::c(o, ov)) => s.cmp(o).then(sv.cmp(ov)),
            (Self::c(_, _), _) => Ordering::Less,
            (_, Self::c(_, _)) => Ordering::Greater,
            (Self::x(s, sv), Self::x(o, ov)) => s.cmp(o).then(sv.cmp(ov)),
            (Self::x(_, _), _) => Ordering::Less,
            (_, Self::x(_, _)) => Ordering::Greater,
            (Self::y(s, sv), Self::y(o, ov)) => s.cmp(o).then(sv.cmp(ov)),
            (Self::y(_, _), _) => Ordering::Less,
            (_, Self::y(_, _)) => Ordering::Greater,
            (Self::z(s, sv), Self::z(o, ov)) => s.cmp(o).then(sv.cmp(ov)),
            (Self::z(_, _), _) => Ordering::Less,
            (_, Self::z(_, _)) => Ordering::Greater,
            (Self::d(s, _, sd, sv, sl), Self::d(o, _, od, ov, ol)) => {
                s.cmp(o).then(sd.cmp(od)).then(sv.cmp(ov)).then(sl.cmp(ol))
            }
            (Self::d(_, _, _, _, _), _) => Ordering::Less,
            (_, Self::d(_, _, _, _, _)) => Ordering::Greater,
            (Self::w(s, _, sd, sv, sl), Self::w(o, _, od, ov, ol)) => {
                s.cmp(o).then(sd.cmp(od)).then(sv.cmp(ov)).then(sl.cmp(ol))
            }
            (Self::w(_, _, _, _, _), _) => Ordering::Less,
            (_, Self::w(_, _, _, _, _)) => Ordering::Greater,
            (Self::v(s, _, sd, sv), Self::v(o, _, od, ov)) => {
                s.cmp(o).then(sd.cmp(od)).then(sv.cmp(ov))
            }
            (Self::v(_, _, _, _), _) => Ordering::Less,
            (_, Self::v(_, _, _, _)) => Ordering::Greater,
            (Self::Immonium(s, _), Self::Immonium(o, _)) => s.cmp(o),
            (Self::Immonium(_, _), _) => Ordering::Less,
            (_, Self::Immonium(_, _)) => Ordering::Greater,
            (Self::PrecursorSideChainLoss(s, _), Self::PrecursorSideChainLoss(o, _)) => s.cmp(o),
            (Self::PrecursorSideChainLoss(_, _), _) => Ordering::Less,
            (_, Self::PrecursorSideChainLoss(_, _)) => Ordering::Greater,
            (Self::Internal(st, sa, sb), Self::Internal(ot, oa, ob)) => {
                sa.cmp(oa).then(sb.cmp(ob)).then(st.cmp(ot))
            }
            (Self::Internal(_, _, _), _) => Ordering::Less,
            (_, Self::Internal(_, _, _)) => Ordering::Greater,
            // Glycans
            (Self::B { b: sb, y: sy, .. }, Self::B { b: ob, y: oy, .. }) => {
                sy.len().cmp(&oy.len()).then(sb.cmp(ob))
            }
            (Self::Y(s), Self::Y(o)) => s.len().cmp(&o.len()),
            (Self::B { y: sy, .. }, Self::Y(o)) => {
                (sy.len() + 1).cmp(&o.len()).then(Ordering::Greater)
            }
            (Self::Y(s), Self::B { y: oy, .. }) => {
                s.len().cmp(&(oy.len() + 1)).then(Ordering::Less)
            }
            (Self::B { .. }, _) => Ordering::Less,
            (_, Self::B { .. }) => Ordering::Greater,
            (Self::Y(_), _) => Ordering::Less,
            (_, Self::Y(_)) => Ordering::Greater,
            (Self::BComposition(s, sl), Self::BComposition(o, ol))
            | (Self::YComposition(s, sl), Self::YComposition(o, ol)) => {
                s.len().cmp(&o.len()).then(sl.cmp(ol))
            }
            (Self::BComposition(s, sl), Self::YComposition(o, ol)) => s
                .len()
                .cmp(&o.len())
                .then(sl.cmp(ol))
                .then(Ordering::Greater),
            (Self::YComposition(s, sl), Self::BComposition(o, ol)) => {
                s.len().cmp(&o.len()).then(sl.cmp(ol)).then(Ordering::Less)
            }
            (Self::BComposition(_, _), _) => Ordering::Less,
            (_, Self::BComposition(_, _)) => Ordering::Greater,
            (Self::YComposition(_, _), _) => Ordering::Less,
            (_, Self::YComposition(_, _)) => Ordering::Greater,
            // Other
            (Self::Diagnostic(s), Self::Diagnostic(o)) => s.cmp(o),
            (Self::Diagnostic(_), _) => Ordering::Less,
            (_, Self::Diagnostic(_)) => Ordering::Greater,
            (Self::Unknown(s), Self::Unknown(o)) => s.cmp(o),
        }
    }
}

impl PartialOrd for FragmentType {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl FragmentType {
    /// Get a main ion series fragment with the specified variant, or pass the fragment type through unchanged
    #[must_use]
    pub fn with_variant(&self, variant: Variant) -> Self {
        match self {
            Self::a(p, _) => Self::a(*p, variant),
            Self::b(p, _) => Self::b(*p, variant),
            Self::c(p, _) => Self::c(*p, variant),
            Self::d(p, a, d, _, l) => Self::d(*p, *a, *d, variant, *l),
            Self::v(p, a, d, _) => Self::v(*p, *a, *d, variant),
            Self::w(p, a, d, _, l) => Self::w(*p, *a, *d, variant, *l),
            Self::x(p, _) => Self::x(*p, variant),
            Self::y(p, _) => Self::y(*p, variant),
            Self::z(p, _) => Self::z(*p, variant),
            other => other.clone(),
        }
    }

    /// Get the position of this ion (or None if it is not known)
    pub const fn position(&self) -> Option<&PeptidePosition> {
        match self {
            Self::a(n, _)
            | Self::b(n, _)
            | Self::c(n, _)
            | Self::d(n, _, _, _, _)
            | Self::v(n, _, _, _)
            | Self::w(n, _, _, _, _)
            | Self::x(n, _)
            | Self::y(n, _)
            | Self::z(n, _)
            | Self::Diagnostic(DiagnosticPosition::Peptide(n, _))
            | Self::PrecursorSideChainLoss(n, _) => Some(n),
            Self::Immonium(n, _) => n.as_ref(),
            _ => None,
        }
    }

    /// Get the root glycan position of this ion (or None if not applicable), Y is not defined as it does not have a root break
    pub const fn glycan_position(&self) -> Option<&GlycanPosition> {
        match self {
            Self::Diagnostic(DiagnosticPosition::Glycan(b, _)) | Self::B { b, .. } => Some(b),
            _ => None,
        }
    }

    /// Get the glycan break positions of this ion (or None if not applicable), gives the sequence index, the root break, and the branch breaks.
    /// Only available with feature 'glycan-render'.
    pub fn glycan_break_positions(
        &self,
    ) -> Option<(Option<SequencePosition>, GlycanSelection<'_>)> {
        match self {
            Self::Diagnostic(DiagnosticPosition::Glycan(n, _)) => Some((
                n.attachment.map(|(_, p)| p),
                GlycanSelection::SingleSugar(n),
            )),
            Self::Y(breaks) => Some((
                breaks.first().and_then(|p| p.attachment.map(|(_, p)| p)),
                GlycanSelection::Subtree(None, breaks),
            )),
            Self::B { b, y, .. } => Some((
                b.attachment.map(|(_, p)| p),
                GlycanSelection::Subtree(Some(b), y),
            )),
            _ => None,
        }
    }

    /// Get the position label, unless it is a precursor ion
    pub fn position_label(&self) -> Option<String> {
        match self {
            Self::a(n, _)
            | Self::b(n, _)
            | Self::c(n, _)
            | Self::d(n, _, _, _, _)
            | Self::v(n, _, _, _)
            | Self::w(n, _, _, _, _)
            | Self::x(n, _)
            | Self::y(n, _)
            | Self::z(n, _)
            | Self::Diagnostic(DiagnosticPosition::Peptide(n, _))
            | Self::PrecursorSideChainLoss(n, _) => Some(n.series_number.to_string()),
            Self::Immonium(n, _) => n.map(|n| n.series_number.to_string()),
            Self::Diagnostic(DiagnosticPosition::Glycan(n, _)) => Some(n.label()),
            Self::Y(bonds) => Some(bonds.iter().map(GlycanPosition::label).join("Y")),
            Self::B { b, y, end } => Some(
                b.label()
                    + "Y"
                    + &y.iter()
                        .chain(end.iter())
                        .map(GlycanPosition::label)
                        .join("Y"),
            ),
            Self::YComposition(sugars, _) | Self::BComposition(sugars, _) => Some(
                sugars
                    .iter()
                    .map(|(sugar, amount)| format!("{sugar}{amount}"))
                    .join(""),
            ),
            Self::Internal(_, pos1, pos2) => {
                Some(format!("{}:{}", pos1.sequence_index, pos2.sequence_index,))
            }
            Self::Precursor
            | Self::Unknown(_)
            | Self::Diagnostic(
                DiagnosticPosition::Labile(_)
                | DiagnosticPosition::GlycanCompositional(_, _)
                | DiagnosticPosition::Reporter,
            ) => None,
        }
    }

    /// Get the label for this fragment type, the first argument is the optional superscript prefix, the second is the main label
    pub fn label(&self) -> (Option<String>, Cow<'_, str>) {
        let get_label = |ion: &'static str, v: i8| {
            if v == 0 {
                Cow::Borrowed(ion)
            } else {
                Cow::Owned(format!(
                    "{ion}{}",
                    if v < 0 {
                        "\'".repeat((-v) as usize)
                    } else {
                        "·".repeat(v as usize)
                    }
                ))
            }
        };

        match self {
            Self::a(_, v) => (None, get_label("a", *v)),
            Self::b(_, v) => (None, get_label("b", *v)),
            Self::c(_, v) => (None, get_label("c", *v)),
            Self::d(_, _, n, v, l) => (
                (*n != 0).then_some(n.to_string()),
                Cow::Owned(format!(
                    "d{l}{}",
                    if *v < 0 {
                        "\'".repeat((-v) as usize)
                    } else {
                        "·".repeat(*v as usize)
                    }
                )),
            ),
            Self::v(_, _, n, v) => ((*n != 0).then_some(n.to_string()), get_label("v", *v)),
            Self::w(_, _, n, v, l) => (
                (*n != 0).then_some(n.to_string()),
                Cow::Owned(format!(
                    "w{l}{}",
                    if *v < 0 {
                        "\'".repeat((-v) as usize)
                    } else {
                        "·".repeat(*v as usize)
                    }
                )),
            ),
            Self::x(_, v) => (None, get_label("x", *v)),
            Self::y(_, v) => (None, get_label("y", *v)),
            Self::z(_, v) => (None, get_label("z", *v)),
            Self::B { .. } | Self::BComposition(_, _) => (None, Cow::Borrowed("B")),
            Self::Y(_) | Self::YComposition(_, _) => (None, Cow::Borrowed("Y")),
            Self::Diagnostic(DiagnosticPosition::Peptide(_, aa)) => (
                None,
                Cow::Owned(
                    aa.one_letter_code()
                        .map(|c| format!("d{c}"))
                        .or_else(|| aa.three_letter_code().map(|c| format!("d{c}")))
                        .unwrap_or_else(|| format!("d{}", aa.name())),
                ),
            ),
            Self::Diagnostic(DiagnosticPosition::Reporter) => (None, Cow::Borrowed("r")),
            Self::Diagnostic(DiagnosticPosition::Labile(m)) => (None, Cow::Owned(format!("d{m}"))),
            Self::Diagnostic(
                DiagnosticPosition::Glycan(_, sug)
                | DiagnosticPosition::GlycanCompositional(sug, _),
            ) => (None, Cow::Owned(format!("d{sug}"))),
            Self::Immonium(_, aa) => (
                None,
                Cow::Owned(
                    aa.aminoacid
                        .one_letter_code()
                        .map(|c| format!("i{c}"))
                        .or_else(|| aa.aminoacid.three_letter_code().map(|c| format!("i{c}")))
                        .unwrap_or_else(|| format!("i{}", aa.aminoacid.name())),
                ),
            ),
            Self::PrecursorSideChainLoss(_, aa) => (
                None,
                Cow::Owned(
                    aa.one_letter_code()
                        .map(|c| format!("p-s{c}"))
                        .or_else(|| aa.three_letter_code().map(|c| format!("p-s{c}")))
                        .unwrap_or_else(|| format!("p-s{}", aa.name())),
                ),
            ),
            Self::Precursor => (None, Cow::Borrowed("p")),
            Self::Internal(fragmentation, _, _) => (
                None,
                Cow::Owned(format!(
                    "m{}",
                    fragmentation.map_or(String::new(), |(n, c)| format!("{n}:{c}")),
                )),
            ),
            Self::Unknown(series) => (
                None,
                Cow::Owned(format!(
                    "?{}",
                    series.map_or(String::new(), |s| s.to_string()),
                )),
            ),
        }
    }

    /// Get the kind of fragment, easier to match against
    pub const fn kind(&self) -> FragmentKind {
        match self {
            Self::a(_, _) => FragmentKind::a,
            Self::b(_, _) => FragmentKind::b,
            Self::c(_, _) => FragmentKind::c,
            Self::d(_, _, _, _, _) => FragmentKind::d,
            Self::v(_, _, _, _) => FragmentKind::v,
            Self::w(_, _, _, _, _) => FragmentKind::w,
            Self::x(_, _) => FragmentKind::x,
            Self::y(_, _) => FragmentKind::y,
            Self::z(_, _) => FragmentKind::z,
            Self::Y(_) | Self::YComposition(_, _) => FragmentKind::Y,
            Self::Diagnostic(
                DiagnosticPosition::Glycan(_, _) | DiagnosticPosition::GlycanCompositional(_, _),
            )
            | Self::B { .. }
            | Self::BComposition(_, _) => FragmentKind::B,
            Self::Diagnostic(_) => FragmentKind::diagnostic,
            Self::Immonium(_, _) => FragmentKind::immonium,
            Self::PrecursorSideChainLoss(_, _) => FragmentKind::precursor_side_chain_loss,
            Self::Precursor => FragmentKind::precursor,
            Self::Internal(_, _, _) => FragmentKind::internal,
            Self::Unknown(_) => FragmentKind::unknown,
        }
    }
}

impl Display for FragmentType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let (sup, label) = self.label();
        write!(
            f,
            "{}{}{}",
            sup.unwrap_or_default(),
            label,
            self.position_label().unwrap_or_default()
        )
    }
}

/// The possible kinds of N terminal backbone fragments.
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[expect(non_camel_case_types)]
pub enum BackboneNFragment {
    /// a
    a,
    /// b
    b,
    /// c
    c,
}

impl Display for BackboneNFragment {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                Self::a => "a",
                Self::b => "b",
                Self::c => "c",
            }
        )
    }
}

/// The possible kinds of C terminal backbone fragments.
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[expect(non_camel_case_types)]
pub enum BackboneCFragment {
    /// x
    x,
    /// y
    y,
    /// z and z·
    z,
}

impl Display for BackboneCFragment {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                Self::x => "x",
                Self::y => "y",
                Self::z => "z",
            }
        )
    }
}

/// The possible kinds of fragments, same options as [`FragmentType`] but without any additional data
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[expect(non_camel_case_types)]
pub enum FragmentKind {
    /// a
    a,
    /// b
    b,
    /// c
    c,
    /// d
    d,
    /// v
    v,
    /// w
    w,
    /// x
    x,
    /// y
    y,
    /// z and z·
    z,
    /// glycan Y fragment, generated by one or more branches broken
    Y,
    /// B or glycan diagnostic ion or Internal glycan fragment, meaning both a B and Y breakages (and potentially multiple of both), resulting in a set of monosaccharides
    B,
    /// Immonium ion
    immonium,
    /// Precursor with amino acid side chain loss
    precursor_side_chain_loss,
    /// Diagnostic ion for a given position
    diagnostic,
    /// Internal ion
    internal,
    /// precursor
    precursor,
    /// unknown fragment
    unknown,
}

impl Display for FragmentKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                Self::a => "a",
                Self::b => "b",
                Self::c => "c",
                Self::d => "d",
                Self::x => "x",
                Self::y => "y",
                Self::v => "v",
                Self::w => "w",
                Self::z => "z",
                Self::Y => "Y",
                Self::B => "oxonium",
                Self::immonium => "immonium",
                Self::precursor_side_chain_loss => "precursor side chain loss",
                Self::diagnostic => "diagnostic",
                Self::internal => "m",
                Self::precursor => "precursor",
                Self::unknown => "unknown",
            }
        )
    }
}

impl From<BackboneFragmentKind> for FragmentKind {
    fn from(value: BackboneFragmentKind) -> Self {
        match value {
            BackboneFragmentKind::a => Self::a,
            BackboneFragmentKind::b => Self::b,
            BackboneFragmentKind::c => Self::c,
            BackboneFragmentKind::d => Self::d,
            BackboneFragmentKind::x => Self::x,
            BackboneFragmentKind::y => Self::y,
            BackboneFragmentKind::v => Self::v,
            BackboneFragmentKind::w => Self::w,
            BackboneFragmentKind::z => Self::z,
        }
    }
}