Skip to content

Commit f236fdf

Browse files
authored
Merge pull request #5 from hroest/tapir_branch
Tapir branch
2 parents 95e4753 + 08676bc commit f236fdf

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

pymzml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
import pymzml.spec
3838
import pymzml.obo
3939
import pymzml.minimum
40-
import pymzml.plot
40+
# import pymzml.plot

pymzml/obo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
from __future__ import print_function
6767
import sys
6868
import os
69-
69+
import codecs
7070

7171
class oboTranslator(object):
7272
def __init__(self, version=None):
@@ -138,7 +138,8 @@ def parseOBO(self):
138138

139139
# Modify the root for cx_freeze
140140
if getattr(sys, 'frozen', False):
141-
obo_root = os.path.dirname(sys.executable)
141+
# obo_root = os.path.dirname(sys._MEIPASS)
142+
obo_root = os.path.dirname(__file__)
142143
else:
143144
obo_root = os.path.dirname(__file__)
144145

@@ -149,7 +150,7 @@ def parseOBO(self):
149150
)
150151

151152
if os.path.exists(obo_file):
152-
with open(obo_file) as obo:
153+
with codecs.open( obo_file, 'r', encoding = 'utf-8' ) as obo:
153154
collections = {}
154155
collect = False
155156
for line in obo:

pymzml/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,13 @@ def __getitem__(self, value):
575575
if len(self.info['offsets']) == 0:
576576
raise IOError("File does support random access: index list missing...")
577577

578+
# Check for conversion of str/int issues
579+
if not value in self.info['offsets']:
580+
try:
581+
value = int(value)
582+
except Exception:
583+
pass
584+
578585
if value in self.info['offsets']:
579586
startPos = self.info['offsets'][value]
580587
endPos_index = bisect.bisect_right(

pymzml/spec.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,13 +829,25 @@ def _decodeNumpress(self, inData, compression):
829829
coder = pyopenms.MSNumpressCoder()
830830
np_config = pyopenms.NumpressConfig()
831831
np_config.estimate_fixed_point = True
832+
zlib_compression = False
832833
if compression == 'ms-np-linear':
833834
np_config.np_compression = pyopenms.MSNumpressCoder.NumpressCompression.LINEAR
834835
elif compression == 'ms-np-pic':
835836
np_config.np_compression = pyopenms.MSNumpressCoder.NumpressCompression.PIC
836837
elif compression == 'ms-np-slof':
837838
np_config.np_compression = pyopenms.MSNumpressCoder.NumpressCompression.SLOF
838-
coder.decodeNP(inData, result, False, np_config)
839+
elif compression == 'zlib-ms-np-linear':
840+
np_config.np_compression = pyopenms.MSNumpressCoder.NumpressCompression.LINEAR
841+
zlib_compression = True
842+
elif compression == 'zlib-ms-np-pic':
843+
np_config.np_compression = pyopenms.MSNumpressCoder.NumpressCompression.PIC
844+
zlib_compression = True
845+
elif compression == 'zlib-ms-np-slof':
846+
np_config.np_compression = pyopenms.MSNumpressCoder.NumpressCompression.SLOF
847+
zlib_compression = True
848+
849+
coder.decodeNP(inData, result, zlib_compression, np_config)
850+
839851
return result
840852

841853
def _decode(self):
@@ -885,6 +897,8 @@ def _decode(self):
885897
decodedData = zlib.decompress(decodedData)
886898
elif compression in ['ms-np-linear', 'ms-np-pic', 'ms-np-slof']:
887899
unpackedData = self._decodeNumpress(base64Data, compression)
900+
elif compression in ['zlib-ms-np-linear', 'zlib-ms-np-pic', 'zlib-ms-np-slof']:
901+
unpackedData = self._decodeNumpress(base64Data, compression)
888902
elif compression == 'no':
889903
pass
890904
else:
@@ -1448,6 +1462,15 @@ def readAccession(self, parElement):
14481462
accession = element.get('accession')
14491463
self.ms[accession] = element
14501464
if element.tag.endswith('cvParam'):
1465+
1466+
# Combination of zlib + msnumpress
1467+
if accession == "MS:1002746":
1468+
self['BinaryArrayOrder'].append(('compression', 'zlib-ms-np-linear'))
1469+
elif accession == "MS:1002747":
1470+
self['BinaryArrayOrder'].append(('compression', 'zlib-ms-np-pic'))
1471+
elif accession == "MS:1002748":
1472+
self['BinaryArrayOrder'].append(('compression', 'zlib-ms-np-slof'))
1473+
14511474
if accession in self.param['accessions']:
14521475
for mzmlTag in self.param['accessions'][accession]['valuesToExtract']:
14531476
try:
@@ -1493,6 +1516,15 @@ def readAccession(self, parElement):
14931516
elif self.param['accessions'][accession]['name'] == 'MS-Numpress short logged float compression':
14941517
self['BinaryArrayOrder'].append(('compression', 'ms-np-slof'))
14951518

1519+
elif self.param['accessions'][accession]['name'] == 'MS-Numpress linear prediction compression followed by zlib compression':
1520+
self['BinaryArrayOrder'].append(('compression', 'zlib-ms-np-linear'))
1521+
1522+
elif self.param['accessions'][accession]['name'] == 'MS-Numpress positive integer compression followed by zlib compression':
1523+
self['BinaryArrayOrder'].append(('compression', 'zlib-ms-np-pic'))
1524+
1525+
elif self.param['accessions'][accession]['name'] == 'MS-Numpress short logged float compression followed by zlib compression':
1526+
self['BinaryArrayOrder'].append(('compression', 'zlib-ms-np-slof'))
1527+
14961528
elif element.tag.endswith('precursorList'):
14971529
# TODO remove this completely?
14981530
self['precursors'] = []

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nose
2+
plotly

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from distutils.core import setup
44
setup(name='pymzml',
5-
version='0.8.0',
5+
version='0.8.1',
66
packages = ['pymzml'],
77
package_dir = {'pymzml': 'pymzml'},
88
package_data={'pymzml': ['obo/*.obo']},

0 commit comments

Comments
 (0)