-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spectrum feature generator #178
base: main
Are you sure you want to change the base?
Conversation
…into spectrum-feature-generator
…into spectrum-feature-generator
…into spectrum-feature-generator
…trum-feature-generator
pull main in spectrum-feature-generator
…pectrum-feature-generator
…mics/ms2rescore into spectrum-feature-generator
…mics/ms2rescore into spectrum-feature-generator
(psm_list["qvalue"] <= 0.01) | ||
& (psm_list["rank"] <= max_rank) | ||
& (~psm_list["is_decoy"]) | ||
& ([metadata.get("original_psm", True) for metadata in psm_list["metadata"]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it might be quite inefficient, however I'm not sure if it can be improved significantly, given that original_psm is in the metadata dict. Maybe keeping it a series instead of a list might be better. Or adding it to the dataframe.
ms2rescore/utils.py
Outdated
if original_matched_ions_pct > matched_ions[i]: | ||
keep[i] = False | ||
else: | ||
keep[i] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if original_matched_ions_pct > matched_ions[i]: | |
keep[i] = False | |
else: | |
keep[i] = True | |
keep[i] = original_matched_ions_pct <= matched_ions[i] |
ms2rescore/utils.py
Outdated
if "matched_ions_pct" in psm_list[0].rescoring_features: | ||
matched_ions = [psm.rescoring_features["matched_ions_pct"] for psm in psm_list] | ||
else: | ||
return psm_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if "matched_ions_pct" in psm_list[0].rescoring_features: | |
matched_ions = [psm.rescoring_features["matched_ions_pct"] for psm in psm_list] | |
else: | |
return psm_list | |
if "matched_ions_pct" not in psm_list[0].rescoring_features: | |
return psm_list | |
else: | |
matched_ions = [psm.rescoring_features["matched_ions_pct"] for psm in psm_list] |
|
||
|
||
class MS2FeatureGenerator(FeatureGeneratorBase): | ||
"""DeepLC retention time-based feature generator.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this docstring should be updated?
} | ||
except AttributeError: | ||
raise ParseSpectrumError( | ||
"Could not parse spectrum IDs using ´spectrum_id_pattern´. Please make sure that there is a capturing in the pattern." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a capture group with "a capturing"?
ms2rescore/feature_generators/ms2.py
Outdated
for peak in annotated_spectrum: | ||
|
||
for fragment in peak.annotation: | ||
|
||
ion_type = infer_fragment_identity(fragment) | ||
|
||
if ion_type == 'b': | ||
b_intensities.append(peak.intensity) | ||
if ion_type == 'y': | ||
y_intensities.append(peak.intensity) | ||
return b_intensities, y_intensities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for peak in annotated_spectrum: | |
for fragment in peak.annotation: | |
ion_type = infer_fragment_identity(fragment) | |
if ion_type == 'b': | |
b_intensities.append(peak.intensity) | |
if ion_type == 'y': | |
y_intensities.append(peak.intensity) | |
return b_intensities, y_intensities | |
for peak in annotated_spectrum: | |
for fragment in peak.annotation: | |
ion_type = infer_fragment_identity(fragment) | |
if ion_type == 'b': | |
b_intensities.append(peak.intensity) | |
elif ion_type == 'y': | |
y_intensities.append(peak.intensity) | |
return b_intensities, y_intensities |
return annotated_spectrum.spectrum | ||
|
||
|
||
def factorial(n): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to use a custom function instead of math.factorial
?
ms2rescore/feature_generators/ms2.py
Outdated
if spectrum_filepath.suffix.lower() == ".mzml": | ||
return mzml.PreIndexedMzML(str(spectrum_filepath)) | ||
elif spectrum_filepath.suffix.lower() == ".mgf": | ||
return mgf.IndexedMGF(str(spectrum_filepath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to avoid failing silently and add an else and raise an e.g. NotImplementedError
or ValueError
.
…rator * origin/main: Use np.fromiter for generators Implement requested changes (.copy; use generators) Urgent fix in im2deep.py require ms2rescore-rs version with file type check move file type check to ms2rescore_rs Pin DeepLC version to <3.1, avoiding calibration bug Refactor parsing of spectrum data: - Clearer logging when parsing precursor info from spectrum files - Always check if PSMs match with spectra based on observed precursor m/z (if available in PSM list) - Always raise error if not all PSMs can be found in spectrum file(s), before MS²PIP - Provide example PSM IDs from both PSM and spectrum file when matching fails. - Move all code to parse_spectra
rustyms 0.9.0a3 requires python 3.11, while we support 3.9.
As mumble hasn't been published on pypi yet, use a git dependency for now.
597544b
to
aee8ec7
Compare
It might be worth considering setting these by default when running mumble through ms2rescore, given that these are kind of required for it to work, so at least it should be documented:
|
im2deep.utils was introduced in 0.3.0. compomics/IM2Deep@0a4bc9d
I had a quick look at the python 3.9 failure: this is because of mumble, which requires python 3.10. I think we could probably lower the requirement in mumble, as I don't think we actually use any new features, unless some of the dependencies do. And otherwise, we could of course just consider dropping python 3.9 for ms2rescore. For the record, I used poetry to get a more useful error from the dependency resolver (adding the version to pyproject.toml, it seems dynamic version fields aren't supported):
|
No description provided.