Skip to content

Commit

Permalink
Merge branch 'releases' of https://github.com/compomics/ms2pip_c into…
Browse files Browse the repository at this point in the history
… fix/deps
  • Loading branch information
RalfG committed Nov 20, 2024
2 parents 1d85f90 + 32398ad commit 26d7264
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Python and C.
``DVAQIFNNILR/2``.

You can install MS²PIP on your machine by following the
`installation instructions <https://ms2pip.readthedocs.io/installation/>`_. For a more
`installation instructions <https://ms2pip.readthedocs.io/en/latest/installation/>`_. For a more
user-friendly experience, go to the `MS²PIP web server <https://iomics.ugent.be/ms2pip>`_. There,
you can easily upload a list of peptide sequences, after which the corresponding predicted MS2
spectra can be downloaded in multiple file formats. The web server can also be contacted through
Expand Down
2 changes: 1 addition & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ For instance:

.. code-block:: sh
ms2pip correlate results.sage.tsv --spectrum-file spectra.mgf
ms2pip correlate --psm-filetype sage results.sage.tsv spectra.mgf
``get-training-data``
Expand Down
21 changes: 5 additions & 16 deletions ms2pip/spectrum_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def read_spectrum_file(spectrum_file: str) -> Generator[ObservedSpectrum, None,
If the file extension is not supported.
"""
file_extension = Path(spectrum_file).suffix.lower()
if file_extension not in [".mgf", ".mzml", ".d"] and not _is_minitdf(spectrum_file):
raise UnsupportedSpectrumFiletypeError(file_extension)
try:
spectra = get_ms2_spectra(str(spectrum_file))
except ValueError:
raise UnsupportedSpectrumFiletypeError(Path(spectrum_file).suffixes)

for spectrum in get_ms2_spectra(str(spectrum_file)):
for spectrum in spectra:
obs_spectrum = ObservedSpectrum(
mz=np.array(spectrum.mz, dtype=np.float32),
intensity=np.array(spectrum.intensity, dtype=np.float32),
Expand All @@ -50,15 +51,3 @@ def read_spectrum_file(spectrum_file: str) -> Generator[ObservedSpectrum, None,
):
continue
yield obs_spectrum


def _is_minitdf(spectrum_file: str) -> bool:
"""
Check if the spectrum file is a Bruker miniTDF folder.
A Bruker miniTDF folder has no fixed name, but contains files matching the patterns
``*ms2spectrum.bin`` and ``*ms2spectrum.parquet``.
"""
files = set(Path(spectrum_file).glob("*ms2spectrum.bin"))
files.update(Path(spectrum_file).glob("*ms2spectrum.parquet"))
return len(files) >= 2

0 comments on commit 26d7264

Please sign in to comment.