Skip to content

Commit

Permalink
fix xml run parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurDeclercq committed Oct 25, 2023
1 parent 51cd43e commit ec6265e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions psm_utils/io/xtandem.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ def __init__(self, filename: str | Path, *args, decoy_prefix="DECOY_", **kwargs)

def __iter__(self):
"""Iterate over file and return PSMs one-by-one."""

with tandem.read(str(self.filename)) as reader:
run = self._parse_run(self.filename)
for entry in reader:
psm = self._parse_entry(entry)
psm = self._parse_entry(entry,run)
yield psm

def _parse_peptidoform(self, peptide_entry, charge: int) -> Peptidoform:
Expand Down Expand Up @@ -139,7 +141,7 @@ def _parse_peptidoform(self, peptide_entry, charge: int) -> Peptidoform:

return Peptidoform(proforma_seq)

def _parse_entry(self, entry) -> PSM:
def _parse_entry(self, entry, run:str) -> PSM:
"""Parse X!Tandem XML entry to :py:class:`~psm_utils.psm.PSM`."""
peptide_entry = entry["protein"][0]["peptide"]
psm = PSM(
Expand All @@ -149,7 +151,7 @@ def _parse_entry(self, entry) -> PSM:
score=-np.log(peptide_entry["expect"]),
precursor_mz=entry["mh"] - mass.nist_mass["H"][0][0],
retention_time=entry["rt"],
run=self._parse_run(self.filename),
run=run
protein_list=[entry["protein"][0]["label"]],
source="X!Tandem",
provenance_data={
Expand Down

0 comments on commit ec6265e

Please sign in to comment.