Skip to content

Commit

Permalink
Merge pull request #35 from xtrojak/conda-env
Browse files Browse the repository at this point in the history
Conda env
  • Loading branch information
martenson authored Sep 15, 2021
2 parents 7dd84a8 + 5d83553 commit 0fb090c
Show file tree
Hide file tree
Showing 31 changed files with 201 additions and 46 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Python Package using Conda

on:
push:
pull_request:
workflow_dispatch:

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env update --file conda/environment-dev.yml --name base
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
conda install pytest pytest-cov
pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml
15 changes: 15 additions & 0 deletions conda/environment-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pyMSPannotator
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- python >=3.7,<3.9
- matchms >=0.9.1
- pandas
- scipy
- requests
- aiohttp
- asyncstdlib
- frozendict
- tabulate
19 changes: 19 additions & 0 deletions conda/environment-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pyMSPannotator
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- python >=3.7,<3.9
- matchms >=0.9.1
- pandas
- scipy
- requests
- aiohttp
- asyncstdlib
- frozendict
- tabulate
- mock
- pytest
- pytest-aiohttp
- pytest-cov
62 changes: 62 additions & 0 deletions conda/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{% set name = "pyMSPannotator" %}
{% set version = "0.1.0" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
path: ..

extra:
channels:
- conda-forge
- bioconda

build:
noarch: python
preserve_egg_dir: True
number: 0
script: {{ PYTHON }} -m pip install --no-deps --ignore-installed . -vv

requirements:
build:
- conda-build
- conda-verify
- pytest-runner
- python
- setuptools
host:
- python >=3.7,<3.9
- pip
- pytest-runner
- setuptools
run:
- python >=3.7,<3.9
- matchms >=0.9.1
- pandas
- scipy
- requests
- aiohttp
- asyncstdlib
- frozendict
- tabulate
- mock
- pytest
- pytest-aiohttp
- pytest-cov

test:
imports:
- pyMSPannotator

about:
home: https://github.com/RECETOX/pyMSPannotator
license: MIT
license_file: LICENSE
summary: Repository for tool that adds more annotations (e.g. SMILES, InChI, CAS number) to MSP files (Python version).
dev_url: https://github.com/RECETOX/pyMSPannotator

extra:
recipe-maintainers:
- xtrojak
4 changes: 0 additions & 4 deletions libs/services/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions libs/utils/__init__.py

This file was deleted.

14 changes: 7 additions & 7 deletions app.py → pyMSPannotator/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import asyncio
import aiohttp

from libs.Annotator import Annotator
from libs.Curator import Curator
from libs.Spectra import Spectra
from libs.utils import logger
from libs.utils.Errors import UnknownService, UnknownSpectraFormat
from libs.utils.Job import convert_to_jobs
from libs.services import *
from pyMSPannotator.libs.Annotator import Annotator
from pyMSPannotator.libs.Curator import Curator
from pyMSPannotator.libs.Spectra import Spectra
from pyMSPannotator.libs.utils import logger
from pyMSPannotator.libs.utils.Errors import UnknownService, UnknownSpectraFormat
from pyMSPannotator.libs.utils.Job import convert_to_jobs
from pyMSPannotator.libs.services import *


class Application:
Expand Down
8 changes: 4 additions & 4 deletions libs/Annotator.py → pyMSPannotator/libs/Annotator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from libs.utils import logger
from libs.utils.Errors import ConversionNotSupported, TargetAttributeNotRetrieved, SourceAttributeNotAvailable, \
ServiceNotAvailable, UnknownResponse
from libs.utils.Logger import LogWarning
from pyMSPannotator.libs.utils import logger
from pyMSPannotator.libs.utils.Errors import ConversionNotSupported, TargetAttributeNotRetrieved, \
SourceAttributeNotAvailable, ServiceNotAvailable, UnknownResponse
from pyMSPannotator.libs.utils.Logger import LogWarning


class Annotator:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libs.services.Converter import Converter
from pyMSPannotator.libs.services.Converter import Converter


class CIR(Converter):
Expand Down
6 changes: 2 additions & 4 deletions libs/services/CTS.py → pyMSPannotator/libs/services/CTS.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from libs.services.Converter import Converter
from pyMSPannotator.libs.services.Converter import Converter


class CTS(Converter):
Expand All @@ -17,7 +17,7 @@ def __init__(self, session):
('inchikey', 'iupac_name', 'from_inchikey')]
self.create_top_level_conversion_methods(conversions)

### top level methods defining allowed conversions
# top level methods defining allowed conversions

async def casno_to_inchikey(self, cas_number):
"""
Expand All @@ -44,8 +44,6 @@ async def name_to_inchikey(self, name):
if response:
return self.parse_inchikey(response)

###

async def from_inchikey(self, inchikey):
"""
Convert InChiKey to all possible attributes using CTS compound service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from aiohttp.client_exceptions import ServerDisconnectedError

from libs.utils import logger
from libs.utils.Errors import TargetAttributeNotRetrieved, ServiceNotAvailable, UnknownResponse
from pyMSPannotator.libs.utils import logger
from pyMSPannotator.libs.utils.Errors import TargetAttributeNotRetrieved, ServiceNotAvailable, UnknownResponse


class Converter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pandas as pd

from libs.services.Converter import Converter
from pyMSPannotator.libs.services.Converter import Converter


class NLM(Converter):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio

from libs.services.Converter import Converter
from pyMSPannotator.libs.services.Converter import Converter
from frozendict import frozendict


