Added peak level annotations support #83
Added peak level annotations support #83bhavyak7-lab wants to merge 13 commits intowfondrie:mainfrom
Conversation
depthcharge/data/parsers.py
Outdated
|
|
||
| raise ValueError("Invalid precursor charge.") | ||
|
|
||
| class AsfParser(BaseParser): |
There was a problem hiding this comment.
Can ASF parser extend the MGF parser instead? Might reduce a little bit of redundancy.
depthcharge/data/parsers.py
Outdated
| if "=" in line: | ||
| key, value = line.split("=", 1) | ||
| if key == "CHARGE": | ||
| if len(value) == 2: |
There was a problem hiding this comment.
What is this length = 2 check for?
| if len(value) == 2: | ||
| value = value[0] | ||
|
|
||
| if key == "PEPMASS": |
There was a problem hiding this comment.
We do not always expect a precursor intensity to also be provided (in fact unless you do a special feature extraction step DIA data we will never have it). We should handle not having it.
There was a problem hiding this comment.
This case would be handled by the final line: spectrum["params"][key.lower()] = [value]
| if key == "SEQ": | ||
| spectrum["params"][key.lower()] = value | ||
| continue | ||
|
|
There was a problem hiding this comment.
Can we add support for skipping spectra where key parameters are missing / of the incorrect format, and warn the users that these spectra were skipped?
There was a problem hiding this comment.
If the charge is outside of the range, the iter_batches method throws an error. Should I also throw an error here?
| yield _iter() | ||
|
|
||
|
|
||
| def parse_spectrum(self, spectrum: dict) -> MassSpectrum: |
There was a problem hiding this comment.
This function is 99% the same as the one for MGF parser. If we extend that class instead, this can just call super() and then set the peak_annotations=spectrum["peak_annotations"] on the result.
|
The failing TDF tests are due to a file-reading issue with MACOS as the tests pass on Linux. |
Changes made:
Users can extract peak level annotations by creating a custom field to extract them, and they are stored in the spectrum dictionary