pymzml / pymzML

pymzML - an interface between Python and mzML Mass spectrometry Files
https://pymzml.readthedocs.io/en/latest/
MIT License
162 stars 92 forks source link

Iterations over pymzml.run.Reader() #218

Closed danielefil closed 4 years ago

danielefil commented 4 years ago

As well described in the manual it's possible to create an iterable python object (run) using the function: run = py.mzml.run.Reader('file.mzml')

Using a for loop it is possible to iterate over run and work with a spectra at each iteration: for spectra in run:     spectra.do_something()

In my program I need to repeat for loops over run for a couple of time. The firt loop works fine but the following ones are not executed. I suppose, because the iterator index reach the last value at the end of first loop and so, at the second loop, it'a alreasy at last value. For now I re-create the run object before every loop (not a big problem).

I'm kidly ask if its possible to reset the iterator index using some already written fuction i.e. _init_iter(self) contained in run.py (line 337).

Thanks Best

Daniele

MKoesters commented 4 years ago

Hi Daniele,

thanks for raising this. I'll have a look into the code and see how easy this is to implement.

Best, Manuel

JB-MS commented 4 years ago

Hi Daniele,

if buffering of the required data for each spectrum is an option, you could try this avoid multiple iterations over the file.

Cheers, Johannes

MKoesters commented 4 years ago

Resolved with #226