From 251db6a2046ff97e279634dc3f9d1f535fe318e7 Mon Sep 17 00:00:00 2001 From: Chengxin Dai <37200167+daichengxin@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:13:29 +0800 Subject: [PATCH 1/6] fixed bugs --- quantmsrescore/ms2rescore.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/quantmsrescore/ms2rescore.py b/quantmsrescore/ms2rescore.py index 9d02c50..5251123 100644 --- a/quantmsrescore/ms2rescore.py +++ b/quantmsrescore/ms2rescore.py @@ -36,6 +36,7 @@ def __init__(self, filename: Union[Path, str], *args, **kwargs) -> None: self.user_params_metadata = self._get_userparams_metadata(self.peptide_ids[0].getHits()[0]) self.rescoring_features = self._get_rescoring_features(self.peptide_ids[0].getHits()[0]) self.skip_invalid_psm = 0 + self.new_peptide_ids = [] def __iter__(self) -> Iterable[PSM]: """ @@ -63,12 +64,16 @@ def __iter__(self) -> Iterable[PSM]: """ for peptide_id in self.peptide_ids: + new_hits = [] for peptide_hit in peptide_id.getHits(): psm = self._parse_psm(self.protein_ids, peptide_id, peptide_hit) if psm is not None: + new_hits.append(peptide_hit) yield psm else: self.skip_invalid_psm += 1 + peptide_id.setHits(new_hits) + self.new_peptide_ids.append(peptide_id) def _parse_psm( self, @@ -239,12 +244,14 @@ def rescore_idxml(input_file, output_file, config) -> None: logging.warning( f"Removed {reader.skip_invalid_psm} PSMs without search engine features!" ) - + peptide_ids = reader.new_peptide_ids + else: + peptide_ids = reader.peptide_ids # Rescore rescore(config, psm_list) # Filter out PeptideHits within PeptideIdentification(s) that could not be processed by all feature generators - peptide_ids_filtered = filter_out_artifact_psms(psm_list, reader.peptide_ids) + peptide_ids_filtered = filter_out_artifact_psms(psm_list, peptide_ids) # Write writer = IdXMLWriter(output_file, reader.protein_ids, peptide_ids_filtered) From 3a16a96cca13cda917ff3c074274adeb056b3c6c Mon Sep 17 00:00:00 2001 From: Chengxin Dai <37200167+daichengxin@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:13:48 +0800 Subject: [PATCH 2/6] Update __init__.py --- quantmsrescore/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantmsrescore/__init__.py b/quantmsrescore/__init__.py index 3b93d0b..27fdca4 100644 --- a/quantmsrescore/__init__.py +++ b/quantmsrescore/__init__.py @@ -1 +1 @@ -__version__ = "0.0.2" +__version__ = "0.0.3" From dcac9517890c3da7728407e60018a047bd66e5ce Mon Sep 17 00:00:00 2001 From: Chengxin Dai <37200167+daichengxin@users.noreply.github.com> Date: Sun, 22 Dec 2024 15:25:59 +0800 Subject: [PATCH 3/6] fixed bugs for invalid psm --- quantmsrescore/ms2rescore.py | 5 +++-- recipe/meta.yaml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quantmsrescore/ms2rescore.py b/quantmsrescore/ms2rescore.py index 5251123..15edc6c 100644 --- a/quantmsrescore/ms2rescore.py +++ b/quantmsrescore/ms2rescore.py @@ -72,8 +72,9 @@ def __iter__(self) -> Iterable[PSM]: yield psm else: self.skip_invalid_psm += 1 - peptide_id.setHits(new_hits) - self.new_peptide_ids.append(peptide_id) + if len(new_hits) > 0: + peptide_id.setHits(new_hits) + self.new_peptide_ids.append(peptide_id) def _parse_psm( self, diff --git a/recipe/meta.yaml b/recipe/meta.yaml index b652f6d..c8d075c 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,7 +1,7 @@ # recipe/meta.yaml package: name: quantms-rescoring - version: "0.0.2" + version: "0.0.3" source: path: ../ From 3e8457f900beac1081db2eb596a49d994117f412 Mon Sep 17 00:00:00 2001 From: Chengxin Dai <37200167+daichengxin@users.noreply.github.com> Date: Sun, 22 Dec 2024 18:13:28 +0800 Subject: [PATCH 4/6] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 359648b..c620b2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "quantms-rescoring" description = "quantms-rescoring: Python scripts and helpers for the quantMS workflow" readme = "README.md" license = "MIT" -version = "0.0.2" +version = "0.0.3" authors = [ "Yasset Perez-Riverol ", "Dai Chengxin ", From 1f665cfb3e380ffe618dfed511b4d975b766f9f6 Mon Sep 17 00:00:00 2001 From: Chengxin Dai <37200167+daichengxin@users.noreply.github.com> Date: Sun, 22 Dec 2024 18:17:52 +0800 Subject: [PATCH 5/6] Update ms2rescore.py --- quantmsrescore/ms2rescore.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/quantmsrescore/ms2rescore.py b/quantmsrescore/ms2rescore.py index 15edc6c..10af8bb 100644 --- a/quantmsrescore/ms2rescore.py +++ b/quantmsrescore/ms2rescore.py @@ -72,6 +72,7 @@ def __iter__(self) -> Iterable[PSM]: yield psm else: self.skip_invalid_psm += 1 + # If it is a valid Peptide Hits then keep it if len(new_hits) > 0: peptide_id.setHits(new_hits) self.new_peptide_ids.append(peptide_id) @@ -245,6 +246,7 @@ def rescore_idxml(input_file, output_file, config) -> None: logging.warning( f"Removed {reader.skip_invalid_psm} PSMs without search engine features!" ) + # Synchronised acquisition of new peptide IDs after removing invalid PSMs peptide_ids = reader.new_peptide_ids else: peptide_ids = reader.peptide_ids From 144c60e334f385eee5ed05cf45a30b1fe8f54cf8 Mon Sep 17 00:00:00 2001 From: Chengxin Dai <37200167+daichengxin@users.noreply.github.com> Date: Sun, 22 Dec 2024 18:55:53 +0800 Subject: [PATCH 6/6] Update ms2rescore.py --- quantmsrescore/ms2rescore.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quantmsrescore/ms2rescore.py b/quantmsrescore/ms2rescore.py index 10af8bb..6ae7af3 100644 --- a/quantmsrescore/ms2rescore.py +++ b/quantmsrescore/ms2rescore.py @@ -62,6 +62,10 @@ def __iter__(self) -> Iterable[PSM]: psm_list: return [PSM 1] + The invalid PSM are directly from search engines results (MSGF+). The search engine doesn't report search + score features (e.g. MSGF:ScoreRatio) for these invalid PSMs. And we can observe the NumMatchedMainIons of + peptide hit is 0. So we should remove these invalid PSMs + """ for peptide_id in self.peptide_ids: new_hits = []