Skip to content

Commit

Permalink
Add bioconda badge and increase test coverage (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Jan 1, 2019
1 parent baac86b commit 45e2736
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 45 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![Code Coverage](https://codecov.io/gh/clintval/sample-sheet/branch/master/graph/badge.svg)](https://codecov.io/gh/clintval/sample-sheet)
[![PyPi Release](https://badge.fury.io/py/sample_sheet.svg)](https://badge.fury.io/py/sample_sheet)
[![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat-square)](http://bioconda.github.io/recipes/sample-sheet/README.html)
[![License](https://img.shields.io/pypi/l/sample-sheet.svg)](https://github.com/clintval/sample-sheet/blob/master/LICENSE)
[![Python Versions](https://img.shields.io/pypi/pyversions/sample-sheet.svg)](https://pypi.python.org/pypi/sample-sheet/)
[![MyPy Checked](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
Expand Down
20 changes: 6 additions & 14 deletions sample_sheet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
from pathlib import Path
from string import ascii_letters, digits, punctuation
from textwrap import wrap

from requests.structures import CaseInsensitiveDict
from smart_open import smart_open # type: ignore
from tabulate import tabulate # type: ignore
from typing import (
Any,
Generator,
Expand All @@ -26,21 +22,17 @@
Union,
)

from requests.structures import CaseInsensitiveDict
from smart_open import smart_open # type: ignore
from tabulate import tabulate # type: ignore
from terminaltables import SingleTable

from .util import maybe_render_markdown

__all__: List[str] = ['ReadStructure', 'Sample', 'SampleSheet']

__version__ = '0.8.0'


try: # pragma: no cover
from terminaltables import SingleTable # type: ignore

HAS_TERMINALTABLES = True
except ImportError:
HAS_TERMINALTABLES = False


DESIGN_HEADER: List[str] = [
'Sample_ID',
'Sample_Name',
Expand Down Expand Up @@ -941,7 +933,7 @@ def __str__(self) -> str:
except OSError: # pragma: no cover
in_terminal = False

if in_terminal and HAS_TERMINALTABLES:
if in_terminal: # pragma: no cover
return self._repr_tty_()
else:
return self.__repr__()
Expand Down
4 changes: 2 additions & 2 deletions sample_sheet/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=E0401
from typing import Any, List
from typing import Any

__all__: List[str] = ['is_ipython_interpreter', 'maybe_render_markdown']
__all__ = ['is_ipython_interpreter', 'maybe_render_markdown']


def is_ipython_interpreter() -> bool: # pragma: no cover
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
license='MIT',
zip_safe=True,
packages=find_packages(),
install_requires=['click', 'smart_open>=1.5.4', 'tabulate'],
extras_requires={'cli': ['terminaltables']},
install_requires=[
'click',
'smart_open>=1.5.4',
'tabulate',
'terminaltables',
],
scripts=['scripts/sample-sheet'],
keywords='illumina samplesheet sample sheet parser bioinformatics',
classifiers=[
Expand Down
29 changes: 18 additions & 11 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
black==18.6b2
coverage==4.5
flake8==3.5.0
mypy==0.620
nose==1.3.7
pylint==2.0.0
pytest==3.6.3
pytest-cov==2.5.1
pytest-remotedata==0.3.0
pytest-doctestplus==0.1.3
pytest-parallel==0.0.2
black
coverage
flake8
flake8-eradicate
flake8-blind-except
flake8-builtins
flake8-bugbear
flake8-import-order
flake8-logging-format
flake8-rst-docstrings
hypothesis
mypy
nose
pylint
pytest
pytest-cov
pytest-doctestplus
pytest-parallel
29 changes: 15 additions & 14 deletions tests/test_sample_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from requests.exceptions import HTTPError

from sample_sheet import * # Test import of __all__
from sample_sheet import HAS_TERMINALTABLES

RESOURCES = Path(__file__).absolute().resolve().parent / 'resources'

Expand Down Expand Up @@ -129,6 +128,13 @@ def test_add_samples(self):
eq_(len(sample_sheet.samples), 2)
eq_(sample_sheet.samples[0], sample1)

def test_add_sample_without_sample_id(self):
"""Test adding a sample without a sample ID"""
sample = Sample()
sample_sheet = SampleSheet()
with pytest.raises(ValueError):
sample_sheet.add_sample(sample)

def test_add_sample_with_index(self):
"""Test that the SampleSheet sets a sample with attribute ``index``"""
sample = Sample({'Sample_ID': 0, 'index': 'ACGTTNAT'})
Expand Down Expand Up @@ -718,33 +724,28 @@ def test_repr(self):
'SampleSheet(\'{}\')'.format(infile),
)

@pytest.mark.xfail(reasion="Not sure if multi-line diff is correct")
@pytest.mark.skipif(
not HAS_TERMINALTABLES,
reason="We need `terminaltables` installed here",
)
def test_repr_tty(self):
"""Test ``_repr_tty_()``"""
self.maxDiff = 3000
sample_sheet = SampleSheet(RESOURCES / 'paired-end-single-index.csv')
source = '\n' + ''.join(decode_vt_100(sample_sheet._repr_tty_()))
target = (
'\n┌Header─────────────┬─────────────────────────────────┐'
'\nIEM1_File_Version │ 4 │'
'\nInvestigator_Name │ jdoe │'
'\nExperiment_Name │ exp001 │'
'\nIEM1FileVersion │ 4 │'
'\nInvestigator Name │ jdoe │'
'\nExperiment Name │ exp001 │'
'\n│ Date │ 11/16/2017 │'
'\n│ Workflow │ SureSelectXT │'
'\n│ Application │ NextSeq FASTQ Only │'
'\n│ Assay │ SureSelectXT │'
'\n│ Description │ A description of this flow cell │'
'\n│ Chemistry │ Default │'
'\n└───────────────────┴─────────────────────────────────┘'
'\n┌Settings──────────────────────┬──────────┐'
'\ncreate_fastq_for_index_reads │ 1 │'
'\nbarcode_mismatches │ 2 │'
'\nreads │ 151, 151 │'
'\n└──────────────────────────────┴──────────┘'
'\n┌Settings──────────────────┬──────────┐'
'\nCreateFastqForIndexReads │ 1 │'
'\nBarcodeMismatches │ 2 │'
'\nReads │ 151, 151 │'
'\n└──────────────────────────┴──────────┘'
'\n┌Identifiers┬──────────────┬────────────┬──────────┬────────┐'
'\n│ Sample_ID │ Sample_Name │ Library_ID │ index │ index2 │'
'\n├───────────┼──────────────┼────────────┼──────────┼────────┤'
Expand Down

0 comments on commit 45e2736

Please sign in to comment.