Skip to main content

No project description provided

Project description

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!!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tax2graph-1.0.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

tax2graph-1.0.3-py3-none-any.whl (101.8 kB view details)

Uploaded Python 3

File details

Details for the file tax2graph-1.0.3.tar.gz.

File metadata

  • Download URL: tax2graph-1.0.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for tax2graph-1.0.3.tar.gz
Algorithm Hash digest
SHA256 aae8518e1a876e8a1b335752e4843ddb2e787bfed7f1c4125acd217b65a7611f
MD5 ec4afe9eff72f8fdb514296ddf4a8693
BLAKE2b-256 e0fa0dd24092573dcff85c64c52e47270a7786a775b72be6b9fe419b4ee551b1

See more details on using hashes here.

File details

Details for the file tax2graph-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: tax2graph-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 101.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for tax2graph-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 313e4e1bc744da935cbe50d40e176ed13563fa3d0fcac0979362f869d6fff470
MD5 e32f5bbb3c97161cbeb1d22ecfeb255d
BLAKE2b-256 fc7716797ca57e8654a8f4256317209828c249afe155ea6ebe8d94e0f43a1164

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page