diff --git a/.gitignore b/.gitignore index 541c81b..66a48da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,123 @@ -.idea/ -.idea* -dist/ -build/ -*egg-info/ +# repo specific /experimental_design.tsv /openms.tsv -__pycache__ + +## Typical Python package ignorance + +.DS_Store + +.coverage +.pytest_cache +docs/api/_build + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +testing* +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# backup files +*~ +*\? + +# Jetbrains IDEs +.idea +pip-wheel-metadata +.vscode +.*.sw? diff --git a/sdrf_pipelines/__init__.py b/sdrf_pipelines/__init__.py index e69de29..c35625a 100644 --- a/sdrf_pipelines/__init__.py +++ b/sdrf_pipelines/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.21" diff --git a/sdrf_pipelines/maxquant/__init__.py b/sdrf_pipelines/maxquant/__init__.py index 8b13789..e69de29 100644 --- a/sdrf_pipelines/maxquant/__init__.py +++ b/sdrf_pipelines/maxquant/__init__.py @@ -1 +0,0 @@ - diff --git a/sdrf_pipelines/maxquant/maxquant.py b/sdrf_pipelines/maxquant/maxquant.py index 90c0b04..80b6d16 100644 --- a/sdrf_pipelines/maxquant/maxquant.py +++ b/sdrf_pipelines/maxquant/maxquant.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Created on Sun Apr 19 09:46:14 2020 @@ -992,7 +991,7 @@ def maxquant_convert( for j in range(arr.shape[1]): arr[i][j] = sorted(arr[i])[j] - label_arr = np.array(list(set([tuple(t) for t in arr]))) + label_arr = np.array(list({tuple(t) for t in arr})) file2silac_shape[raw] = label_arr.shape label_arr.sort() if label_arr.shape[0] == 2: # Support two or three silac labels @@ -1099,7 +1098,7 @@ def maxquant_convert( fastaFilePath_node = doc.createElement("fastaFilePath") fastaFilePath_node.appendChild(doc.createTextNode(fastaFilePath)) identifierParseRule = doc.createElement("identifierParseRule") - identifierParseRule.appendChild(doc.createTextNode(">([^\s]*)")) + identifierParseRule.appendChild(doc.createTextNode(r">([^\s]*)")) descriptionParseRule = doc.createElement("descriptionParseRule") descriptionParseRule.appendChild(doc.createTextNode(">(.*)")) taxonomyParseRule = doc.createElement("taxonomyParseRule") diff --git a/sdrf_pipelines/msstats/msstats.py b/sdrf_pipelines/msstats/msstats.py index e4bb5a4..d39ae8d 100644 --- a/sdrf_pipelines/msstats/msstats.py +++ b/sdrf_pipelines/msstats/msstats.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - - import re import pandas as pd diff --git a/sdrf_pipelines/openms/unimod.py b/sdrf_pipelines/openms/unimod.py index 542c5c8..4570f3e 100644 --- a/sdrf_pipelines/openms/unimod.py +++ b/sdrf_pipelines/openms/unimod.py @@ -62,14 +62,14 @@ def search_mods_by_keyword(self, keyword: str = None): return found_list def _get_elements(self, node): - for e in node.findall("%selements/%selem" % (self.xmlns, self.xmlns)): + for e in node.findall(f"{self.xmlns}elements/{self.xmlns}elem"): ea = e.attrib self.elements[ea["title"]] = ea if re.match(r"[A-Z]", ea["title"][:1]): - self.elements["%s%s" % (int(round(float(ea["mono_mass"]))), ea["title"])] = ea + self.elements["{}{}".format(int(round(float(ea["mono_mass"]))), ea["title"])] = ea def _get_modifications(self, node): - for e in node.findall("%smodifications/%smod" % (self.xmlns, self.xmlns)): + for e in node.findall(f"{self.xmlns}modifications/{self.xmlns}mod"): ma = e.attrib d = e.findall("%sdelta" % self.xmlns)[0] for k in d.attrib.keys(): diff --git a/sdrf_pipelines/parse_sdrf.py b/sdrf_pipelines/parse_sdrf.py index c4ee0f5..44da62e 100755 --- a/sdrf_pipelines/parse_sdrf.py +++ b/sdrf_pipelines/parse_sdrf.py @@ -9,6 +9,7 @@ import click import pandas as pd +from sdrf_pipelines import __version__ from sdrf_pipelines.maxquant.maxquant import Maxquant from sdrf_pipelines.msstats.msstats import Msstats from sdrf_pipelines.normalyzerde.normalyzerde import NormalyzerDE @@ -22,6 +23,7 @@ CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) +@click.version_option(version=__version__, package_name="sdrf_pipelines", message="%(package)s %(version)s") @click.group(context_settings=CONTEXT_SETTINGS) def cli(): """ diff --git a/sdrf_pipelines/sdrf/sdrf_schema.py b/sdrf_pipelines/sdrf/sdrf_schema.py index 321afa3..e5dfa38 100644 --- a/sdrf_pipelines/sdrf/sdrf_schema.py +++ b/sdrf_pipelines/sdrf/sdrf_schema.py @@ -104,7 +104,7 @@ def default_message(self): Return a message for the validation of the Ontology Term :return: """ - return "the term name or title can't be found in the ontology -- {}".format(self._ontology_name) + return f"the term name or title can't be found in the ontology -- {self._ontology_name}" @staticmethod def validate_ontology_terms(cell_value, labels): @@ -285,7 +285,7 @@ def _get_column_pairs(self, panda_sdrf): for column in columns_to_pair: if column.name not in panda_sdrf and column._optional is False: - message = "The column {} is not present in the SDRF".format(column.name) + message = f"The column {column.name} is not present in the SDRF" errors.append(LogicError(message, error_type=logging.ERROR)) elif column.name in panda_sdrf: column_pairs.append((panda_sdrf[column.name], column)) diff --git a/sdrf_pipelines/utils/exceptions.py b/sdrf_pipelines/utils/exceptions.py index 782e8ee..66da480 100644 --- a/sdrf_pipelines/utils/exceptions.py +++ b/sdrf_pipelines/utils/exceptions.py @@ -26,12 +26,12 @@ def __str__(self) -> str: self.row, self.column, self.value, self.message, logging.getLevelName(self._error_type) ) else: - return "{} -- {}".format(self.message, logging.getLevelName(self._error_type)) + return f"{self.message} -- {logging.getLevelName(self._error_type)}" class AppConfigException(AppException): def __init__(self, value): - super(AppConfigException, self).__init__(value) + super().__init__(value) class ConfigManagerException(Exception): diff --git a/sdrf_pipelines/zooma/ols.py b/sdrf_pipelines/zooma/ols.py index 9a49bbe..ec2197d 100644 --- a/sdrf_pipelines/zooma/ols.py +++ b/sdrf_pipelines/zooma/ols.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ OLS API wrapper diff --git a/setup.py b/setup.py index a8601fd..693c381 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,30 @@ -from __future__ import print_function +import codecs +import os.path from setuptools import find_packages from setuptools import setup -with open("README.md", "r", encoding="UTF-8") as fh: +with open("README.md", encoding="UTF-8") as fh: long_description = fh.read() + +def read(rel_path): + here = os.path.abspath(os.path.dirname(__file__)) + with codecs.open(os.path.join(here, rel_path), "r") as fp: + return fp.read() + + +def get_version(rel_path): + for line in read(rel_path).splitlines(): + if line.startswith("__version__"): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + raise RuntimeError("Unable to find version string.") + + setup( name="sdrf-pipelines", - version="0.0.21", + version=get_version("sdrf_pipelines/__init__.py"), author="BigBio Team", author_email="ypriverol@gmail.com", description="Translate, convert SDRF to configuration pipelines",