Expand Down
4 changes: 4 additions & 0 deletions pyMSPannotator/libs/services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pyMSPannotator.libs.services.CIR import CIR
from pyMSPannotator.libs.services.CTS import CTS
from pyMSPannotator.libs.services.NLM import NLM
from pyMSPannotator.libs.services.PubChem import PubChem
File renamed without changes.
2 changes: 1 addition & 1 deletion libs/utils/Job.py → pyMSPannotator/libs/utils/Job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libs.utils.Errors import ConversionNotSupported, SourceAttributeNotAvailable
from pyMSPannotator.libs.utils.Errors import ConversionNotSupported, SourceAttributeNotAvailable


class Job:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from asyncio import Queue

from libs.utils.Metrics import Metrics
from pyMSPannotator.libs.utils.Metrics import Metrics


class Logger:
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions pyMSPannotator/libs/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pyMSPannotator.libs.utils.Logger import Logger

logger = Logger()
24 changes: 24 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from setuptools import setup, find_packages

setup(name='pyMSPannotator',
version='0.1',
description='Repository for tool that adds more annotations '
'(e.g. SMILES, InChI, CAS number) to MSP files (Python version).',
url='https://github.com/RECETOX/pyMSPannotator',
author='Matej Trojak',
author_email='matej.trojak@recetox.muni.cz',
license='MIT',
packages=find_packages(exclude=['*tests*']),
zip_safe=False,
test_suite="tests",
python_requires='>=3.7',
install_requires=[
"matchms",
"requests",
"pandas",
"aiohttp",
"asyncstdlib",
"frozendict",
"tabulate"
]
)
4 changes: 2 additions & 2 deletions tests/test_CIR.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import pytest

from libs.services.CIR import CIR
from libs.utils.Errors import UnknownResponse
from pyMSPannotator.libs.services.CIR import CIR
from pyMSPannotator.libs.utils.Errors import UnknownResponse
from tests.utils import wrap_with_session


Expand Down
8 changes: 4 additions & 4 deletions tests/test_CTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import json
import pytest

from libs.services.CTS import CTS
from libs.utils.Errors import UnknownResponse
from pyMSPannotator.libs.services.CTS import CTS
from pyMSPannotator.libs.utils.Errors import UnknownResponse
from tests.utils import wrap_with_session


@pytest.mark.parametrize('arg, value, expected, method', [
['inchikey', '7783-89-3', 'XQLMNMQWVCXIKR-UHFFFAOYSA-M', 'casno_to_inchikey'],
['inchi', 'XQLMNMQWVCXIKR-UHFFFAOYSA-M', 'InChI=1S/Ag.BrHO3/c;2-1(3)4/h;(H,2,3,4)/q+1;/p-1', 'inchikey_to_inchi'],
['inchikey', 'L-Alanine', 'QNAYBMKLOCPYGJ-REOHCLBHSA-N', 'name_to_inchikey'],
['name', 'QNAYBMKLOCPYGJ-REOHCLBHSA-N', 'L-2-Aminopropanoic acid', 'inchikey_to_name'],
['iupac_name', 'QNAYBMKLOCPYGJ-REOHCLBHSA-N', '(2S)-2-aminopropanoic acid', 'inchikey_to_iupac_name']
['name', 'QNAYBMKLOCPYGJ-REOHCLBHSA-N', 'L-ALANINE', 'inchikey_to_name'],
['iupac_name', 'QNAYBMKLOCPYGJ-REOHCLBHSA-N', '(2S)-2-azaniumylpropanoate', 'inchikey_to_iupac_name']
])
def test_correct_behavior(arg, value, expected, method):
assert asyncio.run(wrap_with_session(CTS, method, [value]))[arg] == expected
Expand Down
2 changes: 1 addition & 1 deletion tests/test_MSP.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
from copy import copy

from app import Application
from pyMSPannotator.app import Application


def test_annotate_MSP_file():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_NLM.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pandas as pd
import pytest

from libs.services.NLM import NLM
from libs.utils.Errors import UnknownResponse
from pyMSPannotator.libs.services.NLM import NLM
from pyMSPannotator.libs.utils.Errors import UnknownResponse
from tests.utils import wrap_with_session


Expand Down
6 changes: 3 additions & 3 deletions tests/test_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import pytest
import mock

from libs.Annotator import Annotator
from libs.utils.Errors import TargetAttributeNotRetrieved
from libs.utils.Job import Job
from pyMSPannotator.libs.Annotator import Annotator
from pyMSPannotator.libs.utils.Errors import TargetAttributeNotRetrieved
from pyMSPannotator.libs.utils.Job import Job


@pytest.mark.parametrize('data, expected, repeat, mocked', [
Expand Down
6 changes: 3 additions & 3 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from aiohttp import ServerDisconnectedError
from aiohttp import web

from libs.services import CTS, CIR
from libs.services.Converter import Converter
from libs.utils.Errors import TargetAttributeNotRetrieved, UnknownResponse
from pyMSPannotator.libs.services import CTS, CIR
from pyMSPannotator.libs.services.Converter import Converter
from pyMSPannotator.libs.utils.Errors import TargetAttributeNotRetrieved, UnknownResponse


def test_query_the_service():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_curator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libs.Curator import Curator
from pyMSPannotator.libs.Curator import Curator


def test_fix_cas_number():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pubchem.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import pytest

from libs.services.PubChem import PubChem
from pyMSPannotator.libs.services.PubChem import PubChem
from frozendict import frozendict

from tests.utils import wrap_with_session
Expand Down

0 comments on commit 0fb090c

Please sign in to comment.