[med-svn] [Git][med-team/q2-quality-filter][upstream] New upstream version 2020.11.0
Andreas Tille
gitlab at salsa.debian.org
Thu Dec 3 13:09:44 GMT 2020
Andreas Tille pushed to branch upstream at Debian Med / q2-quality-filter
Commits:
5e6c8680 by Andreas Tille at 2020-12-03T13:58:37+01:00
New upstream version 2020.11.0
- - - - -
13 changed files:
- .travis.yml
- LICENSE
- Makefile
- q2_quality_filter/__init__.py
- q2_quality_filter/_filter.py
- q2_quality_filter/_format.py
- q2_quality_filter/_transformer.py
- q2_quality_filter/_type.py
- q2_quality_filter/_version.py
- q2_quality_filter/plugin_setup.py
- q2_quality_filter/test/__init__.py
- q2_quality_filter/test/test_filter.py
- setup.py
Changes:
=====================================
.travis.yml
=====================================
@@ -14,7 +14,7 @@ install:
- wget -q https://raw.githubusercontent.com/qiime2/environment-files/master/latest/staging/qiime2-latest-py36-linux-conda.yml
- conda env create -q -n test-env --file qiime2-latest-py36-linux-conda.yml
- source activate test-env
- - conda install -q nose
+ - conda install -q pytest-cov
- pip install -q flake8
- pip install -q https://github.com/qiime2/q2lint/archive/master.zip
- make install
=====================================
LICENSE
=====================================
@@ -1,6 +1,6 @@
BSD 3-Clause License
-Copyright (c) 2017-2019, QIIME 2 development team.
+Copyright (c) 2017-2020, QIIME 2 development team.
All rights reserved.
Redistribution and use in source and binary forms, with or without
=====================================
Makefile
=====================================
@@ -9,10 +9,10 @@ lint:
flake8
test: all
- nosetests
+ py.test
test-cov: all
- nosetests
+ py.test --cov=q2_quality_filter
install: all
$(PYTHON) setup.py install
=====================================
q2_quality_filter/__init__.py
=====================================
@@ -1,15 +1,15 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2017-2019, QIIME 2 development team.
+# Copyright (c) 2017-2020, 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 ._filter import q_score, q_score_joined
+from ._filter import q_score
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
-__all__ = ['q_score', 'q_score_joined']
+__all__ = ['q_score']
=====================================
q2_quality_filter/_filter.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2017-2019, QIIME 2 development team.
+# Copyright (c) 2017-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
@@ -61,6 +61,7 @@ _default_params = {
}
+# TODO: fix up demux fmt writing a la q2-cutadapt
def q_score(demux: SingleLanePerSampleSingleEndFastqDirFmt,
min_quality: int = _default_params['min_quality'],
quality_window: int = _default_params['quality_window'],
@@ -182,16 +183,3 @@ def q_score(demux: SingleLanePerSampleSingleEndFastqDirFmt,
stats = pd.DataFrame(stats, columns=columns).set_index('sample-id')
return result, stats
-
-
-def q_score_joined(
- demux: SingleLanePerSampleSingleEndFastqDirFmt,
- min_quality: int = _default_params['min_quality'],
- quality_window: int = _default_params['quality_window'],
- min_length_fraction:
- float = _default_params['min_length_fraction'],
- max_ambiguous: int = _default_params['max_ambiguous']) \
- -> (SingleLanePerSampleSingleEndFastqDirFmt,
- pd.DataFrame):
- return q_score(demux, min_quality, quality_window,
- min_length_fraction, max_ambiguous)
=====================================
q2_quality_filter/_format.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2017-2019, QIIME 2 development team.
+# Copyright (c) 2017-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
=====================================
q2_quality_filter/_transformer.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2017-2019, QIIME 2 development team.
+# Copyright (c) 2017-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
=====================================
q2_quality_filter/_type.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2017-2019, QIIME 2 development team.
+# Copyright (c) 2017-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
=====================================
q2_quality_filter/_version.py
=====================================
@@ -23,9 +23,9 @@ def get_keywords():
# setup.py/versioneer.py will grep for the variable names, so they must
# each be defined on a line of their own. _version.py will just call
# get_keywords().
- git_refnames = " (tag: 2019.10.0)"
- git_full = "fb46c1bd105da7b65d4294351bb1b1cb48f10e48"
- git_date = "2019-11-01 01:04:25 +0000"
+ git_refnames = " (HEAD -> master, tag: 2020.11.0)"
+ git_full = "bdafd7e885b351a99dc45a54abf5fdc1990823b6"
+ git_date = "2020-11-25 17:13:08 +0000"
keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
return keywords
=====================================
q2_quality_filter/plugin_setup.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2016-2019, QIIME 2 development team.
+# Copyright (c) 2016-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
@@ -41,6 +41,14 @@ plugin.register_semantic_type_to_format(
QualityFilterStats,
artifact_format=QualityFilterStatsDirFmt)
+InputMap, OutputMap = qiime2.plugin.TypeMap({
+ SampleData[SequencesWithQuality | PairedEndSequencesWithQuality]:
+ SampleData[SequencesWithQuality],
+
+ SampleData[JoinedSequencesWithQuality]:
+ SampleData[JoinedSequencesWithQuality],
+})
+
_q_score_parameters = {
'min_quality': qiime2.plugin.Int,
'quality_window': qiime2.plugin.Int,
@@ -76,11 +84,10 @@ _q_score_output_descriptions = {
plugin.methods.register_function(
function=q2_quality_filter.q_score,
- inputs={'demux': SampleData[SequencesWithQuality |
- PairedEndSequencesWithQuality]},
+ inputs={'demux': InputMap},
parameters=_q_score_parameters,
outputs=[
- ('filtered_sequences', SampleData[SequencesWithQuality]),
+ ('filtered_sequences', OutputMap),
('filter_stats', QualityFilterStats)
],
input_descriptions=_q_score_input_descriptions,
@@ -91,20 +98,4 @@ plugin.methods.register_function(
'the presence of ambiguous base calls.')
)
-plugin.methods.register_function(
- function=q2_quality_filter.q_score_joined,
- inputs={'demux': SampleData[JoinedSequencesWithQuality]},
- parameters=_q_score_parameters,
- outputs=[
- ('filtered_sequences', SampleData[JoinedSequencesWithQuality]),
- ('filter_stats', QualityFilterStats)
- ],
- input_descriptions=_q_score_input_descriptions,
- parameter_descriptions=_q_score_parameter_descriptions,
- output_descriptions=_q_score_output_descriptions,
- name='Quality filter based on joined sequence quality scores.',
- description='This method filters joined sequence based on quality '
- 'scores and the presence of ambiguous base calls.'
-)
-
importlib.import_module('q2_quality_filter._transformer')
=====================================
q2_quality_filter/test/__init__.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2016-2019, QIIME 2 development team.
+# Copyright (c) 2016-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
=====================================
q2_quality_filter/test/test_filter.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2016-2019, QIIME 2 development team.
+# Copyright (c) 2016-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
@@ -8,6 +8,7 @@
import unittest
import gzip
+import os
import pandas as pd
import pandas.util.testing as pdt
@@ -16,12 +17,17 @@ from qiime2.sdk import Artifact
import numpy as np
import numpy.testing as npt
from qiime2.plugin.testing import TestPluginBase
+from qiime2.util import redirected_stdio
from q2_types.per_sample_sequences import (
- FastqGzFormat,
- SingleLanePerSampleSingleEndFastqDirFmt)
-
-from q2_quality_filter._filter import (_read_fastq_seqs, _runs_of_ones,
- _truncate, q_score, q_score_joined)
+ FastqGzFormat,
+ SingleLanePerSampleSingleEndFastqDirFmt,
+)
+
+from q2_quality_filter._filter import (
+ _read_fastq_seqs,
+ _runs_of_ones,
+ _truncate,
+)
from q2_quality_filter._format import QualityFilterStatsFmt
@@ -75,16 +81,20 @@ class FilterTests(TestPluginBase):
def test_q_score_all_dropped(self):
ar = Artifact.load(self.get_data_path('simple.qza'))
- view = ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
with self.assertRaisesRegex(ValueError, "filtered out"):
- q_score(view, min_quality=50)
+ with redirected_stdio(stdout=os.devnull):
+ self.plugin.methods['q_score'](ar, min_quality=50)
def test_q_score_numeric_ids(self):
ar = Artifact.load(self.get_data_path('numeric_ids.qza'))
- view = ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
exp_sids = {'00123', '0.4560'}
- obs, stats = q_score(view, min_quality=20)
+
+ with redirected_stdio(stdout=os.devnull):
+ obs_ar, stats_ar = self.plugin.methods['q_score'](
+ ar, min_quality=20)
+ obs = obs_ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
+ stats = stats_ar.view(pd.DataFrame)
obs_manifest = obs.manifest.view(obs.manifest.format)
obs_manifest = pd.read_csv(obs_manifest.open(), dtype=str, comment='#')
obs_manifest.set_index('sample-id', inplace=True)
@@ -95,10 +105,12 @@ class FilterTests(TestPluginBase):
def test_q_score(self):
ar = Artifact.load(self.get_data_path('simple.qza'))
- view = ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
- obs_drop_ambig, stats = q_score(view, quality_window=2,
- min_quality=20,
- min_length_fraction=0.25)
+ with redirected_stdio(stdout=os.devnull):
+ obs_drop_ambig_ar, stats_ar = self.plugin.methods['q_score'](
+ ar, quality_window=2, min_quality=20, min_length_fraction=0.25)
+ obs_drop_ambig = obs_drop_ambig_ar.view(
+ SingleLanePerSampleSingleEndFastqDirFmt)
+ stats = stats_ar.view(pd.DataFrame)
exp_drop_ambig = ["@foo_1",
"ATGCATGC",
@@ -108,19 +120,23 @@ class FilterTests(TestPluginBase):
'reads-truncated',
'reads-too-short-after-truncation',
'reads-exceeding-maximum-ambiguous-bases']
- exp_drop_ambig_stats = pd.DataFrame([('foo', 2, 1, 0, 0, 1),
- ('bar', 1, 0, 0, 0, 1)],
+ exp_drop_ambig_stats = pd.DataFrame([('foo', 2., 1., 0., 0., 1.),
+ ('bar', 1., 0., 0., 0., 1.)],
columns=columns)
exp_drop_ambig_stats = exp_drop_ambig_stats.set_index('sample-id')
obs = []
iterator = obs_drop_ambig.sequences.iter_views(FastqGzFormat)
for sample_id, fp in iterator:
- obs.extend([l.strip() for l in gzip.open(str(fp), 'rt')])
+ obs.extend([x.strip() for x in gzip.open(str(fp), 'rt')])
self.assertEqual(obs, exp_drop_ambig)
pdt.assert_frame_equal(stats, exp_drop_ambig_stats.loc[stats.index])
- obs_trunc, stats = q_score(view, quality_window=1, min_quality=33,
- min_length_fraction=0.25)
+ with redirected_stdio(stdout=os.devnull):
+ obs_trunc_ar, stats_ar = self.plugin.methods['q_score'](
+ ar, quality_window=1, min_quality=33, min_length_fraction=0.25)
+ obs_trunc = obs_trunc_ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
+ stats = stats_ar.view(pd.DataFrame)
+
exp_trunc = ["@foo_1",
"ATGCATGC",
"+",
@@ -129,22 +145,24 @@ class FilterTests(TestPluginBase):
"ATA",
"+",
"DDD"]
- exp_trunc_stats = pd.DataFrame([('foo', 2, 1, 0, 0, 1),
- ('bar', 1, 1, 1, 0, 0)],
+ exp_trunc_stats = pd.DataFrame([('foo', 2., 1., 0., 0., 1.),
+ ('bar', 1., 1., 1., 0., 0.)],
columns=columns)
exp_trunc_stats = exp_trunc_stats.set_index('sample-id')
obs = []
for sample_id, fp in obs_trunc.sequences.iter_views(FastqGzFormat):
- obs.extend([l.strip() for l in gzip.open(str(fp), 'rt')])
+ obs.extend([x.strip() for x in gzip.open(str(fp), 'rt')])
self.assertEqual(sorted(obs), sorted(exp_trunc))
pdt.assert_frame_equal(stats, exp_trunc_stats.loc[stats.index])
def test_q_score_real(self):
ar = Artifact.load(self.get_data_path('real_data.qza'))
- view = ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
- obs_result, stats = q_score(view, min_quality=40,
- min_length_fraction=0.24)
+ with redirected_stdio(stdout=os.devnull):
+ obs_ar, stats_ar = self.plugin.methods['q_score'](
+ ar, min_quality=40, min_length_fraction=0.24)
+ obs_result = obs_ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
+ stats = stats_ar.view(pd.DataFrame)
# All input reads are represented here in their post-quality filtered
# form. Reads that are commented out were manually identified as being
@@ -213,21 +231,23 @@ class FilterTests(TestPluginBase):
'reads-truncated',
'reads-too-short-after-truncation',
'reads-exceeding-maximum-ambiguous-bases']
- exp_stats = pd.DataFrame([('foo', 10, 6, 10, 4, 0)],
+ exp_stats = pd.DataFrame([('foo', 10., 6., 10., 4., 0.)],
columns=columns)
exp_stats = exp_stats.set_index('sample-id')
obs = []
iterator = obs_result.sequences.iter_views(FastqGzFormat)
for sample_id, fp in iterator:
- obs.extend([l.strip() for l in gzip.open(str(fp), 'rt')])
+ obs.extend([x.strip() for x in gzip.open(str(fp), 'rt')])
self.assertEqual(obs, exp_result)
pdt.assert_frame_equal(stats, exp_stats.loc[stats.index])
def test_q_score_real_joined(self):
ar = Artifact.load(self.get_data_path('real_data_joined.qza'))
- view = ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
- obs_result, stats = q_score_joined(
- view, min_quality=40, min_length_fraction=0.24)
+ with redirected_stdio(stdout=os.devnull):
+ obs_ar, stats_ar = self.plugin.methods['q_score'](
+ ar, min_quality=40, min_length_fraction=0.24)
+ obs_result = obs_ar.view(SingleLanePerSampleSingleEndFastqDirFmt)
+ stats = stats_ar.view(pd.DataFrame)
# All input reads are represented here in their post-quality filtered
# form. Reads that are commented out were manually identified as being
@@ -296,13 +316,13 @@ class FilterTests(TestPluginBase):
'reads-truncated',
'reads-too-short-after-truncation',
'reads-exceeding-maximum-ambiguous-bases']
- exp_stats = pd.DataFrame([('foo', 10, 6, 10, 4, 0)],
+ exp_stats = pd.DataFrame([('foo', 10., 6., 10., 4., 0.)],
columns=columns)
exp_stats = exp_stats.set_index('sample-id')
obs = []
iterator = obs_result.sequences.iter_views(FastqGzFormat)
for sample_id, fp in iterator:
- obs.extend([l.strip() for l in gzip.open(str(fp), 'rt')])
+ obs.extend([x.strip() for x in gzip.open(str(fp), 'rt')])
self.assertEqual(obs, exp_result)
pdt.assert_frame_equal(stats, exp_stats.loc[stats.index])
=====================================
setup.py
=====================================
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------
-# Copyright (c) 2017-2019, QIIME 2 development team.
+# Copyright (c) 2017-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
View it on GitLab: https://salsa.debian.org/med-team/q2-quality-filter/-/commit/5e6c8680848f5f036216d8a2bbe8de33f318d329
--
View it on GitLab: https://salsa.debian.org/med-team/q2-quality-filter/-/commit/5e6c8680848f5f036216d8a2bbe8de33f318d329
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20201203/d6c3f97c/attachment-0001.html>
More information about the debian-med-commit
mailing list