diff --git a/.github/workflows/sepp_tests.yml b/.github/workflows/sepp_tests.yml index 5ade5203..5ea87a99 100644 --- a/.github/workflows/sepp_tests.yml +++ b/.github/workflows/sepp_tests.yml @@ -8,15 +8,15 @@ on: jobs: python_tests: + strategy: + matrix: + python-version: ["3.9", "3.10"] runs-on: ubuntu-latest - steps: - name: Checkout Repo uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - name: setup conda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: # This uses *miniforge*, rather than *minicond*. The primary difference # is that the defaults channel is not enabled at all @@ -26,22 +26,54 @@ jobs: # conda CLI use-mamba: true mamba-version: "*" - python-version: "3.9" - environment-file: environment.yml + python-version: ${{ matrix.python-version }} + environment-file: ci/environment.yml + auto-activate-base: true + activate-environment: sepp_ci - name: install sepp + shell: bash -el {0} run: | python setup.py config -c python setup.py install - - name: run python tests + - name: run tests shell: bash -el {0} run: | - nosetests test/unittest --with-doctest --with-coverage + conda list + nosetests -w test/unittest --with-doctest --with-coverage - name: convert coverage shell: bash -el {0} run: | coverage lcov - - name: send coverage report + - name: send coverage report. uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: "coverage.lcov" + + linting: + strategy: + matrix: + python-version: ["3.9", "3.10"] + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + - name: setup conda + uses: conda-incubator/setup-miniconda@v3 + with: + # This uses *miniforge*, rather than *minicond*. The primary difference + # is that the defaults channel is not enabled at all + miniforge-version: latest + # These properties enable the use of mamba, which is much faster and far + # less error prone than conda while being completely compatible with the + # conda CLI + use-mamba: true + mamba-version: "*" + python-version: ${{ matrix.python-version }} + environment-file: ci/env_lint.yml + auto-activate-base: true + activate-environment: sepp_lint + - name: linting + shell: bash -el {0} + run: | + flake8 setup.py split_sequences.py distribute_setup.py run_ensemble.py run_sepp.py run_upp.py merge_script.py test/unittest/ sepp/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 00416834..00000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -# Check on http://lint.travis-ci.org/ after modifying it! -sudo: false -language: c -os: - - linux - - osx -env: - - PYVERSION="3.7" - - PYVERSION="3.8" -before_install: - - echo "$TRAVIS_OS_NAME" - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh; fi - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda config --add channels conda-forge - - conda config --add channels https://conda.anaconda.org/bioconda - - conda config --add channels https://conda.anaconda.org/biocore - # Update conda itself - - conda update -q conda - # Useful for debugging any issues with conda - - conda info -a -install: - - conda create -n test_env python=$PYVERSION --file ci/conda_requirements.txt - - source activate test_env - - pip install -r ci/pip_requirements.txt - # install SEPP - - python setup.py config -c - - python setup.py install -script: - - COVERAGE_FILE=.coverage coverage run -p --concurrency=multiprocessing --rcfile .coveragerc setup.py nosetests -w test/unittest/ - - coverage combine - - flake8 setup.py split_sequences.py distribute_setup.py run_ensemble.py run_sepp.py run_upp.py merge_script.py test/unittest/ sepp/ -after_success: - - coveralls diff --git a/ci/conda_requirements.txt b/ci/conda_requirements.txt deleted file mode 100644 index 08a08680..00000000 --- a/ci/conda_requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -nose -pep8 -flake8 -java-jdk diff --git a/ci/env_lint.yml b/ci/env_lint.yml new file mode 100644 index 00000000..19b60673 --- /dev/null +++ b/ci/env_lint.yml @@ -0,0 +1,6 @@ +channels: + - bioconda + - conda-forge + - defaults +dependencies: + - flake8 diff --git a/sepp/environment.yml b/ci/environment.yml similarity index 85% rename from sepp/environment.yml rename to ci/environment.yml index 2f20419c..8e543d58 100644 --- a/sepp/environment.yml +++ b/ci/environment.yml @@ -1,5 +1,6 @@ name: sepp channels: + - bioconda - conda-forge - defaults dependencies: @@ -8,3 +9,4 @@ dependencies: - coverage >= 6 # to ensure lcov option is available - java-jdk - pep8 + - setuptools diff --git a/ci/pip_requirements.txt b/ci/pip_requirements.txt deleted file mode 100644 index 71094bbe..00000000 --- a/ci/pip_requirements.txt +++ /dev/null @@ -1 +0,0 @@ -coveralls diff --git a/sepp/alignment.py b/sepp/alignment.py index c847d956..4d8663f3 100644 --- a/sepp/alignment.py +++ b/sepp/alignment.py @@ -29,8 +29,8 @@ try: from collections.abc import Mapping # noqa except ImportError: - from collections import Mapping - + from collections import Mapping + import copy from sepp import get_logger import io @@ -771,8 +771,8 @@ def merge_in(self, other, convert_to_string=True): if me != me_len and self.is_insertion_column(me): ''' We both have a series of insertion columns''' start = me - while(me != me_len and self.is_insertion_column(me) and - she != she_len and other.is_insertion_column(she)): + while (me != me_len and self.is_insertion_column(me) and + she != she_len and other.is_insertion_column(she)): me += 1 she += 1 merged_insertion_columns += 1 @@ -805,24 +805,24 @@ def merge_in(self, other, convert_to_string=True): self.col_labels[start:me] = list( range(insertion, insertion-run, -1)) insertion -= run - elif(she == she_len or (me != me_len and - self.col_labels[me] < other.col_labels[she])): + elif (she == she_len or (me != me_len and + self.col_labels[me] < other.col_labels[she])): ''' My column is not present (i.e. was allgap) in the "other"''' start = me - while(me < me_len and (she == she_len or me != me_len and - self.col_labels[me] < other.col_labels[she])): + while (me < me_len and (she == she_len or me != me_len and + self.col_labels[me] < other.col_labels[she])): me += 1 run = me - start ins = bytearray(b"-") * run for v in selfother.values(): v[start:start] = ins - elif(me == me_len or (she != she_len and - self.col_labels[me] > other.col_labels[she])): + elif (me == me_len or (she != she_len and + self.col_labels[me] > other.col_labels[she])): ''' Her column is not present (i.e. was allgap) in "me"''' start = she - while(she < she_len and (me == me_len or she != she_len and - self.col_labels[me] > other.col_labels[she])): + while (she < she_len and (me == me_len or she != she_len and + self.col_labels[me] > other.col_labels[she])): she += 1 run = she - start ins = bytearray(b"-") * run @@ -833,8 +833,8 @@ def merge_in(self, other, convert_to_string=True): me_len += run elif self.col_labels[me] == other.col_labels[she]: ''' A shared column''' - while(me < me_len and she < she_len and - self.col_labels[me] == other.col_labels[she]): + while (me < me_len and she < she_len and + self.col_labels[me] == other.col_labels[she]): she += 1 me += 1 else: diff --git a/sepp/config.py b/sepp/config.py index 8c151ffd..00d6d50e 100644 --- a/sepp/config.py +++ b/sepp/config.py @@ -50,6 +50,7 @@ root_p = open(os.path.join(os.path.split( os.path.split(__file__)[0])[0], "home.path")).readlines()[0].strip() +print("root_p='%s'" % root_p) main_config_path = os.path.join(root_p, "main.config") diff --git a/sepp/exhaustive.py b/sepp/exhaustive.py index dc8c2208..fd76659f 100644 --- a/sepp/exhaustive.py +++ b/sepp/exhaustive.py @@ -6,12 +6,12 @@ from sepp.algorithm import AbstractAlgorithm from sepp.config import options from sepp.tree import PhylogeneticTree -from sepp.alignment import MutableAlignment, ExtendedAlignment,\ - hamming_distance +from sepp.alignment import (MutableAlignment, ExtendedAlignment, + hamming_distance) from sepp.problem import SeppProblem, RootProblem from dendropy.datamodel.treemodel import Tree -from sepp.jobs import HMMBuildJob, HMMSearchJob, HMMAlignJob, PplacerJob,\ - MergeJsonJob +from sepp.jobs import (HMMBuildJob, HMMSearchJob, HMMAlignJob, PplacerJob, + MergeJsonJob) from sepp.scheduler import JobPool, Join from sepp import get_logger from sepp.math_utils import lcm diff --git a/sepp/exhaustive_upp.py b/sepp/exhaustive_upp.py index cf56f0eb..227c95ff 100644 --- a/sepp/exhaustive_upp.py +++ b/sepp/exhaustive_upp.py @@ -73,7 +73,7 @@ def generate_backbone(self): fragments = MutableAlignment() if options().median_full_length is not None \ or options().full_length_range is not None: - if options().median_full_length == -1 \ + if options().median_full_length == -1 \ or 0 < options().median_full_length < 1: # for backward compatibility, -1 is mapped to 0.5 quantile. if options().median_full_length == -1: @@ -415,8 +415,8 @@ def augment_parser(): help="Consider all fragments that are 25%% longer or shorter than N " "to be excluded from the backbone. If value is -1, then UPP will" " use the median of the sequences as the median full length. " - "Use 0 < N < 1 for UPP to use quartiles. e.g. 0.25 for the first " - " quartile and 0.75 for the third quartile. " + "Use 0 < N < 1 for UPP to use quartiles. e.g. 0.25 for the " + "first quartile and 0.75 for the third quartile. " "[default: None]") decompGroup.add_argument( "-T", "--backbone_threshold", type=float, diff --git a/sepp/tree.py b/sepp/tree.py index 134aaf65..86240a7d 100644 --- a/sepp/tree.py +++ b/sepp/tree.py @@ -447,5 +447,5 @@ def is_valid_tree(t): if num_children == 2: # What is with this code? Why do we check the same variable twice? # Bug? NN - assert((not rc[0].child_nodes()) and (not rc[0].child_nodes())) + assert ((not rc[0].child_nodes()) and (not rc[0].child_nodes())) return True diff --git a/test/unittest/TestFork.py b/test/unittest/TestFork.py index d40e7e35..c938491f 100644 --- a/test/unittest/TestFork.py +++ b/test/unittest/TestFork.py @@ -100,9 +100,9 @@ def run(): # Test one of the jobs, to see if it is successful if sample_job.ready() and sample_job.successful(): - assert(jobs[3].result_set is True) + assert (jobs[3].result_set is True) else: - assert(jobs[3].result_set is False) + assert (jobs[3].result_set is False) errors = pool.get_all_job_errors() # print("Following job errors were raised:", errors) diff --git a/test/unittest/testAlignment.py b/test/unittest/testAlignment.py index 59a2c2f2..4ca75d30 100644 --- a/test/unittest/testAlignment.py +++ b/test/unittest/testAlignment.py @@ -4,8 +4,8 @@ @author: smirarab ''' import unittest -from sepp.alignment import MutableAlignment, ReadonlySubalignment,\ - ExtendedAlignment +from sepp.alignment import (MutableAlignment, ReadonlySubalignment, + ExtendedAlignment) from sepp.problem import SeppProblem from sepp.filemgr import get_data_path from tempfile import mkstemp diff --git a/test/unittest/testConfig.py b/test/unittest/testConfig.py index c747d76d..c00af38d 100644 --- a/test/unittest/testConfig.py +++ b/test/unittest/testConfig.py @@ -145,12 +145,12 @@ def testLog(self): sepp._DEBUG = True sepp.reset_loggers() sepp.jobs._LOG.debug("test debugging works") - assert(sepp.jobs._LOG.getEffectiveLevel() == logging.DEBUG) + assert (sepp.jobs._LOG.getEffectiveLevel() == logging.DEBUG) sepp._DEBUG = False sepp.reset_loggers() sepp.jobs._LOG.debug("test debugging is disabled") - assert(sepp.jobs._LOG.getEffectiveLevel() == logging.INFO) + assert (sepp.jobs._LOG.getEffectiveLevel() == logging.INFO) sepp._DEBUG = sdb sepp.reset_loggers() diff --git a/test/unittest/testUPP.py b/test/unittest/testUPP.py index dfab7534..befd1674 100644 --- a/test/unittest/testUPP.py +++ b/test/unittest/testUPP.py @@ -60,12 +60,11 @@ def tearDown(self): shutil.rmtree(self.x.options.outdir, ignore_errors=True) def test_id_collision_working(self): - self.x.run() self.assertTrue(self.x.results is not None) - assert(len(self.x.results) == 490) - assert(300 < len(self.x.results['SEQ396']) < 600) - assert(len(self.x.results['SEQ554'].replace('-', '')) == 57) + assert (len(self.x.results) == 490) + assert (300 < len(self.x.results['SEQ396']) < 600) + assert (len(self.x.results['SEQ554'].replace('-', '')) == 57) if __name__ == "__main__":