Skip to content

Commit

Permalink
flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dpear committed Mar 1, 2022
1 parent 818d904 commit a5e5b35
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
2 changes: 1 addition & 1 deletion q2_katharoseq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
from ._methods import read_count_threshold, estimating_biomass, biomass_plot

__version__ = _version.get_versions()['version']
__all__ = ['read_count_threshold', 'estimating_biomass']
__all__ = ['read_count_threshold', 'estimating_biomass', 'biomass_plot']
3 changes: 2 additions & 1 deletion q2_katharoseq/_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def estimating_biomass(

return filtered


def biomass_plot(
output_dir: str,
total_reads: qiime2.NumericMetadataColumn,
Expand Down Expand Up @@ -228,7 +229,7 @@ def biomass_plot(
slope = lm.coef_[0]

plt.clf()
plt.scatter(x,y, color='black')
plt.scatter(x, y, color='black')
axes = plt.gca()
x_vals = np.array(axes.get_xlim())
y_vals = intercept + slope * x_vals
Expand Down
48 changes: 21 additions & 27 deletions q2_katharoseq/tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
from qiime2 import CategoricalMetadataColumn
from qiime2 import NumericMetadataColumn

from q2_katharoseq import read_count_threshold, estimating_biomass
from q2_katharoseq import (read_count_threshold,
estimating_biomass,
biomass_plot)
from q2_katharoseq._methods import allosteric_sigmoid
from q2_katharoseq._methods import get_threshold

from os.path import dirname, abspath, join
from inspect import currentframe, getfile



class KatharoSeqTestCase(TestCase):

def setUp(self):
Expand Down Expand Up @@ -54,7 +55,7 @@ def setUp(self):
self.control = 'classic'
self.threshold = 50

def test_outputs_index(self): # OK
def test_outputs_index(self):
with tempfile.TemporaryDirectory() as output_dir:
read_count_threshold(
output_dir,
Expand All @@ -68,7 +69,7 @@ def test_outputs_index(self): # OK
index_fp = os.path.join(output_dir, 'index.html')
self.assertTrue(os.path.exists(index_fp))

def test_invalid_threshold(self): # OK
def test_invalid_threshold(self):
with tempfile.TemporaryDirectory() as output_dir, \
self.assertRaisesRegex(
ValueError,
Expand Down Expand Up @@ -99,7 +100,7 @@ def test_invalid_threshold(self): # OK
self.table,
self.control)

def test_no_positive_controls_in_col(self): # OK
def test_no_positive_controls_in_col(self):
ind = pd.Index(['s1', 's2', 's3', 's4'],
name='sampleid')
positive_control_column = pd.Series(
Expand All @@ -124,7 +125,7 @@ def test_no_positive_controls_in_col(self): # OK
self.table,
self.control)

def test_no_positive_controls_in_table(self): # OK
def test_no_positive_controls_in_table(self):
ind = pd.Index(
['s5', 's6', 's7', 's8'],
name='sampleid')
Expand All @@ -151,14 +152,14 @@ def test_no_positive_controls_in_table(self): # OK
table,
self.control)

def test_sigmoid(self): # OK
def test_sigmoid(self):
x = 1.0
h = 2.0
k_prime = 3.0
a = allosteric_sigmoid(x, h, k_prime)
self.assertTrue(a == .25)

def test_threshold(self): # OK
def test_threshold(self):
r1 = [3.5, 2.3, 1.3, 3.4]
r2 = [1.1, 2.2, 1.7, 2.3]
thresh = 50.0
Expand All @@ -168,16 +169,6 @@ def test_threshold(self): # OK
def test_estimating_biomass(self):
fp = join(dirname(abspath(getfile(currentframe()))), 'support_files')

# One line at top of file describing dtype that throws this off
# data = pd.read_csv(
# f'{fp}/input_estimating_biomass.tsv', sep='\t', dtype={
# 'sample_name': str, 'total_reads': float,
# 'control_cell_into_extraction': float,
# 'extraction_mass_g': float,
# 'positive_control': str})



data = qiime2.Metadata.load(f'{fp}/input_estimating_biomass.tsv')

obs = estimating_biomass(
Expand All @@ -194,7 +185,6 @@ def test_estimating_biomass(self):
f'{fp}/output_estimating_biomass.tsv', sep='\t', index_col=0)
pd.testing.assert_frame_equal(obs, exp)


def test_biomass_plot(self):
fp = join(dirname(abspath(getfile(currentframe()))), 'support_files')

Expand All @@ -207,14 +197,18 @@ def test_biomass_plot(self):

data = qiime2.Metadata.load(f'{fp}/input_estimating_biomass.tsv')

biomass_plot(
total_reads=data.get_column('total_reads'),
control_cell_extraction=data.get_column('control_cell_into_extraction'), # noqa
min_total_reads=1150,
positive_control_value='True',
positive_control_column=data.get_column('positive_control')
)
self.assertTrue(os.path.exists(index_fp))
with tempfile.TemporaryDirectory() as output_dir:
biomass_plot(
total_reads=data.get_column('total_reads'),
control_cell_extraction=data.get_column(
'control_cell_into_extraction'), # noqa
min_total_reads=1150,
positive_control_value='True',
positive_control_column=data.get_column('positive_control')
)

index_fp = os.path.join(output_dir, 'index.html')
self.assertTrue(os.path.exists(index_fp))


if __name__ == '__main__':
Expand Down

0 comments on commit a5e5b35

Please sign in to comment.