Skip to content

Commit

Permalink
Merge pull request #103 from compomics/minor
Browse files Browse the repository at this point in the history
Better logging for modification mapping; fix pyOpenMS issue in Dockerfile
  • Loading branch information
RalfG authored Nov 1, 2023
2 parents 598ec54 + 8dda81f commit e44b30a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ ADD README.md /ms2rescore/README.md
ADD MANIFEST.in /ms2rescore/MANIFEST.in
ADD ms2rescore /ms2rescore/ms2rescore

RUN apt-get update && apt-get install python3-pip procps -y \
RUN apt-get update \
&& apt-get install -y python3-pip procps libglib2.0-0 libsm6 libxrender1 libxext6 \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install ms2rescore/

Expand Down
20 changes: 18 additions & 2 deletions ms2rescore/parse_psms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,29 @@ def parse_psms(config: Dict, psm_list: Union[PSMList, None]) -> PSMList:
)

logger.debug("Parsing modifications...")
modifications_found = set(
[
re.search(r"\[([^\[\]]*)\]", x.proforma).group(1)
for x in psm_list["peptidoform"]
if "[" in x.proforma
]
)
logger.debug(f"Found modifications: {modifications_found}")
non_mapped_modifications = modifications_found - set(config["modification_mapping"].keys())
if non_mapped_modifications:
logger.warning(
f"Non-mapped modifications found: {non_mapped_modifications}\nThis can be ignored if Unimod modification label"
)
psm_list.rename_modifications(config["modification_mapping"])
psm_list.add_fixed_modifications(config["fixed_modifications"])
psm_list.apply_fixed_modifications()

logger.debug("Applying `psm_id_pattern`...")
if config["psm_id_pattern"]:
pattern = re.compile(config["psm_id_pattern"])
logger.debug(f"Applying `psm_id_pattern`...")
logger.debug(
f"Parsing `{psm_list['spectrum_id'][0]}` to `{_match_psm_ids(psm_list['spectrum_id'][0], pattern)}`"
)
new_ids = [_match_psm_ids(old_id, pattern) for old_id in psm_list["spectrum_id"]]
psm_list["spectrum_id"] = new_ids

Expand Down Expand Up @@ -125,6 +141,6 @@ def _match_psm_ids(old_id, regex_pattern):
return match[1]
except (TypeError, IndexError):
raise MS2RescoreConfigurationError(
"`psm_id_pattern` could not be matched to all PSM spectrum IDs."
f"`psm_id_pattern` could not be extracted from PSM spectrum IDs (i.e. {old_id})."
" Ensure that the regex contains a capturing group?"
)

0 comments on commit e44b30a

Please sign in to comment.