@@ -137,17 +137,20 @@ fn parse_annotation<'a>(
137137 let ( left_range, charge) = parse_charge ( base_context, line, left_range) ?;
138138 let ( left_range, deviation) = parse_deviation ( base_context, line, left_range) ?;
139139 let ( left_range, confidence) = parse_confidence ( base_context, line, left_range) ?;
140- Ok ( ( left_range, PeakAnnotation {
141- auxiliary,
142- analyte_number,
143- ion,
144- neutral_losses,
145- isotopes,
146- charge : adduct_type
147- . unwrap_or_else ( || MolecularCharge :: proton ( Charge :: new :: < e > ( charge. value ) ) ) ,
148- deviation,
149- confidence,
150- } ) )
140+ Ok ( (
141+ left_range,
142+ PeakAnnotation {
143+ auxiliary,
144+ analyte_number,
145+ ion,
146+ neutral_losses,
147+ isotopes,
148+ charge : adduct_type
149+ . unwrap_or_else ( || MolecularCharge :: proton ( Charge :: new :: < e > ( charge. value ) ) ) ,
150+ deviation,
151+ confidence,
152+ } ,
153+ ) )
151154}
152155
153156/// An mzPAF single peak annotation.
@@ -238,104 +241,119 @@ impl PeakAnnotation {
238241 } else {
239242 ( 0 , AminoAcid :: Unknown , AminoAcid :: Unknown )
240243 } ;
241- ( None , match series {
242- b'a' => FragmentType :: a (
243- PeptidePosition {
244- sequence_index : SequencePosition :: Index ( ordinal - 1 , sequence_length) ,
245- series_number : ordinal,
246- sequence_length,
247- } ,
248- variant,
249- ) ,
250- b'b' => FragmentType :: b (
251- PeptidePosition {
252- sequence_index : SequencePosition :: Index ( ordinal - 1 , sequence_length) ,
253- series_number : ordinal,
254- sequence_length,
255- } ,
256- variant,
257- ) ,
258- b'c' => FragmentType :: c (
259- PeptidePosition {
260- sequence_index : SequencePosition :: Index ( ordinal - 1 , sequence_length) ,
261- series_number : ordinal,
262- sequence_length,
263- } ,
264- variant,
265- ) ,
266- b'd' => FragmentType :: d (
267- PeptidePosition {
268- sequence_index : SequencePosition :: Index ( ordinal - 1 , sequence_length) ,
269- series_number : ordinal,
270- sequence_length,
271- } ,
272- n_aa,
273- 0 ,
274- variant,
275- sub,
276- ) ,
277- b'v' => FragmentType :: v (
278- PeptidePosition {
279- sequence_index : SequencePosition :: Index (
280- sequence_length. saturating_sub ( ordinal) ,
244+ (
245+ None ,
246+ match series {
247+ b'a' => FragmentType :: a (
248+ PeptidePosition {
249+ sequence_index : SequencePosition :: Index (
250+ ordinal - 1 ,
251+ sequence_length,
252+ ) ,
253+ series_number : ordinal,
281254 sequence_length,
282- ) ,
283- series_number : ordinal,
284- sequence_length,
285- } ,
286- c_aa,
287- 0 ,
288- variant,
289- ) ,
290- b'w' => FragmentType :: w (
291- PeptidePosition {
292- sequence_index : SequencePosition :: Index (
293- sequence_length. saturating_sub ( ordinal) ,
255+ } ,
256+ variant,
257+ ) ,
258+ b'b' => FragmentType :: b (
259+ PeptidePosition {
260+ sequence_index : SequencePosition :: Index (
261+ ordinal - 1 ,
262+ sequence_length,
263+ ) ,
264+ series_number : ordinal,
294265 sequence_length,
295- ) ,
296- series_number : ordinal,
297- sequence_length,
298- } ,
299- c_aa,
300- 0 ,
301- variant,
302- sub,
303- ) ,
304- b'x' => FragmentType :: x (
305- PeptidePosition {
306- sequence_index : SequencePosition :: Index (
307- sequence_length. saturating_sub ( ordinal) ,
266+ } ,
267+ variant,
268+ ) ,
269+ b'c' => FragmentType :: c (
270+ PeptidePosition {
271+ sequence_index : SequencePosition :: Index (
272+ ordinal - 1 ,
273+ sequence_length,
274+ ) ,
275+ series_number : ordinal,
308276 sequence_length,
309- ) ,
310- series_number : ordinal ,
311- sequence_length ,
312- } ,
313- variant ,
314- ) ,
315- b'y' => FragmentType :: y (
316- PeptidePosition {
317- sequence_index : SequencePosition :: Index (
318- sequence_length . saturating_sub ( ordinal) ,
277+ } ,
278+ variant ,
279+ ) ,
280+ b'd' => FragmentType :: d (
281+ PeptidePosition {
282+ sequence_index : SequencePosition :: Index (
283+ ordinal - 1 ,
284+ sequence_length ,
285+ ) ,
286+ series_number : ordinal,
319287 sequence_length,
320- ) ,
321- series_number : ordinal,
322- sequence_length,
323- } ,
324- variant,
325- ) ,
326- b'z' => FragmentType :: z (
327- PeptidePosition {
328- sequence_index : SequencePosition :: Index (
329- sequence_length. saturating_sub ( ordinal) ,
288+ } ,
289+ n_aa,
290+ 0 ,
291+ variant,
292+ sub,
293+ ) ,
294+ b'v' => FragmentType :: v (
295+ PeptidePosition {
296+ sequence_index : SequencePosition :: Index (
297+ sequence_length. saturating_sub ( ordinal) ,
298+ sequence_length,
299+ ) ,
300+ series_number : ordinal,
330301 sequence_length,
331- ) ,
332- series_number : ordinal,
333- sequence_length,
334- } ,
335- variant,
336- ) ,
337- _ => unreachable ! ( ) ,
338- } )
302+ } ,
303+ c_aa,
304+ 0 ,
305+ variant,
306+ ) ,
307+ b'w' => FragmentType :: w (
308+ PeptidePosition {
309+ sequence_index : SequencePosition :: Index (
310+ sequence_length. saturating_sub ( ordinal) ,
311+ sequence_length,
312+ ) ,
313+ series_number : ordinal,
314+ sequence_length,
315+ } ,
316+ c_aa,
317+ 0 ,
318+ variant,
319+ sub,
320+ ) ,
321+ b'x' => FragmentType :: x (
322+ PeptidePosition {
323+ sequence_index : SequencePosition :: Index (
324+ sequence_length. saturating_sub ( ordinal) ,
325+ sequence_length,
326+ ) ,
327+ series_number : ordinal,
328+ sequence_length,
329+ } ,
330+ variant,
331+ ) ,
332+ b'y' => FragmentType :: y (
333+ PeptidePosition {
334+ sequence_index : SequencePosition :: Index (
335+ sequence_length. saturating_sub ( ordinal) ,
336+ sequence_length,
337+ ) ,
338+ series_number : ordinal,
339+ sequence_length,
340+ } ,
341+ variant,
342+ ) ,
343+ b'z' => FragmentType :: z (
344+ PeptidePosition {
345+ sequence_index : SequencePosition :: Index (
346+ sequence_length. saturating_sub ( ordinal) ,
347+ sequence_length,
348+ ) ,
349+ series_number : ordinal,
350+ sequence_length,
351+ } ,
352+ variant,
353+ ) ,
354+ _ => unreachable ! ( ) ,
355+ } ,
356+ )
339357 }
340358 IonType :: Immonium ( aa, m) => (
341359 aa. calculate_masses :: < OutputMolecularFormula > ( ) . first ( ) . map ( |f| {
@@ -902,7 +920,7 @@ fn parse_ion<'a>(
902920 BasicKind :: Error ,
903921 "Invalid mzPAF SMILES" ,
904922 "The SMILES string is charged" ,
905- base_context. clone ( ) . add_highlight ( ( 0 , smiles_range. clone ( ) ) ) ,
923+ base_context. clone ( ) . add_highlight ( ( 0 , smiles_range) ) ,
906924 ) ) ;
907925 }
908926 let composition = structure. composition ( ) . ok_or_else ( || {
@@ -1494,24 +1512,24 @@ static MZPAF_NAMED_MOLECULES: LazyLock<Vec<(&str, MolecularFormula)>> = LazyLock
14941512fn neutral_loss ( ) {
14951513 assert_eq ! (
14961514 parse_neutral_loss( & Context :: default ( ) , "-H2O" , 0 ..4 ) ,
1497- Ok ( ( 4 .. 4 , vec! [ NeutralLoss :: Loss (
1498- 1 ,
1499- molecular_formula!( H 2 O 1 )
1500- ) ] ) )
1515+ Ok ( (
1516+ 4 .. 4 ,
1517+ vec! [ NeutralLoss :: Loss ( 1 , molecular_formula!( H 2 O 1 ) ) ]
1518+ ) )
15011519 ) ;
15021520 assert_eq ! (
15031521 parse_neutral_loss( & Context :: default ( ) , "+H2O" , 0 ..4 ) ,
1504- Ok ( ( 4 .. 4 , vec! [ NeutralLoss :: Gain (
1505- 1 ,
1506- molecular_formula!( H 2 O 1 )
1507- ) ] ) )
1522+ Ok ( (
1523+ 4 .. 4 ,
1524+ vec! [ NeutralLoss :: Gain ( 1 , molecular_formula!( H 2 O 1 ) ) ]
1525+ ) )
15081526 ) ;
15091527 assert_eq ! (
15101528 parse_neutral_loss( & Context :: default ( ) , "+NH3" , 0 ..4 ) ,
1511- Ok ( ( 4 .. 4 , vec! [ NeutralLoss :: Gain (
1512- 1 ,
1513- molecular_formula!( N 1 H 3 )
1514- ) ] ) )
1529+ Ok ( (
1530+ 4 .. 4 ,
1531+ vec! [ NeutralLoss :: Gain ( 1 , molecular_formula!( N 1 H 3 ) ) ]
1532+ ) )
15151533 ) ;
15161534 assert_eq ! (
15171535 parse_neutral_loss( & Context :: default ( ) , "/-0.0008" , 0 ..8 ) ,
0 commit comments