Skip to content

Commit a66a9c9

Browse files
author
Christian Fufezan
committed
Blackin diz
1 parent 20ed8e5 commit a66a9c9

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

pymzml/chromatogram.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ def precursor_mz(self):
325325
isolation_window = precursor.find(f".//{self.ns}isolationWindow")
326326
if isolation_window is not None:
327327
for element in isolation_window.iter():
328-
if element.tag.endswith("}cvParam") and element.get("accession") == "MS:1000827": # isolation window target m/z
328+
if (
329+
element.tag.endswith("}cvParam")
330+
and element.get("accession") == "MS:1000827"
331+
): # isolation window target m/z
329332
self._precursor_mz = float(element.get("value"))
330333
break
331334
return self._precursor_mz
@@ -344,7 +347,10 @@ def product_mz(self):
344347
isolation_window = product.find(f".//{self.ns}isolationWindow")
345348
if isolation_window is not None:
346349
for element in isolation_window.iter():
347-
if element.tag.endswith("}cvParam") and element.get("accession") == "MS:1000827": # isolation window target m/z
350+
if (
351+
element.tag.endswith("}cvParam")
352+
and element.get("accession") == "MS:1000827"
353+
): # isolation window target m/z
348354
self._product_mz = float(element.get("value"))
349355
break
350356
return self._product_mz

pymzml/file_classes/standardGzip.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def __getitem__(self, identifier):
101101
elif element.tag.endswith("}chromatogram"):
102102
if element.get("id") == identifier:
103103
self.file_handler.seek(old_pos, 0)
104-
return chromatogram.Chromatogram(element, measured_precision=5e-6)
104+
return chromatogram.Chromatogram(
105+
element, measured_precision=5e-6
106+
)
105107

106108

107109
if __name__ == "__main__":

pymzml/msdata.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,15 @@ def _decodeNumpress_to_array(self, data, compression):
330330
data = np.frombuffer(data, dtype=np.uint8)
331331
if "MS:1002312" in comp_ms_tags:
332332
from .decoder import MSDecoder
333+
333334
result = MSDecoder.decode_linear(data)
334335
elif "MS:1002313" in comp_ms_tags:
335336
from .decoder import MSDecoder
337+
336338
result = MSDecoder.decode_pic(data)
337339
elif "MS:1002314" in comp_ms_tags:
338340
from .decoder import MSDecoder
341+
339342
result = MSDecoder.decode_slof(data)
340343
return result
341344

pymzml/run.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def __next__(self):
167167
if element.tag.endswith("}chromatogram"):
168168
if self.skip_chromatogram:
169169
continue
170-
spectrum = chromatogram.Chromatogram(element, obo_version=self.OT.version)
170+
spectrum = chromatogram.Chromatogram(
171+
element, obo_version=self.OT.version
172+
)
171173
# if has_ref_group:
172174
# spectrum._set_params_from_reference_group(
173175
# self.info['referenceable_param_group_list_element']
@@ -199,13 +201,13 @@ def __getitem__(self, identifier):
199201
raise Exception("Requested identifier is out of range")
200202
except:
201203
pass
202-
204+
203205
element = self.info["file_object"][identifier]
204206
element.obo_translator = self.OT
205-
207+
206208
if isinstance(element, spec.Spectrum):
207209
element.measured_precision = self.ms_precisions[element.ms_level]
208-
210+
209211
return element
210212

211213
def __enter__(self):
@@ -458,60 +460,62 @@ def get_chromatogram_count(self):
458460
chromatogram count (int): Number of chromatograms in file.
459461
"""
460462
return self.info["chromatogram_count"]
461-
463+
462464
def get_spectrum(self, identifier):
463465
"""
464466
Access spectrum with the given identifier.
465-
467+
466468
Arguments:
467469
identifier (str or int): Either a string identifier or an index (0-based)
468470
to access spectra in order.
469-
471+
470472
Returns:
471473
spectrum (Spectrum): spectrum object with the given identifier
472-
474+
473475
Note:
474476
This method provides the same functionality as using the indexing syntax
475477
(e.g., run[0]), but with a more explicit method name.
476478
"""
477479
return self[identifier]
478-
480+
479481
def get_chromatogram(self, identifier):
480482
"""
481483
Access chromatogram with the given identifier.
482-
484+
483485
Arguments:
484486
identifier (str or int): Either a string identifier like 'TIC' or
485487
an index (0-based) to access chromatograms in order.
486-
488+
487489
Returns:
488490
chromatogram (Chromatogram): chromatogram object with the given identifier
489-
491+
490492
Note:
491493
This method is only useful when skip_chromatogram is set to False
492494
if you want to access chromatograms by index. If skip_chromatogram is True,
493495
you can still access chromatograms by string identifiers (e.g., 'TIC').
494496
"""
495497
if isinstance(identifier, str):
496498
return self[identifier]
497-
499+
498500
if isinstance(identifier, int):
499501
if self.get_chromatogram_count() is None:
500502
raise Exception("No chromatograms found in the file")
501-
503+
502504
if identifier >= self.get_chromatogram_count():
503-
raise Exception(f"Chromatogram index {identifier} is out of range (0-{self.get_chromatogram_count()-1})")
504-
505+
raise Exception(
506+
f"Chromatogram index {identifier} is out of range (0-{self.get_chromatogram_count()-1})"
507+
)
508+
505509
# Reset the file pointer and iterate to find the chromatogram
506510
temp_skip_chromatogram = self.skip_chromatogram
507511
self.skip_chromatogram = False
508-
512+
509513
self.info["file_object"].close()
510514
self.info["file_object"] = self._open_file(
511515
self.path_or_file, build_index_from_scratch=False
512516
)
513517
self.iter = self._init_iter()
514-
518+
515519
chrom_count = 0
516520
try:
517521
for element in self:
@@ -522,9 +526,9 @@ def get_chromatogram(self, identifier):
522526
finally:
523527
# Restore original skip_chromatogram setting
524528
self.skip_chromatogram = temp_skip_chromatogram
525-
529+
526530
raise Exception(f"Chromatogram with index {identifier} not found")
527-
531+
528532
raise ValueError("Identifier must be a string or an integer")
529533

530534
def close(self):

0 commit comments

Comments
 (0)