Skip to content

Commit 1e6e152

Browse files
committed
handle percolator pin file generated by comet
1 parent 53f7d94 commit 1e6e152

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

psm_utils/io/percolator.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,15 @@ def _infer_charge_columns(fieldnames):
149149
@staticmethod
150150
def _parse_peptidoform(percolator_peptide, charge):
151151
"""Parse Percolator TSV peptide notation to Peptidoform."""
152-
# Remove leading and trailing amino acids
152+
# Remove leading and trailing amino acids (e.g., R.PEPTIDE.S -> PEPTIDE)
153153
match = re.match(r"^(?:[A-Z-])?\.(.+)\.(?:[A-Z-])?$", percolator_peptide)
154154
peptidoform = match[1] if match else percolator_peptide
155+
# Handle Comet's n-terminal modification format: n[42.0106]PEPTIDE
156+
peptidoform = re.sub(r'^n\[([+-]?[\w\.]*?)\]', r'[\1]-', peptidoform)
157+
158+
# Ensure positive values inside square brackets have a '+' sign
159+
peptidoform = re.sub(r'\[(\d+[\.]*\d*)]', r'[+\1]', peptidoform)
160+
155161
if charge:
156162
peptidoform += f"/{charge}"
157163
return Peptidoform(peptidoform)

0 commit comments

Comments
 (0)