Skip to content

Commit

Permalink
completed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyunzhu committed Feb 5, 2021
1 parent 4dfb38a commit 776f7cc
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 4 deletions.
2 changes: 1 addition & 1 deletion woltka/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def table_add_metacol(table, dic, name, missing=''):
"""
# redirect to BIOM module
if isinstance(table, Table):
biom_add_metacol(table, dic, name, missing='')
biom_add_metacol(table, dic, name, missing=missing)
return

# add metadata column
Expand Down
60 changes: 60 additions & 0 deletions woltka/tests/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ woltka classify \
--output bowtie2.free.tsv
```

`bowtie2.free.1p.tsv`:

```bash
woltka tools filter \
--input output/bowtie2.free.tsv \
--min-percent 1 \
--output bowtie2.free.1p.tsv
```

`blastn.species.tsv`:

```bash
Expand Down Expand Up @@ -146,6 +155,15 @@ woltka classify \
--output split.process.tsv
```

`merged.process.tsv`:

```bash
woltka tools merge \
--input output/burst.process.tsv \
--input output/split.process.tsv \
--output merged.process.tsv
```

`diamond.free.tsv`

```bash
Expand All @@ -169,3 +187,45 @@ woltka classify \
--rank function \
--output diamond.func.tsv
```

`truth.gene.tsv`

```bash
woltka classify \
--input align/truth/b6o \
--coords function/nucl/coords.txt.xz \
--output truth.gene.tsv
```

`truth.uniref.tsv`

```bash
woltka classify \
--input align/truth/b6o \
--coords function/nucl/coords.txt.xz \
--map function/nucl/uniref.map.xz \
--names function/uniref.names.xz \
--map-as-rank \
--rank uniref \
--output truth.uniref.tsv
```

Or:

```bash
woltka tools collapse \
--input output/truth.gene.tsv \
--map function/nucl/uniref.map.xz \
--names function/uniref.names.xz \
--output truth.uniref.tsv
```

`truth.goslim.tsv`

```bash
woltka tools collapse \
--input output/truth.uniref.tsv \
--map function/go/goslim.tsv.xz \
--names function/go/name.txt.xz \
--output truth.goslim.tsv
```
Binary file added woltka/tests/data/align/truth/b6o/S01.b6o.xz
Binary file not shown.
Binary file added woltka/tests/data/align/truth/b6o/S02.b6o.xz
Binary file not shown.
Binary file added woltka/tests/data/align/truth/b6o/S03.b6o.xz
Binary file not shown.
Binary file added woltka/tests/data/align/truth/b6o/S04.b6o.xz
Binary file not shown.
Binary file added woltka/tests/data/align/truth/b6o/S05.b6o.xz
Binary file not shown.
30 changes: 30 additions & 0 deletions woltka/tests/data/output/bowtie2.free.1p.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#FeatureID S01 S02 S03 S04 S05
1028307 0 0 0 1888 0
1125630 0 778 0 0 0
1133852 0 0 864 0 0
176299 0 0 22 0 0
190304 0 26 0 0 226
190485 0 0 0 0 88
198214 0 0 42 0 0
208435 0 0 0 22 0
211586 0 672 0 0 0
220341 0 0 0 0 436
224324 0 0 50 0 0
243160 132 0 36 0 0
243231 0 0 0 0 120
246196 176 0 0 0 0
272560 48 0 0 0 0
272621 0 0 22 0 0
272631 0 0 0 0 86
272947 0 0 54 0 0
295405 0 270 0 0 0
300852 1614 0 0 0 0
333849 0 0 0 54 0
365659 0 0 156 0 0
366394 0 88 0 0 0
380703 0 0 0 0 954
393305 0 0 640 0 0
413999 0 80 0 0 0
441771 0 62 0 0 0
525903 0 0 0 0 56
585056 0 0 22 0 0
205 changes: 205 additions & 0 deletions woltka/tests/data/output/merged.process.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
#FeatureID S01 S02 S03 S04 S05
GO:0000160 0 6 2 0 0
GO:0000162 2 0 0 4 0
GO:0000724 0 4 0 0 0
GO:0000746 0 0 3 0 0
GO:0000917 0 0 0 0 2
GO:0002949 0 0 1 0 0
GO:0005975 16 4 6 4 6
GO:0005978 4 0 0 0 0
GO:0005991 0 0 8 0 0
GO:0006002 4 2 0 0 0
GO:0006007 0 0 0 0 2
GO:0006011 0 0 9 0 0
GO:0006012 0 0 2 0 0
GO:0006071 2 0 0 0 2
GO:0006090 4 0 4 0 0
GO:0006091 0 4 0 0 2
GO:0006096 2 8 4 0 0
GO:0006097 4 0 0 0 0
GO:0006099 0 0 2 0 0
GO:0006106 0 0 0 0 4
GO:0006207 4 0 0 0 0
GO:0006221 6 0 0 0 0
GO:0006259 0 4 0 0 0
GO:0006260 0 8 2 0 10
GO:0006265 10 0 0 2 4
GO:0006268 0 0 4 0 0
GO:0006281 7 8 18 0 6
GO:0006298 4 0 0 0 2
GO:0006302 0 0 4 0 0
GO:0006310 4 1 6 2 0
GO:0006313 14 6 1 10 0
GO:0006351 4 0 0 0 0
GO:0006352 0 4 4 0 0
GO:0006355 11 8 4 15 10
GO:0006364 4 0 0 0 2
GO:0006383 0 0 0 0 2
GO:0006396 8 0 4 0 2
GO:0006400 0 0 0 0 6
GO:0006412 16 2 7 10 8
GO:0006414 0 0 0 2 0
GO:0006415 0 4 0 0 0
GO:0006418 4 8 4 0 8
GO:0006419 4 0 0 0 0
GO:0006420 1 0 0 0 0
GO:0006421 2 0 0 0 0
GO:0006427 0 0 0 4 0
GO:0006429 12 0 0 0 0
GO:0006431 4 0 0 0 0
GO:0006432 2 0 0 0 0
GO:0006433 2 0 0 0 0
GO:0006435 6 4 4 0 0
GO:0006457 4 2 4 0 0
GO:0006464 0 0 0 3 0
GO:0006465 4 0 0 0 0
GO:0006520 8 0 0 0 4
GO:0006522 0 0 4 0 0
GO:0006526 4 0 0 0 0
GO:0006527 0 0 0 4 0
GO:0006537 0 2 4 0 0
GO:0006541 2 0 0 0 0
GO:0006564 2 0 0 0 0
GO:0006576 0 0 0 0 4
GO:0006596 0 4 0 0 0
GO:0006614 0 0 3 0 0
GO:0006629 0 4 0 0 3
GO:0006633 0 0 0 0 6
GO:0006655 0 0 2 0 0
GO:0006696 2 0 0 0 0
GO:0006725 0 3 4 0 2
GO:0006777 4 0 0 0 0
GO:0006779 0 0 4 0 0
GO:0006782 2 0 0 0 0
GO:0006783 4 2 4 0 0
GO:0006790 0 0 0 0 4
GO:0006799 0 0 2 0 0
GO:0006807 0 4 4 4 0
GO:0006810 0 4 4 12 6
GO:0006811 0 4 2 0 0
GO:0006813 2 8 4 0 2
GO:0006814 0 2 0 0 0
GO:0006821 0 0 0 0 4
GO:0006855 0 0 6 0 0
GO:0006865 0 2 4 0 6
GO:0006935 0 3 0 0 0
GO:0007049 0 0 0 0 4
GO:0007155 6 2 3 4 0
GO:0007156 0 4 0 0 0
GO:0007165 0 6 0 0 4
GO:0008152 4 2 18 4 8
GO:0008295 5 0 0 0 0
GO:0008299 2 0 0 0 0
GO:0008360 2 0 4 0 2
GO:0008610 4 0 0 0 0
GO:0008616 4 0 0 0 0
GO:0008643 0 7 5 12 0
GO:0008654 4 0 0 0 0
GO:0009056 0 4 0 0 0
GO:0009058 6 4 6 0 2
GO:0009059 4 0 0 2 0
GO:0009060 4 0 0 0 0
GO:0009063 0 0 4 0 0
GO:0009072 4 0 0 0 2
GO:0009073 3 0 0 4 0
GO:0009086 0 0 0 4 0
GO:0009089 0 2 4 0 4
GO:0009098 4 0 0 0 0
GO:0009103 2 0 6 0 2
GO:0009116 1 0 3 0 0
GO:0009166 2 0 0 0 0
GO:0009228 9 0 3 0 0
GO:0009234 4 0 0 0 4
GO:0009236 4 0 0 0 0
GO:0009244 0 4 0 0 0
GO:0009245 0 2 2 0 0
GO:0009252 0 0 4 0 0
GO:0009253 0 0 0 0 4
GO:0009264 2 0 0 0 0
GO:0009271 0 0 1 0 0
GO:0009306 0 2 4 0 1
GO:0009401 0 4 5 3 0
GO:0009404 0 0 2 0 0
GO:0009405 0 0 7 0 4
GO:0009435 0 2 0 0 0
GO:0009446 0 0 0 4 0
GO:0009972 0 0 4 0 0
GO:0009987 0 2 6 10 4
GO:0010033 0 2 0 0 0
GO:0010038 2 0 0 0 0
GO:0010124 4 0 0 0 0
GO:0010133 0 0 0 0 2
GO:0010468 0 0 0 0 2
GO:0015031 2 2 2 4 0
GO:0015074 0 0 4 0 0
GO:0015628 0 0 0 0 2
GO:0015803 0 0 4 0 0
GO:0015833 4 0 0 8 0
GO:0015889 0 0 1 0 0
GO:0015891 0 0 4 0 0
GO:0015909 0 2 0 0 0
GO:0015937 4 0 0 0 0
GO:0015976 0 4 2 0 0
GO:0015986 0 0 2 0 2
GO:0016051 0 4 0 0 0
GO:0016114 0 0 0 0 2
GO:0016539 0 0 0 0 4
GO:0017003 4 0 0 0 0
GO:0017004 0 0 2 0 0
GO:0018339 4 0 0 0 0
GO:0019285 0 0 4 0 0
GO:0019310 0 4 0 4 0
GO:0019354 2 0 0 0 0
GO:0019439 4 0 2 0 0
GO:0019544 0 0 0 0 2
GO:0019569 0 0 0 2 0
GO:0019700 0 0 6 0 0
GO:0019752 0 0 0 4 0
GO:0022904 4 0 0 0 0
GO:0030001 0 4 0 0 0
GO:0030091 0 2 0 0 0
GO:0030436 0 3 0 0 0
GO:0031119 4 0 0 0 0
GO:0033539 0 0 0 2 0
GO:0034641 0 0 10 6 4
GO:0042128 2 0 0 0 0
GO:0042254 4 0 0 0 0
GO:0042426 0 0 0 0 4
GO:0042773 1 0 0 0 0
GO:0043039 0 0 4 0 0
GO:0043213 0 0 0 3 0
GO:0043571 2 0 0 0 0
GO:0044179 0 0 1 0 0
GO:0044205 6 0 0 0 0
GO:0044208 2 0 0 0 0
GO:0044209 0 0 0 0 5
GO:0044237 4 0 20 3 5
GO:0044238 0 0 2 0 0
GO:0044249 0 0 2 0 0
GO:0044260 6 0 2 0 0
GO:0044281 0 0 0 2 0
GO:0045454 0 2 0 0 2
GO:0045892 0 0 2 4 0
GO:0045900 0 0 0 0 4
GO:0046416 0 0 0 0 1
GO:0046854 1 1 0 0 0
GO:0050794 0 0 0 0 2
GO:0051191 0 0 0 2 0
GO:0051301 2 0 2 3 2
GO:0055070 0 0 2 0 0
GO:0055085 19 4 22 0 29
GO:0055086 0 0 1 0 0
GO:0055114 0 0 7 0 4
GO:0055129 2 0 0 0 0
GO:0070084 4 0 0 2 0
GO:0070475 0 4 0 0 0
GO:0071470 0 3 0 0 0
GO:0071704 0 0 0 2 0
GO:0071705 0 0 4 0 0
GO:0071840 1 0 0 0 0
GO:0071973 0 0 2 0 4
GO:0097588 0 2 0 0 0
GO:1901135 0 0 0 0 2
GO:1901564 0 0 5 0 0
GO:1902600 0 0 4 2 2
GO:1902604 0 0 0 0 2
6 changes: 6 additions & 0 deletions woltka/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,12 @@ def test_collapse_table(self):
for i in range(4):
self.assertListEqual(obs[i], exp[i])

# BIOM table
table_ = Table(*map(np.array, table))
obs = collapse_table(table_, mapping)
exp = Table(*map(np.array, exp))
self.assertEqual(obs.descriptive_equality(exp), 'Tables appear equal')

# some missing, some extra
mapping = {'G1': ['H1'], 'G2': ['H2'], 'G3': ['H3'], 'G9': ['H9']}
obs = collapse_table(table, mapping)
Expand Down
13 changes: 10 additions & 3 deletions woltka/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ def intize(num):
Notes
-----
This function is for demo purpose. Use `initize_list` or `initize_dict` to
save function-calling overhead in data-intensive operations.
Limited by Python floating point arithmetic, odds are that when ambiguous
assignment is on, counts will be sums of fractions and they can be rounded
either up or down when converted to integers, depending how these numbers
Expand Down Expand Up @@ -161,6 +158,11 @@ def intize_list(lst):
See Also
--------
intize
Notes
-----
Use this function instead of `initize` on large lists to save some
function-calling overhead.
"""
for i, element in enumerate(lst):
near = round(element * 2) / 2
Expand All @@ -183,6 +185,11 @@ def intize_dict(dic, zero=False):
See Also
--------
intize
Notes
-----
Use this function instead of `initize` on large dictionaries to save some
function-calling overhead.
"""
todel = []
add_todel = todel.append
Expand Down

0 comments on commit 776f7cc

Please sign in to comment.