Skip to content

Commit 854438f

Browse files
committed
deploy: 977d3ff
1 parent af377ac commit 854438f

15 files changed

+489
-344
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Tree (main class)
22
=================
33

4-
.. autoclass:: ete4.Tree
4+
.. automodule:: ete4.core.tree
55
:members:
66
:undoc-members:
77
:special-members: __init__

_sources/tutorial/tutorial_trees.rst.txt

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,36 @@ to encode information about the tree topology, branch distances and
5454
node names. Nevertheless, it is not uncommon to find slightly
5555
different variations of the format.
5656

57-
ETE can read and write many of them:
57+
ETE can read and write many of them (normally with ``Tree(...,
58+
parser=...)``, see :ref:`sec:reading-newick`):
5859

5960
.. table::
6061

61-
====== ========================================= =============================================
62-
Format Description Example
63-
====== ========================================= =============================================
64-
0 internal nodes with support (flexible) ((D:0.7,F:0.5)1.0:0.6,(B:0.2,H:0.7)1.0:0.8);
65-
1 internal nodes with names (flexible) ((D:0.7,F:0.5)E:0.6,(B:0.2,H:0.7)B:0.8);
66-
2 internal w/ support, all lengths present ((D:0.7,F:0.5)1.0:0.6,(B:0.2,H:0.7)1.0:0.8);
67-
3 internal w/ names, all lengths present ((D:0.7,F:0.5)E:0.6,(B:0.2,H:0.7)B:0.8);
68-
4 names and lengths for leaves only ((D:0.7,F:0.5),(B:0.2,H:0.7));
69-
5 leaf names and all lengths ((D:0.7,F:0.5):0.6,(B:0.2,H:0.7):0.8);
70-
6 leaf names and internal lengths ((D,F):0.6,(B,H):0.8);
71-
7 all names and leaf lengths ((D:0.7,F:0.5)E,(B:0.2,H:0.7)B);
72-
8 all names (leaves and internal nodes) ((D,F)E,(B,H)B);
73-
9 leaf names only ((D,F),(B,H));
74-
100 topology only ((,),(,));
75-
====== ========================================= =============================================
62+
====== ======================================== =================================
63+
Format Description Example
64+
====== ======================================== =================================
65+
0 (*) internal nodes with support (flexible) ((D:2,E:5)1.0:9,(F:6,G):7);
66+
1 internal nodes with names (flexible) ((D:2,E:5)B:9,(F:6,G):7);
67+
2 internal w/ support, all values present ((D:2,E:5)1.0:9,(F:6,G:3)1.0:7);
68+
3 internal w/ names, all values present ((D:2,E:5)B:9,(F:6,G:3)C:7);
69+
4 names and lengths for leaves only ((D:2,E:5),(F:6,G:3));
70+
5 leaf names and all lengths ((D:2,E:5):9,(F:6,G:3):7);
71+
6 leaf names and internal lengths ((D,F):6,(B,H):8);
72+
7 all names and leaf lengths ((D:2,E:5)B,(F:6,G:3)C);
73+
8 all names (leaves and internal nodes) ((D,E)B,(F,G)C);
74+
9 leaf names only ((D,E),(F,G));
75+
100 topology only ((,),(,));
76+
====== ======================================== =================================
77+
78+
where the example tree would look (more or less) like::
79+
80+
╭╴D:2
81+
╭╴B:9╶┤
82+
│ ╰╴E:5
83+
╶┤
84+
│ ╭╴F:6
85+
╰╴C:7╶┤
86+
╰╴G:3
7687

7788
Formats labeled as *flexible* allow for missing information. For
7889
instance, format 0 will be able to load a newick tree even if it does
@@ -132,6 +143,8 @@ example of the previously populated tree::
132143
# ╰╴j
133144

134145

146+
.. _sec:reading-newick:
147+
135148
Reading newick trees
136149
~~~~~~~~~~~~~~~~~~~~
137150

genindex.html

