@@ -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