Skip to content

Commit 5eae580

Browse files
authored
io.flashlfq: Fix Peptide Monoisotopic Mass and Protein Accession column names (#97)
1 parent 565934a commit 5eae580

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.1] - 2024-09-06
9+
10+
### Fixed
11+
12+
- `io.flashlfq`: Fix column names `Peptide Monoisotopic Mass` and `Protein Accession`.
13+
814
## [1.1.0] - 2024-09-05
915

1016
### Added

psm_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Common utilities for parsing and handling PSMs, and search engine results."""
22

3-
__version__ = "1.1.0"
3+
__version__ = "1.1.1"
44
__all__ = ["Peptidoform", "PSM", "PSMList"]
55

66
from warnings import filterwarnings

psm_utils/io/flashlfq.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@ def _parse_entry(self, entry: dict, spectrum_id) -> PSM:
6262
spectrum_id=spectrum_id,
6363
run=entry.get("File Name"),
6464
retention_time=entry.get("Scan Retention Time"),
65-
protein_list=self._parse_protein_list(entry.get("Protein Accessions")),
65+
protein_list=self._parse_protein_list(entry.get("Protein Accession")),
6666
)
6767

6868
@staticmethod
69-
def _parse_protein_list(protein_accessions: Optional[str]) -> list[str]:
69+
def _parse_protein_list(protein_accession: Optional[str]) -> list[str]:
7070
"""Parse protein list string to list of protein accessions."""
71-
if not protein_accessions:
71+
if not protein_accession:
7272
return []
73-
elif ";" in protein_accessions: # Docs define separator as semicolon
74-
return protein_accessions.split(";")
75-
elif "|" in protein_accessions: # Example file uses pipe
76-
return protein_accessions.split("|")
73+
elif ";" in protein_accession: # Docs define separator as semicolon
74+
return protein_accession.split(";")
75+
elif "|" in protein_accession: # Example file uses pipe
76+
return protein_accession.split("|")
7777
else:
78-
return [protein_accessions] # Single protein
78+
return [protein_accession] # Single protein
7979

8080

8181
class FlashLFQWriter(WriterBase):
@@ -125,10 +125,10 @@ def __enter__(self) -> FlashLFQWriter:
125125
"File Name",
126126
"Base Sequence",
127127
"Full Sequence",
128-
"Peptide Monoisotope Mass",
128+
"Peptide Monoisotopic Mass",
129129
"Scan Retention Time",
130130
"Precursor Charge",
131-
"Protein Accessions",
131+
"Protein Accession",
132132
]
133133
mode = "wt"
134134

@@ -221,8 +221,8 @@ def _psm_to_entry(psm: PSM) -> dict:
221221
"File Name": psm.run,
222222
"Base Sequence": psm.peptidoform.sequence,
223223
"Full Sequence": psm.peptidoform.modified_sequence,
224-
"Peptide Monoisotope Mass": psm.peptidoform.theoretical_mass,
224+
"Peptide Monoisotopic Mass": f"{psm.peptidoform.theoretical_mass:.6f}",
225225
"Scan Retention Time": psm.retention_time,
226226
"Precursor Charge": psm.peptidoform.precursor_charge,
227-
"Protein Accessions": ";".join(psm.protein_list),
227+
"Protein Accession": ";".join(psm.protein_list),
228228
}

tests/test_io/test_flashlfq.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from psm_utils.psm_list import PSMList
99

1010
# Sample data for testing
11-
sample_tsv_data = """File Name\tBase Sequence\tFull Sequence\tPeptide Monoisotope Mass\tScan Retention Time\tPrecursor Charge\tProtein Accessions
11+
sample_tsv_data = """File Name\tBase Sequence\tFull Sequence\tPeptide Monoisotopic Mass\tScan Retention Time\tPrecursor Charge\tProtein Accession
1212
sample1.raw\tPEPTIDE\tPEPTIDE\t1000.0\t5.0\t2\tP12345;P67890
1313
sample2.raw\tPEPTIDE\tPEPTIDE\t1000.0\t10.0\t2\tP23456|P78901
1414
"""
@@ -32,7 +32,7 @@ def invalid_psm_entry():
3232
"Precursor Charge": "2",
3333
"File Name": "sample1.raw",
3434
"Scan Retention Time": "5.0",
35-
"Protein Accessions": None,
35+
"Protein Accession": None,
3636
}
3737

3838

@@ -43,7 +43,7 @@ def test_flashlfqreader_parse_entry(valid_psm):
4343
"Precursor Charge": "2",
4444
"File Name": "sample1.raw",
4545
"Scan Retention Time": "5.0",
46-
"Protein Accessions": "P12345;P67890",
46+
"Protein Accession": "P12345;P67890",
4747
}
4848
psm = reader._parse_entry(entry, spectrum_id="0")
4949
assert psm == valid_psm
@@ -59,7 +59,7 @@ def test_flashlfqreader_iterate_over_file():
5959

6060

6161
def test_flashlfqreader_invalid_entry_handling():
62-
invalid_data = """File Name\tBase Sequence\tPeptide Monoisotope Mass\tScan Retention Time\tPrecursor Charge\tProtein Accessions
62+
invalid_data = """File Name\tBase Sequence\tPeptide Monoisotopic Mass\tScan Retention Time\tPrecursor Charge\tProtein Accession
6363
sample1.raw\tPEPTIDE\t1000.0\t5.0
6464
sample2.raw\tPEPTIDE\t1000.0\t10.0
6565
sample3.raw\tPEPTIDE\t1000.0\t15.0
@@ -95,10 +95,10 @@ def test_flashlfqwriter_existing_file():
9595
"File Name",
9696
"Base Sequence",
9797
"Full Sequence",
98-
"Peptide Monoisotope Mass",
98+
"Peptide Monoisotopic Mass",
9999
"Scan Retention Time",
100100
"Precursor Charge",
101-
"Protein Accessions",
101+
"Protein Accession",
102102
]
103103

104104

0 commit comments

Comments
 (0)