Lines changed: 91 additions & 80 deletions
Large diffs are not rendered by default.

internals/internals_essentials.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h2>Tree Representation<a class="headerlink" href="#tree-representation" title="
4848
evolutionary distance between the nodes, and other <em>branch
4949
properties</em>.</p>
5050
<img alt="../_images/tree.png" src="../_images/tree.png" />
51-
<p>In the representation that we have chosen, a <a class="reference internal" href="../reference/reference_tree.html#ete4.Tree" title="ete4.Tree"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code></a> is a
51+
<p>In the representation that we have chosen, a <code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code> is a
5252
structure with some content (internally stored in a dictionary
5353
<code class="docutils literal notranslate"><span class="pre">props</span></code> of properties) and a list of <code class="docutils literal notranslate"><span class="pre">children</span></code>, which can be
5454
viewed as trees themselves. It can have a parent (<code class="docutils literal notranslate"><span class="pre">up</span></code>), which is
@@ -64,7 +64,7 @@ <h2>Tree Representation<a class="headerlink" href="#tree-representation" title="
6464
</section>
6565
<section id="size">
6666
<h2>Size<a class="headerlink" href="#size" title="Link to this heading"></a></h2>
67-
<p>A <a class="reference internal" href="../reference/reference_tree.html#ete4.Tree" title="ete4.Tree"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code></a> also has a <code class="docutils literal notranslate"><span class="pre">size</span></code>, which is a tuple <code class="docutils literal notranslate"><span class="pre">(dx,</span> <span class="pre">dy)</span></code>
67+
<p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code> also has a <code class="docutils literal notranslate"><span class="pre">size</span></code>, which is a tuple <code class="docutils literal notranslate"><span class="pre">(dx,</span> <span class="pre">dy)</span></code>
6868
formed by the distance to its further leaf (including its own length),
6969
and the total number of descendant leaves.</p>
7070
<p>This concept is exploited when drawing with different representations,

objects.inv

14 Bytes
Binary file not shown.

py-modindex.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ <h1>Python Module Index</h1>
6363
<td>&#160;&#160;&#160;
6464
<a href="reference/reference_seqgroup.html#module-ete4.core.seqgroup"><code class="xref">ete4.core.seqgroup</code></a></td><td>
6565
<em></em></td></tr>
66+
<tr class="cg-1">
67+
<td></td>
68+
<td>&#160;&#160;&#160;
69+
<a href="reference/reference_tree.html#module-ete4.core.tree"><code class="xref">ete4.core.tree</code></a></td><td>
70+
<em></em></td></tr>
6671
<tr class="cg-1">
6772
<td></td>
6873
<td>&#160;&#160;&#160;

reference/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ <h1>Reference Guide<a class="headerlink" href="#reference-guide" title="Link to
4040
<div class="toctree-wrapper compound">
4141
<ul>
4242
<li class="toctree-l1"><a class="reference internal" href="reference_tree.html">Tree (main class)</a><ul>
43-
<li class="toctree-l2"><a class="reference internal" href="reference_tree.html#ete4.Tree"><code class="docutils literal notranslate"><span class="pre">Tree</span></code></a></li>
43+
<li class="toctree-l2"><a class="reference internal" href="reference_tree.html#ete4.core.tree.Tree"><code class="docutils literal notranslate"><span class="pre">Tree</span></code></a></li>
44+
<li class="toctree-l2"><a class="reference internal" href="reference_tree.html#ete4.core.tree.TreeError"><code class="docutils literal notranslate"><span class="pre">TreeError</span></code></a></li>
4445
</ul>
4546
</li>
4647
<li class="toctree-l1"><a class="reference internal" href="reference_operations.html">Tree operations</a><ul>

