-
Notifications
You must be signed in to change notification settings - Fork 30
Updated changes #79
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
base: main
Are you sure you want to change the base?
Updated changes #79
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -400,12 +400,12 @@ def aa(self, tree) -> None: | |
| self._sequence.append(tree[0]) | ||
| # An amino acid token can be followed by (i) a modification on that | ||
| # residue, or (ii) a label (linking it to another modified residue). | ||
| if isinstance(tree[1], Label): | ||
| if len(tree) > 1 and isinstance(tree[1], Label): | ||
| # noinspection PyArgumentList | ||
| self._modifications.append( | ||
| Modification(position=position, label=tree[1]) | ||
| ) | ||
| elif isinstance(tree[1], Modification): | ||
| elif len(tree) > 1 and isinstance(tree[1], Modification): | ||
| tree[1].position = position | ||
| self._modifications.append(tree[1]) | ||
|
|
||
|
|
@@ -879,10 +879,8 @@ def _parse_obo( | |
| elif ( | ||
| cv_id == "XLMOD" | ||
| and isinstance(clause, fastobo.term.PropertyValueClause) | ||
| and ( | ||
| clause.property_value.relation.prefix | ||
| == "monoIsotopicMass" | ||
| ) | ||
| and "monoIsotopicMass" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: What is the advantage of the new version vs the previous code?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well the main reason for this change because from the previous code we were facing attribute error ,as it was depending on how fastobo parses the OBO file, the relation might include an extra colon or whitespace (e.g. "monoIsotopicMass:" or with surrounding spaces) as seen in XLMOD.obo file. so i change the previous implementation so that minor formatting differences don’t cause the condition to fail. |
||
| in str(clause.property_value.relation) | ||
| ): | ||
| term_mass = float(clause.property_value.value) | ||
| elif cv_id == "GNO" and isinstance( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| import copy | ||
| import functools | ||
| import urllib.parse | ||
|
|
@@ -22,7 +23,13 @@ def __init__(self, **kwargs): | |
|
|
||
|
|
||
| # Reload the Pyteomics PROXI aggregator to also include GNPS. | ||
| pyteomics.usi._proxies["gnps"] = GnpsBackend | ||
| # Only perform the assignment if not building docs. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Why is this necessary?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi @bittremieux ,its good to see u again .so this ensures that the GNPS backend will be used for normal runtime usage, while avoiding potential issues during Sphinx documentation builds or in environments .so that while doing doctest it should not cause any issue . |
||
| if not os.environ.get("SPHINX_BUILD"): | ||
| try: | ||
| pyteomics.usi._proxies["gnps"] = GnpsBackend | ||
| except Exception: | ||
| pass | ||
|
|
||
| pyteomics.usi.AGGREGATOR = pyteomics.usi.PROXIAggregator() | ||
|
|
||
|
|
||
|
|
@@ -75,7 +82,7 @@ def intensity(self) -> np.ndarray: | |
| def round( | ||
| self, decimals: int = 0, combine: str = "sum" | ||
| ) -> "MsmsSpectrumJit": | ||
| mz_round = np.round_(self._mz, decimals, np.empty_like(self._mz)) | ||
| mz_round = np.round(self._mz, decimals, np.empty_like(self._mz)) | ||
| mz_unique = np.unique(mz_round) | ||
| if len(mz_unique) == len(mz_round): | ||
| self._mz = mz_unique | ||
|
|
@@ -646,13 +653,24 @@ def _annotate_proteoforms( | |
| (since parsing the sequence is a lot slower than annotating the | ||
| peaks). | ||
|
|
||
| >>> import spectrum_utils.spectrum as sus | ||
| >>> identifier = "test_spec" | ||
| >>> precursor_mz = 500.0 | ||
| >>> precursor_charge = 2 | ||
| >>> mz_array = np.array([100.0, 200.0, 300.0]) | ||
| >>> intensity_array = np.array([10.0, 20.0, 30.0]) | ||
|
|
||
| >>> spec = sus.MsmsSpectrum(identifier, precursor_mz, precursor_charge, mz_array, intensity_array) | ||
| >>> proforma_sequence = "MYPEPTIDEK/2" | ||
| >>> spectrum.annotate_proforma(proforma_sequence, ...) | ||
| >>> _ = spec.annotate_proforma(proforma_str =proforma_sequence, fragment_tol_mass=10.0, | ||
| ... fragment_tol_mode ="ppm", ion_types="by") | ||
|
|
||
| or | ||
| --- or | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo: This interprets it as a Python
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay i will update this also .but is not causing any issue + it will help in maintaining the identation with other code . |
||
|
|
||
| >>> parsed_proforma = proforma.parse(proforma_sequence) | ||
| >>> spectrum._annotate_proteoforms(parsed_proforma, proforma_sequence, ...) | ||
| >>> _ = spec._annotate_proteoforms(proteoforms=parsed_proforma, proforma_str =proforma_sequence, | ||
| ... fragment_tol_mass=10.0, fragment_tol_mode ="ppm", ion_types="by") | ||
|
|
||
|
|
||
| WARN: | ||
| This function does not check that the passed sequence | ||
|
|
@@ -704,6 +722,7 @@ def _annotate_proteoforms( | |
| > fragment_tol_mass | ||
| ): | ||
| fragment_i += 1 | ||
|
|
||
| i = 0 | ||
| while ( | ||
| fragment_i + i < len(fragments) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.