Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-related updates #15

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,9 @@ conda env create -n q2-boots-2024.10 -f https://raw.githubusercontent.com/qiime2
conda activate q2-boots-2024.10
```

## Testing and using `q2-boots`
## Using `q2-boots`

After completing the install steps above, confirm that everything is working as expected by running:

```shell
make test
```

You should get a report that tests were run, and you should see that all tests passed and none failed.
It's usually ok if some warnings are reported.

If all of the tests pass, you're ready to use the plugin.
Start by making QIIME 2's command line interface aware of `q2-boots` by running:
After completing the install steps above, make QIIME 2's command line interface aware of `q2-boots` by running:

```shell
qiime dev refresh-cache
Expand Down
5 changes: 0 additions & 5 deletions q2_boots/_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ def _bootstrap_iteration(table: biom.Table, sampling_depth: int) -> biom.Table:
table = table.subsample(sampling_depth, axis='sample', by_id=False,
with_replacement=True)

if table.is_empty():
return ValueError('The output table contains no samples or features.'
'Verify your table is valid and that you provided a '
'shallow enough samplign depth')

return table


Expand Down
36 changes: 33 additions & 3 deletions q2_boots/tests/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,42 @@

class TestBootstrapIteration(TestCase):

def test_bootstrap_iteration(self):
def test_bootstrap_iteration_filters_samples(self):
t = Table(np.array([[0, 1, 3], [1, 1, 2]]),
['O1', 'O2'],
['S1', 'S2', 'S3'])
a = _bootstrap_iteration(t, 2)
self.assertEqual(a.shape, (2, 2))

observed = _bootstrap_iteration(t, 6)
self.assertTrue(observed.is_empty())

observed = _bootstrap_iteration(t, 5)
self.assertEqual(list(observed.ids(axis='sample')), ['S3'])

observed = _bootstrap_iteration(t, 2)
self.assertEqual(list(observed.ids(axis='sample')), ['S2', 'S3'])

observed = _bootstrap_iteration(t, 1)
self.assertEqual(list(observed.ids(axis='sample')), ['S1', 'S2', 'S3'])

def test_bootstrap_iteration_obtains_expected_counts(self):
t = Table(np.array([[0, 10, 30], [1, 10, 20]]),
['O1', 'O2'],
['S1', 'S2', 'S3'])

observed = _bootstrap_iteration(t, 1)
self.assertEqual(list(observed.sum(axis="sample")), [1., 1., 1.])

observed = _bootstrap_iteration(t, 10)
self.assertEqual(list(observed.sum(axis="sample")), [10., 10.])

observed = _bootstrap_iteration(t, 19)
self.assertEqual(list(observed.sum(axis="sample")), [19., 19.])

observed = _bootstrap_iteration(t, 25)
self.assertEqual(list(observed.sum(axis="sample")), [25.])

observed = _bootstrap_iteration(t, 49)
self.assertEqual(list(observed.sum(axis="sample")), [49.])


if __name__ == "__main__":
Expand Down
Loading