reference/reference_parsers.html

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,98 @@ <h1>Parsers<a class="headerlink" href="#parsers" title="Link to this heading">¶
4040
<section id="module-ete4.parser.newick">
4141
<span id="newick"></span><h2>Newick<a class="headerlink" href="#module-ete4.parser.newick" title="Link to this heading"></a></h2>
4242
<p>Parser for trees represented in newick format.</p>
43+
<p>The main functions are <code class="docutils literal notranslate"><span class="pre">loads()</span></code> and <code class="docutils literal notranslate"><span class="pre">dumps()</span></code>, which read/write a tree
44+
from/to its newick text representation.</p>
45+
<p>When reading a newick file, the argument <code class="docutils literal notranslate"><span class="pre">parser=...</span></code> specifies
46+
which kind of parser to use.</p>
47+
<p>The classical ones in ete are the following:</p>
48+
<table class="docutils align-default">
49+
<thead>
50+
<tr class="row-odd"><th class="head"><p>Format</p></th>
51+
<th class="head"><p>Description</p></th>
52+
<th class="head"><p>Example</p></th>
53+
</tr>
54+
</thead>
55+
<tbody>
56+
<tr class="row-even"><td><p>0 (*)</p></td>
57+
<td><p>internal nodes with support (flexible)</p></td>
58+
<td><p>((D:2,E:5)1.0:9,(F:6,G):7);</p></td>
59+
</tr>
60+
<tr class="row-odd"><td><p>1</p></td>
61+
<td><p>internal nodes with names (flexible)</p></td>
62+
<td><p>((D:2,E:5)B:9,(F:6,G):7);</p></td>
63+
</tr>
64+
<tr class="row-even"><td><p>2</p></td>
65+
<td><p>internal w/ support, all values present</p></td>
66+
<td><p>((D:2,E:5)1.0:9,(F:6,G:3)1.0:7);</p></td>
67+
</tr>
68+
<tr class="row-odd"><td><p>3</p></td>
69+
<td><p>internal w/ names, all values present</p></td>
70+
<td><p>((D:2,E:5)B:9,(F:6,G:3)C:7);</p></td>
71+
</tr>
72+
<tr class="row-even"><td><p>4</p></td>
73+
<td><p>names and lengths for leaves only</p></td>
74+
<td><p>((D:2,E:5),(F:6,G:3));</p></td>
75+
</tr>
76+
<tr class="row-odd"><td><p>5</p></td>
77+
<td><p>leaf names and all lengths</p></td>
78+
<td><p>((D:2,E:5):9,(F:6,G:3):7);</p></td>
79+
</tr>
80+
<tr class="row-even"><td><p>6</p></td>
81+
<td><p>leaf names and internal lengths</p></td>
82+
<td><p>((D,F):6,(B,H):8);</p></td>
83+
</tr>
84+
<tr class="row-odd"><td><p>7</p></td>
85+
<td><p>all names and leaf lengths</p></td>
86+
<td><p>((D:2,E:5)B,(F:6,G:3)C);</p></td>
87+
</tr>
88+
<tr class="row-even"><td><p>8</p></td>
89+
<td><p>all names (leaves and internal nodes)</p></td>
90+
<td><p>((D,E)B,(F,G)C);</p></td>
91+
</tr>
92+
<tr class="row-odd"><td><p>9</p></td>
93+
<td><p>leaf names only</p></td>
94+
<td><p>((D,E),(F,G));</p></td>
95+
</tr>
96+
<tr class="row-even"><td><p>100</p></td>
97+
<td><p>topology only</p></td>
98+
<td><p>((,),(,));</p></td>
99+
</tr>
100+
</tbody>
101+
</table>
102+
<p>where the example tree would look (more or less) like:</p>
103+
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> ╭╴D:2
104+
╭╴B:9╶┤
105+
│ ╰╴E:5
106+
╶┤
107+
│ ╭╴F:6
108+
╰╴C:7╶┤
109+
╰╴G:3
110+
</pre></div>
111+
</div>
112+
<p>There are other valid values for <code class="docutils literal notranslate"><span class="pre">parser</span></code>:</p>
113+
<ul class="simple">
114+
<li><p><code class="docutils literal notranslate"><span class="pre">'name'</span></code>, same as 1</p></li>
115+
<li><p><code class="docutils literal notranslate"><span class="pre">'support'</span></code>, same as 0</p></li>
116+
<li><p><code class="docutils literal notranslate"><span class="pre">'multisupport'</span></code>, internal nodes look like <code class="docutils literal notranslate"><span class="pre">((X:5)80/100:7)...</span></code>, that is,
117+
have multiple values of support separated by <code class="docutils literal notranslate"><span class="pre">/</span></code></p></li>
118+
</ul>
119+
<p>More generally, <code class="docutils literal notranslate"><span class="pre">parser</span></code> can be a dictionary that specifies in
120+
detail how to read/write each field. It must say, for leaf and internal
121+
nodes, what <code class="docutils literal notranslate"><span class="pre">p0:p1</span></code> means (which properties they are, including how
122+
to read and write them). For example, the default parser looks like:</p>
123+
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">PARSER_DEFAULT</span> <span class="o">=</span> <span class="p">{</span>
124+
<span class="s1">&#39;leaf&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">NAME</span><span class="p">,</span> <span class="n">DIST</span><span class="p">],</span> <span class="c1"># ((name:dist)x:y);</span>
125+
<span class="s1">&#39;internal&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">SUPPORT</span><span class="p">,</span> <span class="n">DIST</span><span class="p">],</span> <span class="c1"># ((x:y)support:dist);</span>
126+
<span class="p">}</span>
127+
</pre></div>
128+
</div>
129+
<p>where <code class="docutils literal notranslate"><span class="pre">NAME</span></code> and <code class="docutils literal notranslate"><span class="pre">DIST</span></code> are “property dicts”, that have all the
130+
information for a property (<code class="docutils literal notranslate"><span class="pre">pname</span></code>) to know which function to apply
131+
to read/write from/to a string. For example, <code class="docutils literal notranslate"><span class="pre">DIST</span></code> is:</p>
132+
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">DIST</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;pname&#39;</span><span class="p">:</span> <span class="s1">&#39;dist&#39;</span><span class="p">,</span> <span class="s1">&#39;read&#39;</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="s1">&#39;write&#39;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="s1">&#39;</span><span class="si">%g</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="p">)}</span>
133+
</pre></div>
134+
</div>
43135
<dl class="py exception">
44136
<dt class="sig sig-object py" id="ete4.parser.newick.NewickError">
45137
<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">NewickError</span></span><a class="headerlink" href="#ete4.parser.newick.NewickError" title="Link to this definition"></a></dt>

