Skip to content

Commit

Permalink
Merge pull request #7 from bigbio/dev
Browse files Browse the repository at this point in the history
major changes about PSMs bugs.
  • Loading branch information
ypriverol authored Dec 22, 2024
2 parents 644cbfa + 87ad69f commit 20d4299
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ypriverol@gmail.com>",
"Dai Chengxin <chengxin2024@126.com>",
Expand Down
2 changes: 1 addition & 1 deletion quantmsrescore/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.2"
__version__ = "0.0.3"
18 changes: 16 additions & 2 deletions quantmsrescore/ms2rescore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand All @@ -61,14 +62,24 @@ 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 = []
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
# 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)

def _parse_psm(
self,
Expand Down Expand Up @@ -239,12 +250,15 @@ 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
# 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)
Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# recipe/meta.yaml
package:
name: quantms-rescoring
version: "0.0.2"
version: "0.0.3"

source:
path: ../
Expand Down

0 comments on commit 20d4299

Please sign in to comment.