Skip to content

Commit

Permalink
Fix usage of config file in GUI (was not parsed at all); fix bugs fro…
Browse files Browse the repository at this point in the history
…m previous commit
  • Loading branch information
RalfG committed Oct 12, 2023
1 parent e16a3b1 commit dee9349
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ms2rescore/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def rescore(configuration: Dict, psm_list: Optional[PSMList] = None) -> None:
logger.debug("Using %i of %i available CPUs.", int(config["processes"]), int(cpu_count()))

# Parse PSMs
psm_list = parse_psms(config, psm_list, output_file_root)
psm_list = parse_psms(config, psm_list)

# Log #PSMs identified before rescoring
id_psms_before = _log_id_psms_before(psm_list)
Expand Down
8 changes: 4 additions & 4 deletions ms2rescore/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _parse_modification_mapping(table_output):
for mod in table_output:
if mod[0] and mod[1]:
modification_map[mod[0].strip()] = mod[1].strip()
return modification_map
return modification_map or None

@staticmethod
def _parse_fixed_modifications(table_output):
Expand All @@ -252,7 +252,7 @@ def _parse_fixed_modifications(table_output):
if mod[0] and mod[1]:
amino_acids = [aa.upper() for aa in mod[1].strip().split(",")]
fixed_modifications[mod[0]] = amino_acids
return fixed_modifications
return fixed_modifications or None


class PSMFileConfigFrame(ctk.CTkFrame):
Expand Down Expand Up @@ -612,7 +612,7 @@ def __init__(self, *args, **kwargs):
self.configure(fg_color="transparent")
self.grid_columnconfigure(0, weight=1)

self.title = widgets.Heading(self, text="Percolator configuration")
self.title = widgets.Heading(self, text="Percolator coffeeguration")
self.title.grid(row=0, column=0, columnspan=2, pady=(0, 5), sticky="ew")

self.weights_file = widgets.LabeledFileSelect(
Expand All @@ -629,7 +629,7 @@ def get(self) -> Dict:
def function(config):
"""Function to be executed in a separate process."""
config = config.copy()
config = parse_configurations(config)
config = parse_configurations([config["ms2rescore"]["config_file"], config])
rescore(configuration=config)


Expand Down
6 changes: 3 additions & 3 deletions ms2rescore/parse_psms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import re
from typing import Dict, Union
from itertools import chain
from typing import Dict, Union

import psm_utils.io
from psm_utils import PSMList
Expand Down Expand Up @@ -88,7 +88,7 @@ def _read_psms(config, psm_list):
psm_list_list.append(id_file_psm_list)
current_file += 1

return PSMList(psm_list=chain.from_iterable(p.psm_list for p in psm_list_list))
return PSMList(psm_list=list(chain.from_iterable(p.psm_list for p in psm_list_list)))


def _find_decoys(config, psm_list):
Expand Down Expand Up @@ -124,7 +124,7 @@ def _match_psm_ids(old_id, regex_pattern):
try:
return match[1]
except (TypeError, IndexError):
raise MS2RescoreError(
raise MS2RescoreConfigurationError(
"`psm_id_pattern` could not be matched to all PSM spectrum IDs."
" Ensure that the regex contains a capturing group?"
)
2 changes: 1 addition & 1 deletion ms2rescore/parse_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _parse_values_from_mgf(
)

for spectrum in MGF(str(spectrum_file)):
matched_id = spectrum_id_pattern.match(spectrum["id"]).group()
matched_id = spectrum_id_pattern.match(spectrum["params"]["title"]).group()
if missing_rt:
try:
rt_dict[matched_id] = float(spectrum["params"]["rtinseconds"])
Expand Down

0 comments on commit dee9349

Please sign in to comment.