Skip to content

Commit

Permalink
MultiTax version 1.2.1 (#11)
Browse files Browse the repository at this point in the history
* v1.2.1 fix bug custom files

* tests and pep8

* docs

* travis
  • Loading branch information
pirovc authored Nov 1, 2022
1 parent 572383b commit 649024a
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
4 changes: 3 additions & 1 deletion docs/multitax.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ <h1 class="modulename">
<span class="n">names</span><span class="p">[</span><span class="n">node</span><span class="p">]</span> <span class="o">=</span> <span class="n">fields</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cols</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]]</span>
<span class="k">if</span> <span class="s2">&quot;rank&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cols</span><span class="p">:</span>
<span class="n">ranks</span><span class="p">[</span><span class="n">node</span><span class="p">]</span> <span class="o">=</span> <span class="n">fields</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cols</span><span class="p">[</span><span class="s2">&quot;rank&quot;</span><span class="p">]]</span>
<span class="k">return</span> <span class="n">nodes</span><span class="p">,</span> <span class="n">ranks</span><span class="p">,</span> <span class="n">names</span>

<span class="k">return</span> <span class="n">nodes</span><span class="p">,</span> <span class="n">ranks</span><span class="p">,</span> <span class="n">names</span>

<span class="k">def</span> <span class="nf">_parse_cols</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cols</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cols</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
Expand Down Expand Up @@ -468,6 +469,7 @@ <h5>Inherited Members</h5>
<span class="n">nodes</span><span class="p">[</span><span class="n">taxid</span><span class="p">]</span> <span class="o">=</span> <span class="n">parent_taxid</span>
<span class="n">names</span><span class="p">[</span><span class="n">taxid</span><span class="p">]</span> <span class="o">=</span> <span class="n">name</span>
<span class="n">ranks</span><span class="p">[</span><span class="n">taxid</span><span class="p">]</span> <span class="o">=</span> <span class="n">rank</span>

<span class="k">return</span> <span class="n">nodes</span><span class="p">,</span> <span class="n">ranks</span><span class="p">,</span> <span class="n">names</span>
</pre></div>

Expand Down
12 changes: 4 additions & 8 deletions docs/multitax/multitax.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h1 class="modulename">

<span class="k">class</span> <span class="nc">MultiTax</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>

<span class="n">version</span> <span class="o">=</span> <span class="s2">&quot;1.2.0&quot;</span>
<span class="n">version</span> <span class="o">=</span> <span class="s2">&quot;1.2.1&quot;</span>

<span class="n">_default_urls</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">_default_root_node</span> <span class="o">=</span> <span class="s2">&quot;1&quot;</span>
Expand Down Expand Up @@ -427,7 +427,6 @@ <h1 class="modulename">
<span class="sd"> Returns a list with the lineage of a given node.</span>
<span class="sd"> If ranks is provided, returns only nodes annotated with such ranks.</span>
<span class="sd"> If root_node is provided, use it instead of default root of tree.</span>
<span class="sd"> ranks and root_node are ignored if build_lineages() was used.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># If lineages were built with build_lineages() with matching params</span>
<span class="k">if</span> <span class="n">node</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lineages</span> <span class="ow">and</span> <span class="n">root_node</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">ranks</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
Expand Down Expand Up @@ -724,7 +723,7 @@ <h1 class="modulename">
<summary>View Source</summary>
<div class="pdoc-code codehilite"><pre><span></span><span class="k">class</span> <span class="nc">MultiTax</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>

<span class="n">version</span> <span class="o">=</span> <span class="s2">&quot;1.2.0&quot;</span>
<span class="n">version</span> <span class="o">=</span> <span class="s2">&quot;1.2.1&quot;</span>

<span class="n">_default_urls</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">_default_root_node</span> <span class="o">=</span> <span class="s2">&quot;1&quot;</span>
Expand Down Expand Up @@ -1027,7 +1026,6 @@ <h1 class="modulename">
<span class="sd"> Returns a list with the lineage of a given node.</span>
<span class="sd"> If ranks is provided, returns only nodes annotated with such ranks.</span>
<span class="sd"> If root_node is provided, use it instead of default root of tree.</span>
<span class="sd"> ranks and root_node are ignored if build_lineages() was used.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># If lineages were built with build_lineages() with matching params</span>
<span class="k">if</span> <span class="n">node</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lineages</span> <span class="ow">and</span> <span class="n">root_node</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">ranks</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
Expand Down Expand Up @@ -1472,7 +1470,7 @@ <h1 class="modulename">
<div id="MultiTax.version" class="classattr">
<div class="attr variable"><a class="headerlink" href="#MultiTax.version">#&nbsp;&nbsp</a>

