Commits (20)
......@@ -2,9 +2,6 @@
# PyCharm stuff
.idea
# obo files (distributed in psi-ms-CV repository)
*.obo
# saved Molecule properties
/molecules
*.mol
......
......@@ -24,7 +24,12 @@ before_script:
test:
script:
- python setup.py install
- python setup.py test
- python PyRSIR.py -fn "tests/LY-2015-09-15 06.mzML.gz" -xl "tests/LY-2015-09-15 06 pyrsir example.xlsx" -n 3 5 10
artifacts:
paths:
- tests/LY-2015-09-15 06 pyrsir example.xlsx
run:
script:
......
......@@ -74,7 +74,7 @@ parser.add_argument(
action='store',
nargs='+',
type=int,
help='number of scans to bin. Multiple bin numbers may be specified separated by commas',
help='number of scans to bin. Multiple bin numbers may be specified separated by spaces',
dest='num_bins'
)
......
......@@ -10,7 +10,7 @@ If you use these tools in your research endeavours, please cite
[Yunker _et al._ _J. Chem. Inf. Model._, **2019**, _59_(4) pp 1295-1300](https://pubs.acs.org/doi/10.1021/acs.jcim.9b00055).
### Requirements and Installation:
This package has been written for python 3.5+.
This package has been written for python 3.6+.
##### Getting started
......@@ -99,4 +99,8 @@ shape and managing impractically precise x values.
Contains classes for interacting with mzML files in a pythonic manner.
### License
These tools are licensed under the [MIT license](https://opensource.org/licenses/MIT).
\ No newline at end of file
These tools are licensed under the [MIT license](https://opensource.org/licenses/MIT).
A [HUPO PSI-MS](https://www.hupo.org/Proteomics-Standards-Initiative) type definition file (psi-ms.obo) is distributed with this package as
a reference for the `mzml` package. This file is included [without modification](https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo)
and is included under the [Creative Commons Attribution 4.0 International (CC BY 4.0) license](https://creativecommons.org/licenses/by/4.0/).
\ No newline at end of file
__version__ = '2.2.0'
__version__ = '2.2.1'
......@@ -474,7 +474,7 @@ class IPMolecule(Molecule):
self.fwhm
)
if abs(self.error) > self.criticalerror:
logger.warning(f'the error of {self} is {self.error} (critical: {self.criticalerror})')
logger.warning(f'the estimated pattern error of {self} is {self.error} (critical: {self.criticalerror})')
def compare(self, exp):
"""
......
This diff is collapsed.
"""Classes for interacting with HUPO-PSI-MS controlled variable names and descriptions"""
import os
import obonet
import textwrap
import urllib
import pathlib
from packaging import version
from typing import Union
from xml.etree import ElementTree
cv_param_def = None # default state for loaded CV parameters
def find_obos(paths: list):
"""
locates any *.obo files in the specified directory
:param paths: paths to search
:return: list of paths
:rtype: list
"""
locations = []
for eachpath in paths:
for root, dirs, files in os.walk(eachpath):
for ind in files:
if ind.endswith('.obo'):
locations.append(os.path.join(root, ind))
return locations
def newest_version(paths: list):
"""
Select the newest possible obo version in the supplied paths
......@@ -32,16 +17,17 @@ def newest_version(paths: list):
:return: selected path
:rtype: str
"""
ver = 0.
ver: version = version.parse('0.')
out = ''
for loc in paths:
hndl = open(loc, 'rt')
lines = hndl.readlines()
hndl.close()
for line in lines:
if line.startswith('format-version:'):
if float(line.split()[1]) > ver:
ver = float(line.split()[1])
if line.startswith('data-version:'):
loc_ver = version.parse(line.split()[1])
if loc_ver > ver:
ver = loc_ver
out = loc
break
return out
......@@ -63,7 +49,7 @@ def verify_obo(path):
])
def find_local_obo(custom_paths: list = None):
def find_local_obo(*custom_paths: Union[str, pathlib.Path]):
"""
Finds local paths to obo files
......@@ -71,13 +57,17 @@ def find_local_obo(custom_paths: list = None):
:return: path to newest, local obo or None
:rtype: str
"""
paths = [
os.getcwd(), # by default, check CWD
default_search_paths = [
pathlib.Path(__file__).parent, # check default save location
pathlib.Path.cwd(), # check current working directory
]
default_search_paths.extend(custom_paths)
obo_paths = []
for path in default_search_paths:
obo_paths.extend(path.glob('**/*.obo'))
if custom_paths is not None:
paths.extend(paths)
possible = find_obos(paths) # retrieve possible locations
verified = [path for path in possible if verify_obo(path) is True] # verify correct paths
default_search_paths.extend(default_search_paths)
verified = [path for path in obo_paths if verify_obo(path) is True] # verify correct paths
if len(verified) == 0:
return None # if there are no valid possibilities, return None
return newest_version(verified)
......@@ -85,9 +75,9 @@ def find_local_obo(custom_paths: list = None):
# url for accessing the most up-to-date version of the psi-ms obo file
OBOURL = 'https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo'
local_obo = find_local_obo() # try to find a local obo and use instead
if local_obo is not None:
OBOURL = local_obo
TARGET_OBO = find_local_obo() # try to find a local obo and use instead
if TARGET_OBO is None:
TARGET_OBO = OBOURL
def interpret_term_string(string: str):
......@@ -415,7 +405,7 @@ class CVParameterSet(object):
class CVParameterDefinitions(CVParameterSet):
def __init__(self,
obo_path=OBOURL,
obo_path=TARGET_OBO,
):
"""
Loads and interprets a PSI-MS obo file into a python-interpretable format.
......@@ -442,10 +432,10 @@ class CVParameterDefinitions(CVParameterSet):
)
def __repr__(self):
return f'{self.__class__.__name__}(v{self.format_version})'
return f'{self.__class__.__name__}(v{self.data_version})'
def __str__(self):
return f'{self.__class__.__name__} format version {self.format_version} with {len(self.cv_values)} keys'
return f'{self.__class__.__name__} data version {self.data_version} with {len(self.cv_values)} keys'
def print_properties(self, key):
cvparam = self.__getitem__(key)
......
......@@ -28,6 +28,7 @@ setup(
url='https://gitlab.com/larsyunker/PythoMS',
packages=PACKAGES,
license='MIT',
python_requires='~=3.6',
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
......@@ -47,6 +48,10 @@ setup(
'obonet==0.2.5', # they changed attribute names without deprecationwarnings, so only this version is verified
'isospecpy>=2.0.2',
'tqdm>=4.46.0',
'packaging>=20.1',
],
package_data={
'': ['*.obo']
},
keywords=KEYWORDS,
)
......@@ -35,25 +35,25 @@ class TestPyRSIR(unittest.TestCase):
)
os.remove(f'{multitest_xl}.bak')
def test_rxn(self):
"""runs the reaction profiling stage"""
shutil.copy(
rxn_xl,
f'{rxn_xl}.bak'
)
try:
rsir = RSIR(
rxn_mz,
bin_numbers=[3, 5, 10],
)
rsir.add_targets_from_xlsx(
rxn_xl,
)
rsir.extract_data()
rsir.write_rsir_to_excel(f'{rxn_xl}')
finally:
shutil.copy(
f'{rxn_xl}.bak',
rxn_xl,
)
os.remove(f'{rxn_xl}.bak')
# def test_rxn(self):
# """runs the reaction profiling stage"""
# shutil.copy(
# rxn_xl,
# f'{rxn_xl}.bak'
# )
# try:
# rsir = RSIR(
# rxn_mz,
# bin_numbers=[3, 5, 10],
# )
# rsir.add_targets_from_xlsx(
# rxn_xl,
# )
# rsir.extract_data()
# rsir.write_rsir_to_excel(f'{rxn_xl}')
# finally:
# shutil.copy(
# f'{rxn_xl}.bak',
# rxn_xl,
# )
# os.remove(f'{rxn_xl}.bak')