reference/reference_phylo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ <h2>PhyloTree<a class="headerlink" href="#phylotree" title="Link to this heading
4242
<dl class="py class">
4343
<dt class="sig sig-object py" id="ete4.PhyloTree">
4444
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">PhyloTree</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newick</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">children</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alignment</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alg_format</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'fasta'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sp_naming_function</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parser</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ete4/phylo/phylotree.html#PhyloTree"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ete4.PhyloTree" title="Link to this definition"></a></dt>
45-
<dd><p>Bases: <a class="reference internal" href="reference_tree.html#ete4.Tree" title="ete4.core.tree.Tree"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code></a></p>
45+
<dd><p>Bases: <a class="reference internal" href="reference_tree.html#ete4.core.tree.Tree" title="ete4.core.tree.Tree"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code></a></p>
4646
<p>Class to store a phylogenetic tree.</p>
47-
<p>Extends the standard <a class="reference internal" href="reference_tree.html#ete4.Tree" title="ete4.Tree"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code></a> instance by adding
47+
<p>Extends the standard <code class="xref py py-class docutils literal notranslate"><span class="pre">Tree</span></code> instance by adding
4848
specific properties and methods to work with phylogentic trees.</p>
4949
<dl class="py method">
5050
<dt class="sig sig-object py" id="ete4.PhyloTree.__init__">

0 commit comments

Comments
 (0)