Skip to content

Commit

Permalink
Merge pull request #204 from pymzml/dev
Browse files Browse the repository at this point in the history
Update to v2.4.6
  • Loading branch information
fu authored Jan 24, 2020
2 parents 60a3fa2 + d789253 commit 74e98ad
Show file tree
Hide file tree
Showing 23 changed files with 433 additions and 37 deletions.
10 changes: 10 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
addReviewers: true
addAssignees: true
reviewers:
- MKoesters

skipKeywords:
- wip
- WIP

numberOfReviewers: 0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dist
.tox
pymzml.egg-info
docs/source/code_inc/
/.github/
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Please refer to:
| Germany
| eMail: [email protected]
|
| http:// <in transition >
| https://fufezan.net

*******
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx >= 1.3.0
sphinx_rtd_theme >= 0.1.9
sphinx==2.3.1
sphinx_rtd_theme==0.4.3
regex
66 changes: 66 additions & 0 deletions example_scripts/_playground2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python3
import bisect
import pprint
import click
import os
import hashlib

import random
import pickle
import pymzml

from xml.etree.ElementTree import ParseError


@click.command()
@click.argument('input_files', nargs=-1)
@click.option('--shuffle', '-s', is_flag=True)
@click.option('--suffix')
def main(input_files, shuffle, suffix=''):
print(suffix)
output_name = f'failing_spectra{suffix}.txt'
with open(output_name, 'wt') as fout:
for file in input_files:
print(file)
fails = 0
fail_info = []
reader = pymzml.run.Reader(file)
indices = list(range(1, reader.get_spectrum_count()))
if shuffle:
random.seed(a=1570010244.2805517)
random.shuffle(indices)
m = hashlib.md5()
m.update(pickle.dumps(indices))
md5_digest = m.hexdigest()
print(f"Shuffled indices md5: {md5_digest}")
# exit(1)
number_of_specs = len(indices)
basic_off_set_dict = reader.info["file_object"].file_handler.offset_dict.copy()
basic_seek_list = reader.info["file_object"].file_handler.seek_list.copy()
for pos, i in enumerate(indices):
# reader.info["file_object"].file_handler.offset_dict = basic_off_set_dict.copy()
# reader.info["file_object"].file_handler.seek_list = basic_seek_list.copy()
current_precentage = 100 * float(pos) / float(number_of_specs)
print(f"[{current_precentage:0>3.1f}%] Access spectrum {i:<10}".format(), end='\r')
#spec = reader[i]
try:
spec = reader[i]
# 100 / 0
except Exception as e:
fails += 1
fout.write(f'{os.path.basename(file)}\t{i}\n')
print(f"failed on spec {i}")

# pprint.pprint(reader.info["file_object"].file_handler.offset_dict)
# pprint.pprint(reader.info["file_object"].file_handler.seek_list)
spec = reader[i]
exit(1)
# break
print()
perc = fails / len(indices) * 100
print(f'{fails} of {len(indices)} spectra could not be accessed ({perc}%)')
print('\n\n')


if __name__ == '__main__':
main()
Loading

0 comments on commit 74e98ad

Please sign in to comment.