Skip to main content

tax2graph

Glomerellales graph

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:

import os
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', low_memory=False)

builder.build_col_graph()

The second parameter (low_memoty) is optional and is the same of pandas.read_csv() (see details in https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html).

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.

You can also include properties to relationships. To do, simpleously create an instance of CustomRelPropertiesType and include an additional parameter as the third argument of set_custom_node method.

from datetime import datetime
from tax2graph import CustomRelPropertiesType

relationship_properties: CustomRelPropertiesType = {
    'created': datetime.now()
}

manager.set_custom_node(custom_node, 'Colletotrichum', relationship_properties)

Feel free to add new features and contribute through pull requests. Be happy!!

Release files for tax2graph 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tax2graph 1.0.3
File Size Uploaded
tax2graph-1.0.3.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tax2graph 1.0.3
File Interpreter ABI Platform
tax2graph-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 106.8 kB

Release files / tax2graph-1.0.3.tar.gz

Download URL tax2graph-1.0.3.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aae8518e1a876e8a1b335752e4843ddb2e787bfed7f1c4125acd217b65a7611f
BLAKE2b-256 checksum
How to use checksums
e0fa0dd24092573dcff85c64c52e47270a7786a775b72be6b9fe419b4ee551b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

Release files / tax2graph-1.0.3-py3-none-any.whl

Download URL tax2graph-1.0.3-py3-none-any.whl
Size 101.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
313e4e1bc744da935cbe50d40e176ed13563fa3d0fcac0979362f869d6fff470
BLAKE2b-256 checksum
How to use checksums
fc7716797ca57e8654a8f4256317209828c249afe155ea6ebe8d94e0f43a1164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

1 release file

1.0.1

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page