Repository navigation
Read scan time unit from unitAccession, handle missing scan time - #414
Conversation
scan_time_in_minutes() raised 'Time unit unicorns unknown' when the scan start time cvParam had a unitAccession but no unitName (unitName is optional in the mzML schema), raised for millisecond because of an if that should be elif, and raised AttributeError for spectra without a scan start time. Fall back to the UO accession for the unit name, fix the elif, and return None when there is no scan start time.
|
|
Thanks for the thorough write-up and tests, looks solid to me! I'll approve and merge once I had a closer look later this week. Best |
Thanks Manuel! Agreed the OBO lookup would be a nicer long-term fix, happy to help there if useful. |



Spectrum.scan_time_in_minutes()raises in three cases:unitAccession="UO:0000010"but nounitName:Exception: Time unit 'unicorns' unknown. In the mzML 1.1 schemaunitNameis optional, andunitAccessionis what identifies the unit.ifwhere it should be anelif, so the millisecond value falls through to theelseand raises.AttributeError: 'NoneType' object has no attribute 'lower'.pyteomics/tests/tiny.pwiz.1.1.mzML(written by ProteoWizard) has such a spectrum (scan=21). Scan start time is not required by the mzML mapping rules.Fix: fall back to the UO accession (UO:0000028, UO:0000010, UO:0000031, UO:0000032) when
unitNameis missing, turn theifinto anelif, and return None when there is no scan start time. An unknown unit still raises, as before.Tested:
tests/scan_time_unit_test.py(5 tests). 3 fail on dev and all 5 pass with the fix.tiny.pwiz.1.1.mzMLnow reads to the end, withscan=21returning None.