<span class="name">version</span><span class="default_value"> = &#39;1.2.0&#39;</span>
<span class="name">version</span><span class="default_value"> = &#39;1.2.1&#39;</span>
</div>


Expand Down Expand Up @@ -1750,7 +1748,6 @@ <h1 class="modulename">
<span class="sd"> Returns a list with the lineage of a given node.</span>
<span class="sd"> If ranks is provided, returns only nodes annotated with such ranks.</span>
<span class="sd"> If root_node is provided, use it instead of default root of tree.</span>
<span class="sd"> ranks and root_node are ignored if build_lineages() was used.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># If lineages were built with build_lineages() with matching params</span>
<span class="k">if</span> <span class="n">node</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lineages</span> <span class="ow">and</span> <span class="n">root_node</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">ranks</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
Expand Down Expand Up @@ -1796,8 +1793,7 @@ <h1 class="modulename">

<div class="docstring"><p>Returns a list with the lineage of a given node.
If ranks is provided, returns only nodes annotated with such ranks.
If root_node is provided, use it instead of default root of tree.
ranks and root_node are ignored if build_lineages() was used.</p>
If root_node is provided, use it instead of default root of tree.</p>
</div>


Expand Down
2 changes: 1 addition & 1 deletion docs/search.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion multitax/customtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def _parse(self, fhs, **kwargs):
names[node] = fields[self._cols["name"]]
if "rank" in self._cols:
ranks[node] = fields[self._cols["rank"]]
return nodes, ranks, names

return nodes, ranks, names

def _parse_cols(self, cols):
if isinstance(cols, list):
Expand Down
1 change: 1 addition & 0 deletions multitax/greengenestx.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ def _parse(self, fhs, **kwargs):
nodes[taxid] = parent_taxid
names[taxid] = name
ranks[taxid] = rank

return nodes, ranks, names
3 changes: 1 addition & 2 deletions multitax/multitax.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class MultiTax(object):

version = "1.2.0"
version = "1.2.1"

_default_urls = []
_default_root_node = "1"
Expand Down Expand Up @@ -307,7 +307,6 @@ def lineage(self, node: str, root_node: str = None, ranks: list = None):
Returns a list with the lineage of a given node.
If ranks is provided, returns only nodes annotated with such ranks.
If root_node is provided, use it instead of default root of tree.
ranks and root_node are ignored if build_lineages() was used.
"""
# If lineages were built with build_lineages() with matching params
if node in self._lineages and root_node is None and ranks is None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="multitax",
version="1.2.0",
version="1.2.1",
url="https://www.github.com/pirovc/multitax",
license="MIT",
author="Vitor C. Piro",
Expand Down
Binary file added tests/multitax/data_minimal/custom2.tsv.gz
Binary file not shown.
6 changes: 4 additions & 2 deletions tests/multitax/integration/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class TestCommon(unittest.TestCase):
taxonomies["greengenes"] = {"class": GreengenesTx,
"params": {"files": [data_dir + "gg.txt.gz"]}}
taxonomies["custom"] = {"class": CustomTx,
"params": {"files": [data_dir + "custom.tsv.gz"]}}
"params": {"files": [data_dir + "custom.tsv.gz",
data_dir + "custom2.tsv.gz"]}}

@classmethod
def setUpClass(self):
Expand Down Expand Up @@ -59,7 +60,8 @@ def test_fail_to_download(self):
"""
with self.assertRaises(Exception):
with self.assertWarns(UserWarning):
tax = self.taxonomies["ncbi"]["class"](urls=["www.thisisnotawebsite.com/neither/a/file", "fasfafsafasfasf"])
tax = self.taxonomies["ncbi"]["class"](
urls=["www.thisisnotawebsite.com/neither/a/file", "fasfafsafasfasf"])

def test_urls_output_prefix(self):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/multitax/integration/test_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

sys.path.append("tests/multitax/")


@unittest.skip('Skip online by default')
class TestOnline(unittest.TestCase):

Expand Down

0 comments on commit 649024a

Please sign in to comment.