-
Notifications
You must be signed in to change notification settings - Fork 15
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.
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] |
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"?
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
?
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
.
No description provided.