Skip to content
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.15.1] - 2024-01-05
### Added
- Tree Constructor: `newick_to_tree` to convert Newick notation to tree.
### Changed
- Tree Exporter: `tree_to_newick` to accept more parameters to parse length and attributes.
### Fixed
- Misc: Automated doctest setup to use os operations instead of string operations.

## [0.15.0] - 2024-01-02
### Added
- Tree Exporter: Export to Newick notation with `tree_to_newick`.
Expand Down Expand Up @@ -419,6 +427,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Utility Iterator: Tree traversal methods.
- Workflow To Do App: Tree use case with to-do list implementation.

[0.15.1]: https://github.com/kayjan/bigtree/compare/0.15.1...0.15.0
[0.15.0]: https://github.com/kayjan/bigtree/compare/0.15.0...0.14.8
[0.14.8]: https://github.com/kayjan/bigtree/compare/0.14.7...0.14.8
[0.14.7]: https://github.com/kayjan/bigtree/compare/0.14.6...0.14.7
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For **Tree** implementation, there are 9 main components.
2. ``Node``, BaseNode with node name attribute
2. [**✨ Constructing Tree**](https://bigtree.readthedocs.io/en/latest/bigtree/tree/construct.html)
1. From `Node`, using parent and children constructors
2. From *str*, using tree display
2. From *str*, using tree display or Newick string notation
3. From *list*, using paths or parent-child tuples
4. From *nested dictionary*, using path-attribute key-value pairs or recursive structure
5. From *pandas DataFrame*, using paths or parent-child columns
Expand Down Expand Up @@ -228,11 +228,11 @@ root.show(style="ascii")

#### 2. **From *str***

Construct nodes only.
Construct nodes only. Newick string notation supports parsing attributes.

{emphasize-lines="13"}
{emphasize-lines="13,25"}
```python
from bigtree import str_to_tree
from bigtree import str_to_tree, newick_to_tree

tree_str = """
a
Expand All @@ -254,6 +254,18 @@ root.show()
# │ └── h
# └── c
# └── f

newick_str = "((d,(g,h)e)b,(f)c)a"
root = newick_to_tree(newick_str)
root.show()
# a
# ├── b
# │ ├── d
# │ └── e
# │ ├── g
# │ └── h
# └── c
# └── f
```

#### 3. **From *list***
Expand Down
1 change: 1 addition & 0 deletions bigtree/tree/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ def newick_to_tree(
Variations supported
- Support special characters ([, ], (, ), :, ,) in node name, attribute name, and attribute values if
they are enclosed in single quotes i.e., '(name:!)'
- If there are no node names, it will be auto-filled with convention `nodeN` with N representing a number

>>> from bigtree import newick_to_tree
>>> root = newick_to_tree("((d,e)b,c)a")
Expand Down