No project description provided
Project description
tax2graph
Goal
tax2graph
provide a simple way to convert i4Life tabled taxonomy to Neo4J graph representation.
Example data
A example data are available on data folder. It contains the Sordariomycetes taxonomy downloaded from "i4Life WP4 Download Service of the Catalogue of Life: Darwin Core Archive Export" (see http://www.catalogueoflife.org/DCA_Export/).
Usage
Initialize a connection dict containing at last the password key to perform queries to Neo4J database:
from tax2graph import GraphBuilder, ConnectionType
connection_variables: ConnectionType = {
"password": str(os.getenv('NEO_PASSWORD'))
}
builder = GraphBuilder(connection_variables)
And build the graph from Sordariomycetes tab-separated file:
builder.read('tax2graph/data/sordariomycetes/taxa.txt')
builder.build_col_graph()
After load the base taxonomy, the Manager class can be used to perform queries. To perform simple queries use:
from tax2graph import Manager
manager = Manager(connection_variables)
manager.get_node('Glomerellales')
manager.get_parent('Glomerellales')
In the above code the constructor of Manager class require the 'connection_variables' to be started, like GraphBuilder class. After started both methods get_node
and get_parent
are called. Both receives a simgle parameter as string indicating the name of the Node to search. The former return an dict containing the target (e.g. order Glomerellales) node and the last return the parent node (e.g. class Sordariomycetes).
The manager class also contain a single method to create custom nodes. To this, simpleously use set_custom_node
, as example:
from tax2graph import CustomNodeType
custom_node: CustomNodeType = {
'taxonRank': 'species',
'description': 'A custom clade'
}
manager.set_custom_node(custom_node, 'Colletotrichum')
This method receive two parameters: the first is a dict of CustomNodeType type that contains two keys, as taxonRank
and description
; and the second is a string indicating the parent node in with the custom_node will be connected.
Feel free to add new features and contribute through pull requests. Be happy!!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for tax2graph-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6416c95cfdb4f7bda6732d0e1afe62618b456ee52a66d6199f090cb552faaffb |
|
MD5 | f1af3b12f0baf60a194e129220d3f628 |
|
BLAKE2b-256 | 0a8f18a4dc7318f0b6e7d0aee24a9174a5291c08258bca39c2ac8d45d98d21b1 |