Skip to content

Commit

Permalink
MAINT: lint, test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcaporaso committed Sep 20, 2017
1 parent 4509214 commit 9cebd13
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 28 deletions.
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
branch = True
omit =
*/tests*
*/__init__.py

[report]
omit =
*/tests*
*/__init__.py
32 changes: 18 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
dist: trusty
sudo: false
language: python
env:
- PYTHON_VERSION=3.5
before_install:
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/miniconda3/bin:$PATH
- export MPLBACKEND='Agg'
- wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- export MINICONDA_PREFIX="$HOME/miniconda"
- bash miniconda.sh -b -p $MINICONDA_PREFIX
- export PATH="$MINICONDA_PREFIX/bin:$PATH"
- conda config --set always_yes yes
- conda update -q conda
- conda info -a
install:
# q2-dummy-types is only required for the dummy methods and
# visualizers provided as examples. Remove this dependency when you're
# ready to develop your plugin, and add your own dependencies (if there are
# any).
- conda create --yes -n test-env -c qiime2 python=$PYTHON_VERSION qiime nose flake8
- conda create -q -n test-env --file https://raw.githubusercontent.com/qiime2/environment-files/master/latest/staging/qiime2-latest-conda-linux-64.txt
- source activate test-env
- pip install .
- conda install -q pytest-cov
- pip install -q flake8 coveralls
- pip install -q https://github.com/qiime2/q2lint/archive/master.zip
- make install
script:
- nosetests
- flake8 q2_vsearch setup.py
- make lint
- make test-cov
after_success:
- coveralls
6 changes: 4 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Copyright (c) 2016, QIIME 2 Development Team
BSD 3-Clause License

Copyright (c) 2016-2017, QIIME 2 development team.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -11,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of qiime2 nor the names of its
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

Expand Down
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: all lint test test-cov install dev clean distclean

all: ;

lint:
q2lint
flake8

test: all
py.test

test-cov: all
py.test --cov=q2_vsearch

install: all
python setup.py install

dev: all
pip install -e .

clean: distclean

distclean: ;
8 changes: 8 additions & 0 deletions q2_vsearch/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2017, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------

__version__ = "0.0.7.dev0"
10 changes: 10 additions & 0 deletions q2_vsearch/_cluster_features.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2017, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------

import tempfile
import subprocess
Expand All @@ -6,6 +13,7 @@
import skbio
from q2_types.feature_data import DNAFASTAFormat


def run_command(cmd, verbose=True):
print("Running external command line application. This may print "
"messages to stdout and/or stderr.")
Expand All @@ -16,6 +24,7 @@ def run_command(cmd, verbose=True):
print(" ".join(cmd), end='\n\n')
subprocess.run(cmd, check=True)


def _collapse_f_from_uc(uc):
id_to_centroid = {}
for line in uc:
Expand Down Expand Up @@ -44,6 +53,7 @@ def collapse_f(id_, x):

return collapse_f


def cluster_features_denovo(sequences: DNAFASTAFormat, table: biom.Table,
id: float) -> (biom.Table, DNAFASTAFormat):
sequences_fp = str(sequences)
Expand Down
19 changes: 13 additions & 6 deletions q2_vsearch/plugin_setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2017, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------

import qiime2.plugin

import q2_vsearch
import q2_vsearch._cluster_features
from q2_types.feature_data import DNAFASTAFormat, FeatureData, Sequence
from q2_types.feature_data import FeatureData, Sequence
from q2_types.feature_table import FeatureTable, Frequency

plugin = qiime2.plugin.Plugin(
Expand All @@ -28,14 +36,14 @@
('clustered_table', FeatureTable[Frequency]),
('clustered_sequences', FeatureData[Sequence]),
],
input_descriptions = {
input_descriptions={
'table': 'The feature table to be clustered.',
'sequences': 'The sequences corresponding to the features in table.',
},
parameter_descriptions = {
parameter_descriptions={
'id': 'The percent identity at which clustering should be performed.',
},
output_descriptions = {
output_descriptions={
'clustered_table': 'The table following clustering of features.',
'clustered_sequences': 'Sequences representing clustered features.',
},
Expand All @@ -54,6 +62,5 @@
'were clustered in that sample. Feature identifiers and '
'sequences will be inherited from the centroid feature '
'of each cluster. See the vsearch documentation for details '
'on how sequence clustering is performed.'
)
'on how sequence clustering is performed.')
)
9 changes: 3 additions & 6 deletions q2_vsearch/tests/test_cluster_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
# ----------------------------------------------------------------------------

import os
import unittest
import skbio
import subprocess
import biom
import numpy as np
import pandas as pd

from qiime2.plugin.testing import TestPluginBase
from qiime2.util import redirected_stdio
Expand Down Expand Up @@ -41,13 +38,13 @@ def test_no_clustering(self):
# order of identifiers is important for biom.Table equality
obs_table = \
obs_table.sort_order(input_table.ids(axis='observation'),
axis='observation')
axis='observation')
self.assertEqual(obs_table, input_table)

obs_seqs = list(skbio.io.read(str(obs_sequences),
constructor=skbio.DNA, format='fasta'))
constructor=skbio.DNA, format='fasta'))
exp_seqs = list(skbio.io.read(str(input_sequences),
constructor=skbio.DNA, format='fasta'))
constructor=skbio.DNA, format='fasta'))
print(obs_seqs)
print(exp_seqs)
self.assertEqual(obs_seqs, exp_seqs)
Expand Down
17 changes: 17 additions & 0 deletions q2_vsearch/tests/test_plugin_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2017, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------

import unittest

from q2_vsearch.plugin_setup import plugin as vsearch_plugin


class PluginSetupTests(unittest.TestCase):

def test_plugin_setup(self):
self.assertEqual(vsearch_plugin.name, 'vsearch')
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2017, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------

from setuptools import setup, find_packages
import re
import ast
Expand Down

0 comments on commit 9cebd13

Please sign in to comment.