Skip to content

Commit

Permalink
Update CI workflow, fix validator from previous discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed Apr 19, 2024
1 parent 08fa441 commit 7b03637
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 76 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ __pycache__
*.ipynb
examples/*splindex
.coverage
htmlcov/
htmlcov/
dist/
build/
29 changes: 15 additions & 14 deletions examples/chinese_hamster_hcd_selected_head.mzlb.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<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>
<AttributeSet Interpretation=all>
<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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mzlib/validate/rules/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
],
"combination_logic": "OR",
"id": "Spectrum_has_precursor_mz",
"level": "SHOULD",
"level": "MAY",
"path": "/Library/Spectrum"
},
{
Expand Down
8 changes: 7 additions & 1 deletion mzlib/validate/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
Loading

0 comments on commit 7b03637

Please sign in to comment.