From 26762201a6627a3181504552b1fe056f1b47c0b6 Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Fri, 23 Aug 2024 14:10:48 +0200 Subject: [PATCH 1/2] move file type check to ms2rescore_rs Note that the first regex match would always fail, assuming the extension wasn't the complete filename, so the for loop would always trigger. The exists check was added instead, and is needed for e.g. gzipped files when the run name would be without the .gz extension. --- ms2rescore/utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ms2rescore/utils.py b/ms2rescore/utils.py index 3515893..2d2d157 100644 --- a/ms2rescore/utils.py +++ b/ms2rescore/utils.py @@ -1,11 +1,11 @@ import logging import os -import re from glob import glob from pathlib import Path from typing import Optional, Union from ms2rescore.exceptions import MS2RescoreConfigurationError +from ms2rescore_rs import is_supported_file_type logger = logging.getLogger(__name__) @@ -66,11 +66,9 @@ def infer_spectrum_path( ) # Match with file extension if not in resolved_path yet - if not _is_minitdf(resolved_path) and not re.match( - r"\.mgf$|\.mzml$|\.d$", resolved_path, flags=re.IGNORECASE - ): + if not is_supported_file_type(resolved_path) or not os.path.exists(resolved_path): for filename in glob(resolved_path + "*"): - if re.match(r".*(\.mgf$|\.mzml$|\.d)", filename, flags=re.IGNORECASE): + if is_supported_file_type(filename): resolved_path = filename break else: From e97d5f63c1a6cd90567ff84c68f155265b191fbd Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Tue, 29 Oct 2024 14:06:41 +0100 Subject: [PATCH 2/2] require ms2rescore-rs version with file type check --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8356b3f..9f873ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ dependencies = [ "lxml>=4.5", "mokapot>=0.10", "ms2pip>=4.0.0", - "ms2rescore_rs>=0.3.0", + "ms2rescore_rs>=0.4.0", "numpy>=1.25", "pandas>=1", "plotly>=5",