From 7b03637b0a83aa587795236a3af33a0d650455cf Mon Sep 17 00:00:00 2001
From: Joshua Klein <mobiusklein@gmail.com>
Date: Fri, 19 Apr 2024 09:01:27 -0400
Subject: [PATCH] Update CI workflow, fix validator from previous discussion

---
 .github/workflows/test.yml                    |  6 +-
 .gitignore                                    |  4 +-
 ...chinese_hamster_hcd_selected_head.mzlb.txt | 29 +++---
 mzlib/validate/rules/base.json                |  2 +-
 mzlib/validate/validator.py                   |  8 +-
 ...hinese_hamster_hcd_selected_head.mzlb.json | 91 ++++++++++---------
 ...chinese_hamster_hcd_selected_head.mzlb.txt | 29 +++---
 7 files changed, 93 insertions(+), 76 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 90ca75f..304c21a 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -22,12 +22,12 @@ jobs:
     - name: Lint with flake8
       run: |
         # stop the build if there are Python syntax errors or undefined names
-        flake8 implementations/python --count --select=E9,F63,F7,F82 --show-source --statistics
+        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
         # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
-        flake8 implementations/python --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
+        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
     - name: Install python package
       run: |
-        pip install --editable implementations/python[test]
+        pip install --editable .[test]
     - name: Test with pytest
       run: |
         pytest -r a
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 4786091..21ce63d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,6 @@ __pycache__
 *.ipynb
 examples/*splindex
 .coverage
-htmlcov/
\ No newline at end of file
+htmlcov/
+dist/
+build/
\ No newline at end of file
diff --git a/examples/chinese_hamster_hcd_selected_head.mzlb.txt b/examples/chinese_hamster_hcd_selected_head.mzlb.txt
index 4991bc3..c9278c5 100644
--- a/examples/chinese_hamster_hcd_selected_head.mzlb.txt
+++ b/examples/chinese_hamster_hcd_selected_head.mzlb.txt
@@ -1,4 +1,5 @@
 <mzSpecLib 1.0>
+MS:1003186|library format version=1.0
 MS:1003188|library name=examples/chinese_hamster_hcd_selected_head
 <AttributeSet Spectrum=all>
 <AttributeSet Analyte=all>
@@ -6,7 +7,6 @@ MS:1003188|library name=examples/chinese_hamster_hcd_selected_head
 <Spectrum=1>
 MS:1003061|library spectrum name=AAAACALTPGPLADLAAR/2_1(4,C,CAM)_46eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=855.4538
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=46
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -30,6 +30,7 @@ MS:1003059|number of peaks=87
 MS:1000224|molecular mass=1710.9076
 MS:1000888|stripped peptide sequence=AAAACALTPGPLADLAAR
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=855.4538
 [1]MS:1001975|delta m/z=1.4
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=855.455
@@ -39,7 +40,7 @@ MS:1001117|theoretical mass=1708.89303961159
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=R
 [2]MS:1001113|c-terminal flanking residue=L
-[2]MS:1000885|protein accession="tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.2848
 MS:1003080|top 20 peak unassigned intensity fraction=0.1879
@@ -137,7 +138,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=4
 <Spectrum=2>
 MS:1003061|library spectrum name=AAAACALTPGPLADLAAR/2_1(4,C,CAM)_53eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=855.4538
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=53
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -161,6 +161,7 @@ MS:1003059|number of peaks=204
 MS:1000224|molecular mass=1710.9076
 MS:1000888|stripped peptide sequence=AAAACALTPGPLADLAAR
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=855.4538
 [1]MS:1001975|delta m/z=4.2
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=855.4574
@@ -170,7 +171,7 @@ MS:1001117|theoretical mass=1708.89303961159
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=R
 [2]MS:1001113|c-terminal flanking residue=L
-[2]MS:1000885|protein accession="tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.3165
 MS:1003080|top 20 peak unassigned intensity fraction=0.142
@@ -385,7 +386,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=5
 <Spectrum=3>
 MS:1003061|library spectrum name=AAAAGQTGTVPPGAPGALPLPGMAIVK/2_0_76eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=1207.1672
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=76
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -409,6 +409,7 @@ MS:1003059|number of peaks=122
 MS:1000224|molecular mass=2414.3344
 MS:1000888|stripped peptide sequence=AAAAGQTGTVPPGAPGALPLPGMAIVK
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=1207.1672
 [1]MS:1001975|delta m/z=-0.9
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=1207.1661
@@ -418,7 +419,7 @@ MS:1001117|theoretical mass=2412.319901150229
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=A
 [2]MS:1001113|c-terminal flanking residue=E
-[2]MS:1000885|protein accession="tr|G3I2Q7|G3I2Q7_CRIGR Transcription intermediary factor 1-beta OS=Cricetulus griseus GN=I79_017700 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3I2Q7|G3I2Q7_CRIGR Transcription intermediary factor 1-beta OS=Cricetulus griseus GN=I79_017700 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.2591
 MS:1003080|top 20 peak unassigned intensity fraction=0.0
@@ -551,7 +552,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=0
 <Spectrum=4>
 MS:1003061|library spectrum name=AAAAGSTSVKPIFSR/2_0_44eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=731.9043
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=44
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -575,6 +575,7 @@ MS:1003059|number of peaks=111
 MS:1000224|molecular mass=1463.8086
 MS:1000888|stripped peptide sequence=AAAAGSTSVKPIFSR
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=731.9043
 [1]MS:1001975|delta m/z=-2.7
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=731.9023
@@ -584,7 +585,7 @@ MS:1001117|theoretical mass=1461.7939769138902
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=Q
 [2]MS:1001113|c-terminal flanking residue=D
-[2]MS:1000885|protein accession="tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.1681
 MS:1003080|top 20 peak unassigned intensity fraction=0.0217
@@ -706,7 +707,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=1
 <Spectrum=5>
 MS:1003061|library spectrum name=AAAAGSTSVKPIFSR/3_0_28eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=488.2719
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=28
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -730,6 +730,7 @@ MS:1003059|number of peaks=161
 MS:1000224|molecular mass=1464.8157
 MS:1000888|stripped peptide sequence=AAAAGSTSVKPIFSR
 MS:1000041|charge state=3
+MS:1003208|experimental precursor monoisotopic m/z=488.2719
 [1]MS:1001975|delta m/z=3.8
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=488.2738
@@ -739,7 +740,7 @@ MS:1001117|theoretical mass=1461.7939769138902
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=Q
 [2]MS:1001113|c-terminal flanking residue=D
-[2]MS:1000885|protein accession="tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.1804
 MS:1003080|top 20 peak unassigned intensity fraction=0.0
@@ -911,7 +912,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=0
 <Spectrum=6>
 MS:1003061|library spectrum name=AAAALGSHGSCSSEVEK/2_1(10,C,CAM)_50eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=830.8834
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=50
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -935,6 +935,7 @@ MS:1003059|number of peaks=68
 MS:1000224|molecular mass=1661.7668
 MS:1000888|stripped peptide sequence=AAAALGSHGSCSSEVEK
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=830.8834
 [1]MS:1001975|delta m/z=4.1
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=830.8868
@@ -944,7 +945,7 @@ MS:1001117|theoretical mass=1659.7522486039798
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=K
 [2]MS:1001113|c-terminal flanking residue=E
-[2]MS:1000885|protein accession="tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.4368
 MS:1003080|top 20 peak unassigned intensity fraction=0.184
@@ -1023,7 +1024,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=6
 <Spectrum=7>
 MS:1003061|library spectrum name=AAAALGSHGSCSSEVEK/2_1(10,C,CAM)_52eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=830.8834
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=52
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -1047,6 +1047,7 @@ MS:1003059|number of peaks=402
 MS:1000224|molecular mass=1661.7668
 MS:1000888|stripped peptide sequence=AAAALGSHGSCSSEVEK
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=830.8834
 [1]MS:1001975|delta m/z=-2.0
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=830.8817
@@ -1056,7 +1057,7 @@ MS:1001117|theoretical mass=1659.7522486039798
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=K
 [2]MS:1001113|c-terminal flanking residue=E
-[2]MS:1000885|protein accession="tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.339
 MS:1003080|top 20 peak unassigned intensity fraction=0.0816
diff --git a/mzlib/validate/rules/base.json b/mzlib/validate/rules/base.json
index d22733c..0db1bbf 100644
--- a/mzlib/validate/rules/base.json
+++ b/mzlib/validate/rules/base.json
@@ -112,7 +112,7 @@
       ],
       "combination_logic": "OR",
       "id": "Spectrum_has_precursor_mz",
-      "level": "SHOULD",
+      "level": "MAY",
       "path": "/Library/Spectrum"
     },
     {
diff --git a/mzlib/validate/validator.py b/mzlib/validate/validator.py
index 4a58e86..2db65b9 100644
--- a/mzlib/validate/validator.py
+++ b/mzlib/validate/validator.py
@@ -2,6 +2,8 @@
 import logging
 import warnings
 import re
+import numbers
+
 from dataclasses import dataclass, field
 from typing import Any, Callable, Deque, Dict, Iterator, List, Optional, Sequence, Tuple, Union
 
@@ -78,7 +80,11 @@ def _warning_iterator(iterator: Iterator[Spectrum]) -> Iterator[Spectrum]:
 
 def _is_of_type(attrib, relation) -> bool:
     if isinstance(relation.value_type.type_definition, type):
-        return isinstance(attrib.value, relation.value_type.type_definition)
+        if relation.value_type.type_definition is float:
+            tp = numbers.Number
+        else:
+            tp = relation.value_type.type_definition
+        return isinstance(attrib.value, tp)
     else:
         return _try_convert(attrib.value, relation.value_type.type_definition)
 
diff --git a/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.json b/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.json
index bc6d6ba..e6ecb07 100644
--- a/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.json
+++ b/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.json
@@ -39,6 +39,11 @@
               "name": "charge state",
               "value": 2
             },
+            {
+              "accession": "MS:1003208",
+              "name": "experimental precursor monoisotopic m/z",
+              "value": 855.4538
+            },
             {
               "accession": "MS:1001975",
               "cv_param_group": "1",
@@ -96,7 +101,8 @@
               "accession": "MS:1000885",
               "cv_param_group": "2",
               "name": "protein accession",
-              "value": "\"tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1\""
+              "value": "G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1",
+              "value_accession": "tr"
             }
           ],
           "id": "1"
@@ -119,11 +125,6 @@
           "value": "singleton spectrum",
           "value_accession": "MS:1003066"
         },
-        {
-          "accession": "MS:1003208",
-          "name": "experimental precursor monoisotopic m/z",
-          "value": 855.4538
-        },
         {
           "accession": "MS:1000044",
           "name": "dissociation method",
@@ -546,6 +547,11 @@
               "name": "charge state",
               "value": 2
             },
+            {
+              "accession": "MS:1003208",
+              "name": "experimental precursor monoisotopic m/z",
+              "value": 855.4538
+            },
             {
               "accession": "MS:1001975",
               "cv_param_group": "1",
@@ -603,7 +609,8 @@
               "accession": "MS:1000885",
               "cv_param_group": "2",
               "name": "protein accession",
-              "value": "\"tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1\""
+              "value": "G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1",
+              "value_accession": "tr"
             }
           ],
           "id": "1"
@@ -626,11 +633,6 @@
           "value": "singleton spectrum",
           "value_accession": "MS:1003066"
         },
-        {
-          "accession": "MS:1003208",
-          "name": "experimental precursor monoisotopic m/z",
-          "value": 855.4538
-        },
         {
           "accession": "MS:1000044",
           "name": "dissociation method",
@@ -1404,6 +1406,11 @@
               "name": "charge state",
               "value": 2
             },
+            {
+              "accession": "MS:1003208",
+              "name": "experimental precursor monoisotopic m/z",
+              "value": 1207.1672
+            },
             {
               "accession": "MS:1001975",
               "cv_param_group": "1",
@@ -1461,7 +1468,8 @@
               "accession": "MS:1000885",
               "cv_param_group": "2",
               "name": "protein accession",
-              "value": "\"tr|G3I2Q7|G3I2Q7_CRIGR Transcription intermediary factor 1-beta OS=Cricetulus griseus GN=I79_017700 PE=4 SV=1\""
+              "value": "G3I2Q7|G3I2Q7_CRIGR Transcription intermediary factor 1-beta OS=Cricetulus griseus GN=I79_017700 PE=4 SV=1",
+              "value_accession": "tr"
             }
           ],
           "id": "1"
@@ -1484,11 +1492,6 @@
           "value": "singleton spectrum",
           "value_accession": "MS:1003066"
         },
-        {
-          "accession": "MS:1003208",
-          "name": "experimental precursor monoisotopic m/z",
-          "value": 1207.1672
-        },
         {
           "accession": "MS:1000044",
           "name": "dissociation method",
@@ -2016,6 +2019,11 @@
               "name": "charge state",
               "value": 2
             },
+            {
+              "accession": "MS:1003208",
+              "name": "experimental precursor monoisotopic m/z",
+              "value": 731.9043
+            },
             {
               "accession": "MS:1001975",
               "cv_param_group": "1",
@@ -2073,7 +2081,8 @@
               "accession": "MS:1000885",
               "cv_param_group": "2",
               "name": "protein accession",
-              "value": "\"tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1\""
+              "value": "G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1",
+              "value_accession": "tr"
             }
           ],
           "id": "1"
@@ -2096,11 +2105,6 @@
           "value": "singleton spectrum",
           "value_accession": "MS:1003066"
         },
-        {
-          "accession": "MS:1003208",
-          "name": "experimental precursor monoisotopic m/z",
-          "value": 731.9043
-        },
         {
           "accession": "MS:1000044",
           "name": "dissociation method",
@@ -2595,6 +2599,11 @@
               "name": "charge state",
               "value": 3
             },
+            {
+              "accession": "MS:1003208",
+              "name": "experimental precursor monoisotopic m/z",
+              "value": 488.2719
+            },
             {
               "accession": "MS:1001975",
               "cv_param_group": "1",
@@ -2652,7 +2661,8 @@
               "accession": "MS:1000885",
               "cv_param_group": "2",
               "name": "protein accession",
-              "value": "\"tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1\""
+              "value": "G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1",
+              "value_accession": "tr"
             }
           ],
           "id": "1"
@@ -2675,11 +2685,6 @@
           "value": "singleton spectrum",
           "value_accession": "MS:1003066"
         },
-        {
-          "accession": "MS:1003208",
-          "name": "experimental precursor monoisotopic m/z",
-          "value": 488.2719
-        },
         {
           "accession": "MS:1000044",
           "name": "dissociation method",
@@ -3324,6 +3329,11 @@
               "name": "charge state",
               "value": 2
             },
+            {
+              "accession": "MS:1003208",
+              "name": "experimental precursor monoisotopic m/z",
+              "value": 830.8834
+            },
             {
               "accession": "MS:1001975",
               "cv_param_group": "1",
@@ -3381,7 +3391,8 @@
               "accession": "MS:1000885",
               "cv_param_group": "2",
               "name": "protein accession",
-              "value": "\"tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1\""
+              "value": "G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1",
+              "value_accession": "tr"
             }
           ],
           "id": "1"
@@ -3404,11 +3415,6 @@
           "value": "singleton spectrum",
           "value_accession": "MS:1003066"
         },
-        {
-          "accession": "MS:1003208",
-          "name": "experimental precursor monoisotopic m/z",
-          "value": 830.8834
-        },
         {
           "accession": "MS:1000044",
           "name": "dissociation method",
@@ -3774,6 +3780,11 @@
               "name": "charge state",
               "value": 2
             },
+            {
+              "accession": "MS:1003208",
+              "name": "experimental precursor monoisotopic m/z",
+              "value": 830.8834
+            },
             {
               "accession": "MS:1001975",
               "cv_param_group": "1",
@@ -3831,7 +3842,8 @@
               "accession": "MS:1000885",
               "cv_param_group": "2",
               "name": "protein accession",
-              "value": "\"tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1\""
+              "value": "G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1",
+              "value_accession": "tr"
             }
           ],
           "id": "1"
@@ -3854,11 +3866,6 @@
           "value": "singleton spectrum",
           "value_accession": "MS:1003066"
         },
-        {
-          "accession": "MS:1003208",
-          "name": "experimental precursor monoisotopic m/z",
-          "value": 830.8834
-        },
         {
           "accession": "MS:1000044",
           "name": "dissociation method",
diff --git a/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.txt b/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.txt
index 226cdf8..b6c8631 100644
--- a/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.txt
+++ b/tests/test_data/chinese_hamster_hcd_selected_head.mzlb.txt
@@ -1,4 +1,5 @@
 <mzSpecLib 1.0>
+MS:1003186|library format version=1.0
 MS:1003188|library name=tests/test_data/chinese_hamster_hcd_selected_head
 <AttributeSet Spectrum=all>
 <AttributeSet Analyte=all>
@@ -6,7 +7,6 @@ MS:1003188|library name=tests/test_data/chinese_hamster_hcd_selected_head
 <Spectrum=1>
 MS:1003061|library spectrum name=AAAACALTPGPLADLAAR/2_1(4,C,CAM)_46eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=855.4538
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=46
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -30,6 +30,7 @@ MS:1003059|number of peaks=87
 MS:1000224|molecular mass=1710.9076
 MS:1000888|stripped peptide sequence=AAAACALTPGPLADLAAR
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=855.4538
 [1]MS:1001975|delta m/z=1.4
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=855.455
@@ -39,7 +40,7 @@ MS:1001117|theoretical mass=1708.89303961159
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=R
 [2]MS:1001113|c-terminal flanking residue=L
-[2]MS:1000885|protein accession="tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.2848
 MS:1003080|top 20 peak unassigned intensity fraction=0.1879
@@ -137,7 +138,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=4
 <Spectrum=2>
 MS:1003061|library spectrum name=AAAACALTPGPLADLAAR/2_1(4,C,CAM)_53eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=855.4538
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=53
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -161,6 +161,7 @@ MS:1003059|number of peaks=204
 MS:1000224|molecular mass=1710.9076
 MS:1000888|stripped peptide sequence=AAAACALTPGPLADLAAR
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=855.4538
 [1]MS:1001975|delta m/z=4.2
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=855.4574
@@ -170,7 +171,7 @@ MS:1001117|theoretical mass=1708.89303961159
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=R
 [2]MS:1001113|c-terminal flanking residue=L
-[2]MS:1000885|protein accession="tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3IJB9|G3IJB9_CRIGR UDP-N-acetylhexosamine pyrophosphorylase-like protein 1 OS=Cricetulus griseus GN=I79_023952 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.3165
 MS:1003080|top 20 peak unassigned intensity fraction=0.142
@@ -385,7 +386,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=5
 <Spectrum=3>
 MS:1003061|library spectrum name=AAAAGQTGTVPPGAPGALPLPGMAIVK/2_0_76eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=1207.1672
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=76
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -409,6 +409,7 @@ MS:1003059|number of peaks=122
 MS:1000224|molecular mass=2414.3344
 MS:1000888|stripped peptide sequence=AAAAGQTGTVPPGAPGALPLPGMAIVK
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=1207.1672
 [1]MS:1001975|delta m/z=-0.9
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=1207.1661
@@ -418,7 +419,7 @@ MS:1001117|theoretical mass=2412.319901150229
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=A
 [2]MS:1001113|c-terminal flanking residue=E
-[2]MS:1000885|protein accession="tr|G3I2Q7|G3I2Q7_CRIGR Transcription intermediary factor 1-beta OS=Cricetulus griseus GN=I79_017700 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3I2Q7|G3I2Q7_CRIGR Transcription intermediary factor 1-beta OS=Cricetulus griseus GN=I79_017700 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.2591
 MS:1003080|top 20 peak unassigned intensity fraction=0.0
@@ -551,7 +552,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=0
 <Spectrum=4>
 MS:1003061|library spectrum name=AAAAGSTSVKPIFSR/2_0_44eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=731.9043
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=44
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -575,6 +575,7 @@ MS:1003059|number of peaks=111
 MS:1000224|molecular mass=1463.8086
 MS:1000888|stripped peptide sequence=AAAAGSTSVKPIFSR
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=731.9043
 [1]MS:1001975|delta m/z=-2.7
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=731.9023
@@ -584,7 +585,7 @@ MS:1001117|theoretical mass=1461.7939769138902
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=Q
 [2]MS:1001113|c-terminal flanking residue=D
-[2]MS:1000885|protein accession="tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.1681
 MS:1003080|top 20 peak unassigned intensity fraction=0.0217
@@ -706,7 +707,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=1
 <Spectrum=5>
 MS:1003061|library spectrum name=AAAAGSTSVKPIFSR/3_0_28eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=488.2719
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=28
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -730,6 +730,7 @@ MS:1003059|number of peaks=161
 MS:1000224|molecular mass=1464.8157
 MS:1000888|stripped peptide sequence=AAAAGSTSVKPIFSR
 MS:1000041|charge state=3
+MS:1003208|experimental precursor monoisotopic m/z=488.2719
 [1]MS:1001975|delta m/z=3.8
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=488.2738
@@ -739,7 +740,7 @@ MS:1001117|theoretical mass=1461.7939769138902
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=Q
 [2]MS:1001113|c-terminal flanking residue=D
-[2]MS:1000885|protein accession="tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3I0F4|G3I0F4_CRIGR NADH dehydrogenase [ubiquinone] 1 alpha subcomplex subunit 6 OS=Cricetulus griseus GN=I79_016836 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.1804
 MS:1003080|top 20 peak unassigned intensity fraction=0.0
@@ -911,7 +912,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=0
 <Spectrum=6>
 MS:1003061|library spectrum name=AAAALGSHGSCSSEVEK/2_1(10,C,CAM)_50eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=830.8834
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=50
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -935,6 +935,7 @@ MS:1003059|number of peaks=68
 MS:1000224|molecular mass=1661.7668
 MS:1000888|stripped peptide sequence=AAAALGSHGSCSSEVEK
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=830.8834
 [1]MS:1001975|delta m/z=4.1
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=830.8868
@@ -944,7 +945,7 @@ MS:1001117|theoretical mass=1659.7522486039798
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=K
 [2]MS:1001113|c-terminal flanking residue=E
-[2]MS:1000885|protein accession="tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.4368
 MS:1003080|top 20 peak unassigned intensity fraction=0.184
@@ -1023,7 +1024,6 @@ MS:1003290|number of unassigned peaks among top 20 peaks=6
 <Spectrum=7>
 MS:1003061|library spectrum name=AAAALGSHGSCSSEVEK/2_1(10,C,CAM)_52eV
 MS:1003065|spectrum aggregation type=MS:1003066|singleton spectrum
-MS:1003208|experimental precursor monoisotopic m/z=830.8834
 MS:1000044|dissociation method=MS:1000422|beam-type collision-induced dissociation
 [1]MS:1000045|collision energy=52
 [1]UO:0000000|unit=UO:0000266|electronvolt
@@ -1047,6 +1047,7 @@ MS:1003059|number of peaks=402
 MS:1000224|molecular mass=1661.7668
 MS:1000888|stripped peptide sequence=AAAALGSHGSCSSEVEK
 MS:1000041|charge state=2
+MS:1003208|experimental precursor monoisotopic m/z=830.8834
 [1]MS:1001975|delta m/z=-2.0
 [1]UO:0000000|unit=UO:0000169|parts per million
 MS:1003208|experimental precursor monoisotopic m/z=830.8817
@@ -1056,7 +1057,7 @@ MS:1001117|theoretical mass=1659.7522486039798
 [2]MS:1001045|cleavage agent name=MS:1001251|Trypsin
 [2]MS:1001112|n-terminal flanking residue=K
 [2]MS:1001113|c-terminal flanking residue=E
-[2]MS:1000885|protein accession="tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1"
+[2]MS:1000885|protein accession=tr|G3HHY9|G3HHY9_CRIGR V-type proton ATPase subunit G 1 OS=Cricetulus griseus GN=I79_010250 PE=4 SV=1
 <Interpretation=1>
 MS:1003079|total unassigned intensity fraction=0.339
 MS:1003080|top 20 peak unassigned intensity fraction=0.0816