@@ -66,20 +66,15 @@ fn amino_acid<'a, 's>(
66
66
67
67
// =
68
68
69
- /// Modifications = "(" ,
70
- /// ( Predefined Modification
71
- /// | Chemical Offset
72
- /// ) , { { " " } , "," , { " " } ,
73
- /// ( Predefined Modification
74
- /// | Chemical Offset
75
- /// ) } , ")" ;
69
+ /// Modifications = "(" , ( Named Modification | Offset Modification ) ,
70
+ /// { { " " } , "," , { " " } , ( Named Modification | Offset Modification ) } , ")" ;
76
71
fn modifications < ' a , ' s > (
77
72
polymerizer : & Polymerizer < ' a , ' a > ,
78
73
) -> impl FnMut ( & ' s str ) -> ParseResult < Vec < AnyModification < ' a , ' a > > > {
79
74
let separator = delimited ( space0, char ( ',' ) , space0) ;
80
75
// FIXME: Move into polychem
81
76
let any_mod = alt ( (
82
- map ( predefined_modification ( polymerizer) , Modification :: convert) ,
77
+ map ( named_modification ( polymerizer) , Modification :: convert) ,
83
78
map ( chemical_offset ( polymerizer) , Modification :: convert) ,
84
79
) ) ;
85
80
delimited ( char ( '(' ) , separated_list1 ( separator, any_mod) , char ( ')' ) )
@@ -115,8 +110,8 @@ fn lateral_chain<'a, 's>(
115
110
116
111
// FIXME: I probably need to add a lot of `wrap_err`s around these parsers!
117
112
// FIXME: Move into polychem
118
- /// Predefined Modification = [ Multiplier ] , Identifier
119
- fn predefined_modification < ' a , ' s > (
113
+ /// Named Modification = [ Multiplier ] , Identifier
114
+ fn named_modification < ' a , ' s > (
120
115
polymerizer : & Polymerizer < ' a , ' a > ,
121
116
) -> impl FnMut ( & ' s str ) -> ParseResult < Modification < NamedMod < ' a , ' a > > > {
122
117
let polymer_db = polymerizer. polymer_db ( ) ;
@@ -342,17 +337,17 @@ mod tests {
342
337
343
338
#[ test]
344
339
#[ allow( clippy:: cognitive_complexity) ]
345
- fn test_predefined_modification ( ) {
340
+ fn test_named_modification ( ) {
346
341
let polymerizer = Polymerizer :: new ( & ATOMIC_DB , & POLYMER_DB ) ;
347
- let mut predefined_modification = predefined_modification ( & polymerizer) ;
342
+ let mut named_modification = named_modification ( & polymerizer) ;
348
343
macro_rules! assert_offset_mass {
349
344
( $input: literal, $output: literal, $mass: expr) => {
350
- let ( rest, modification) = predefined_modification ( $input) . unwrap( ) ;
345
+ let ( rest, modification) = named_modification ( $input) . unwrap( ) ;
351
346
assert_eq!( rest, $output) ;
352
347
assert_eq!( modification. monoisotopic_mass( ) , $mass) ;
353
348
} ;
354
349
}
355
- // Valid Predefined Modifications
350
+ // Valid Named Modifications
356
351
assert_offset_mass ! ( "Am" , "" , dec!( -0.98401558291 ) ) ;
357
352
assert_offset_mass ! ( "Ac" , "" , dec!( 42.01056468403 ) ) ;
358
353
assert_offset_mass ! ( "Poly" , "" , dec!( 77.95068082490 ) ) ;
@@ -362,33 +357,33 @@ mod tests {
362
357
assert_offset_mass ! ( "1xAm" , "" , dec!( -0.98401558291 ) ) ;
363
358
assert_offset_mass ! ( "2xRed" , "" , dec!( 4.03130012892 ) ) ;
364
359
assert_offset_mass ! ( "3xAnh" , "" , dec!( -54.03169405209 ) ) ;
365
- // Invalid Predefined Modifications
366
- assert ! ( predefined_modification ( " H2O" ) . is_err( ) ) ;
367
- assert ! ( predefined_modification ( "1" ) . is_err( ) ) ;
368
- assert ! ( predefined_modification ( "9999" ) . is_err( ) ) ;
369
- assert ! ( predefined_modification ( "0" ) . is_err( ) ) ;
370
- assert ! ( predefined_modification ( "00145" ) . is_err( ) ) ;
371
- assert ! ( predefined_modification ( "+H" ) . is_err( ) ) ;
372
- assert ! ( predefined_modification ( "[H]" ) . is_err( ) ) ;
373
- assert ! ( predefined_modification ( "Øof" ) . is_err( ) ) ;
374
- assert ! ( predefined_modification ( "-Ac" ) . is_err( ) ) ;
375
- assert ! ( predefined_modification ( "_Ac" ) . is_err( ) ) ;
376
- assert ! ( predefined_modification ( "+Am" ) . is_err( ) ) ;
377
- assert ! ( predefined_modification ( "-2xAm" ) . is_err( ) ) ;
378
- assert ! ( predefined_modification ( "(Am)" ) . is_err( ) ) ;
379
- assert ! ( predefined_modification ( "-4xH2O" ) . is_err( ) ) ;
380
- assert ! ( predefined_modification ( "-2p" ) . is_err( ) ) ;
381
- assert ! ( predefined_modification ( "+C2H2O-2e" ) . is_err( ) ) ;
382
- assert ! ( predefined_modification ( "-3xC2H2O-2e" ) . is_err( ) ) ;
383
- assert ! ( predefined_modification ( "+NH3+p" ) . is_err( ) ) ;
384
- assert ! ( predefined_modification ( "+2xD2O" ) . is_err( ) ) ;
385
- assert ! ( predefined_modification ( "-2x[2H]2O" ) . is_err( ) ) ;
386
- // Non-Existent Predefined Modifications
387
- assert ! ( predefined_modification ( "Blue" ) . is_err( ) ) ;
388
- assert ! ( predefined_modification ( "Hydro" ) . is_err( ) ) ;
389
- assert ! ( predefined_modification ( "1xAm2" ) . is_err( ) ) ;
390
- assert ! ( predefined_modification ( "2xR_ed" ) . is_err( ) ) ;
391
- // Multiple Predefined Modifications
360
+ // Invalid Named Modifications
361
+ assert ! ( named_modification ( " H2O" ) . is_err( ) ) ;
362
+ assert ! ( named_modification ( "1" ) . is_err( ) ) ;
363
+ assert ! ( named_modification ( "9999" ) . is_err( ) ) ;
364
+ assert ! ( named_modification ( "0" ) . is_err( ) ) ;
365
+ assert ! ( named_modification ( "00145" ) . is_err( ) ) ;
366
+ assert ! ( named_modification ( "+H" ) . is_err( ) ) ;
367
+ assert ! ( named_modification ( "[H]" ) . is_err( ) ) ;
368
+ assert ! ( named_modification ( "Øof" ) . is_err( ) ) ;
369
+ assert ! ( named_modification ( "-Ac" ) . is_err( ) ) ;
370
+ assert ! ( named_modification ( "_Ac" ) . is_err( ) ) ;
371
+ assert ! ( named_modification ( "+Am" ) . is_err( ) ) ;
372
+ assert ! ( named_modification ( "-2xAm" ) . is_err( ) ) ;
373
+ assert ! ( named_modification ( "(Am)" ) . is_err( ) ) ;
374
+ assert ! ( named_modification ( "-4xH2O" ) . is_err( ) ) ;
375
+ assert ! ( named_modification ( "-2p" ) . is_err( ) ) ;
376
+ assert ! ( named_modification ( "+C2H2O-2e" ) . is_err( ) ) ;
377
+ assert ! ( named_modification ( "-3xC2H2O-2e" ) . is_err( ) ) ;
378
+ assert ! ( named_modification ( "+NH3+p" ) . is_err( ) ) ;
379
+ assert ! ( named_modification ( "+2xD2O" ) . is_err( ) ) ;
380
+ assert ! ( named_modification ( "-2x[2H]2O" ) . is_err( ) ) ;
381
+ // Non-Existent Named Modifications
382
+ assert ! ( named_modification ( "Blue" ) . is_err( ) ) ;
383
+ assert ! ( named_modification ( "Hydro" ) . is_err( ) ) ;
384
+ assert ! ( named_modification ( "1xAm2" ) . is_err( ) ) ;
385
+ assert ! ( named_modification ( "2xR_ed" ) . is_err( ) ) ;
386
+ // Multiple Named Modifications
392
387
assert_offset_mass ! ( "Anh, Am" , ", Am" , dec!( -18.01056468403 ) ) ;
393
388
assert_offset_mass ! ( "1xAm)JAA" , ")JAA" , dec!( -0.98401558291 ) ) ;
394
389
}
0 commit comments