Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 38f74515 authored by Léo Ackermann's avatar Léo Ackermann
Browse files

:pencil: Fix math display in readme

parent f11e88fe
No related branches found
No related tags found
No related merge requests found
* ☄️ A fast converter from Newick trees to Phylip distance matrices
# 🚀️ nwk2phy is a fast converter from Newick trees to Phylip distance matrices
Typical computation of distance between leaves in a tree takes \(O(n)\) time.
Typical computation of distance between leaves in a tree takes $O(n)$ time.
Hence, computing pairwise distance between leaves of the tree would take
\(O(n^3)\) time. While polynomial, it becomes already impractical for moderate
$O(n^3)$ time. While polynomial, it becomes already impractical for moderate
collections (eg. 1000 genomes).
The `nwk2phy` relies on the folklore construction of datastructure able to
answer Lowest Common Ancestor in the tree in constant time. This comes at the
price of extra linear space, build during a linear time preprocessing phase.
Afterward, the distance queries can be answered in \(O(1)\) time, leading to an
(asymptotically) optimal complexity of \(O(n^2)\).
Afterward, the distance queries can be answered in $O(1)$ time, leading to an
(asymptotically) optimal complexity of $O(n^2)$.
*Note.* This program uses an advanced approach, supplying its speed, but is no
**Note.** This program uses an advanced approach, supplying its speed, but is no
further optimized.
** 🖥️ Usage
## 🖥️ Usage
#+begin_src text
``` text
┓ ┏┓ ┓
┏┓┓┏┏┃┏┏┛┏┓┣┓┓┏
┛┗┗┻┛┛┗┗━┣┛┛┗┗┫ v.0.1
......@@ -37,4 +37,4 @@ USAGE
with respect to the order
LEAVES is the left-to-right leaves order of the tree (default)
LEXICO is the lexicographic order
#+end_src
```
......@@ -31,6 +31,7 @@ def message(*msg):
log_line = f'[nwk2phy, {fdt}] >> {" ".join(msg)}'
print(log_line, file=sys.stderr)
# ----------------------------------------------------------------------------------------
def naive_rmq(l, i, j):
'''
......@@ -337,7 +338,7 @@ class TreeWithEfficientLCA:
if (j-i+1) <= 2*self.block_sz:
imin = min(imin_left_border, imin_right_border, key=self.euler_d.__getitem__)
# Case when the range is already covered by the two border blocks
# Case when the range needed the internal block to be covered
else:
rbmd = self.rmq_blocked_min_depth(ceil(i/self.block_sz), floor(j/self.block_sz) - 1)
imin_blocked_internal = self.blocked_imin_depth[rbmd]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment