Crates.io | gtdb_tree |
lib.rs | gtdb_tree |
version | 0.1.9 |
source | src |
created_at | 2024-09-04 09:09:27.294163 |
updated_at | 2024-09-07 11:43:35.193002 |
description | A library for parsing Newick format files, especially GTDB tree files. |
homepage | https://github.com/eric9n/gtdb_tree |
repository | https://github.com/eric9n/gtdb_tree |
max_upload_size | |
id | 1363077 |
size | 23,859 |
A library for parsing Newick format files, especially GTDB tree files.
Add this crate to your Cargo.toml
:
[dependencies]
gtdb_tree = "0.1.9"
Here's a simple example of how to use the library:
use gtdb_tree::tree::parse_tree;
fn main() {
let newick_str = "((A:0.1,B:0.2):0.3,C:0.4);";
match parse_tree(newick_str) {
Ok(nodes) => println!("Parsed nodes: {:?}", nodes),
Err(e) => println!("Error parsing: {:?}", e),
}
}
A Python package for parsing GTDB trees using Rust.
pip install gtdb_tree
import gtdb_tree
result = gtdb_tree.parse_tree("((A:0.1,B:0.2):0.3,C:0.4);")
print(result)
You can provide a custom parser function to handle special node formats:
import gtdb_tree
def custom_parser(node_str):
# Custom parsing logic
name, length = node_str.split(':')
return name, 100.0, float(length) # name, bootstrap, length
result = gtdb_tree.parse_tree("((A:0.1,B:0.2):0.3,C:0.4);", custom_parser=custom_parser)
print(result)