Skip to content

Commit ecd9ed6

Browse files
committed
Merge branch 'osw_parquet_chrom_reader' of github.com:Roestlab/massdash into osw_parquet_chrom_reader_w_xtra_file_ext
2 parents c8dd271 + 0ef5d2f commit ecd9ed6

3 files changed

Lines changed: 453 additions & 390 deletions

File tree

massdash/loaders/OpenSwathXICParquetLoader.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,33 @@ def loadTransitionGroups(self, pep_id: str, charge: int, runNames: Union[None, s
6161

6262
out = TransitionGroupCollection()
6363

64+
def _assembleTransitionGroup(t):
65+
chroms = t.getChromatogramsFromSequenceAndCharge(pep_id, charge)
66+
precursorChroms = [i for i in chroms if 'precursor' in i.label.lower()]
67+
transitionChroms = [i for i in chroms if 'precursor' not in i.label.lower()]
68+
if len(precursorChroms) == 0 and len(transitionChroms) == 0: # do not create a transition group if there are no chromatograms
69+
return None
70+
else:
71+
return TransitionGroup(precursorChroms, transitionChroms, pep_id, charge)
72+
6473
if runNames is None:
6574
for t in self.dataAccess:
66-
out[t.runName] = t.getChromatogramsFromSequenceAndCharge(pep_id, charge)
75+
out[t.runName] = _assembleTransitionGroup(t)
6776
elif isinstance(runNames, str):
6877
t = self.dataAccess[self.runNames.index(runNames)]
69-
out[runNames] = t.getChromatogramsFromSequenceAndCharge(pep_id, charge)
78+
out[runNames] = _assembleTransitionGroup(t)
7079
elif isinstance(runNames, list):
7180
out = TransitionGroupCollection()
7281
for r in runNames:
7382
for t in self.dataAccess:
7483
if t.runName == r:
75-
out[t.runName] = t.getChromatogramsFromSequenceAndCharge(pep_id, charge)
84+
out[t.runName] = _assembleTransitionGroup(t)
7685
else:
7786
raise ValueError("runName must be none, a string or list of strings")
7887

79-
return out
88+
# if there are no chromatograms, return none
89+
if all([i is None for i in out.values()]):
90+
LOGGER.warning(f"No chromatograms found for peptide {pep_id} with charge {charge} in any of the runs")
91+
return None
92+
else:
93+
return out

0 commit comments

Comments
 (0)