Skip to main content
PyPI Status CI Status Documentation Status

alifedata-phyloinformatics-convert helps apply traditional phyloinformatics software to alife standardized data

Usage

Use apc’s RosettaTree interface for flexible conversion between phylogenetic data structures and schemas. First, create a RosettaTree object from any supported structure/schema

import io
import pathlib

import alifedata_phyloinformatics_convert as apc
import anytree
import Bio
import dendropy
import ete3 as ete
import networkx
import pandas
import phylotrackpy

newickstr = "((A,B),(C,D));"

for obj in [
  anytree.AnyNode(),
  Bio.Phylo.read(io.StringIO(newickstr), "newick"),
  dendropy.Tree.get(data=newickstr, schema="newick"),
  ete.Tree(newickstr),
  networkx.DiGraph(),
  pandas.DataFrame({"id": [0], "ancestor_list": "[None]"}),  # alife standard
  phylotrackpy.systematics.Systematics(lambda x: x),
]:
  rt = apc.RosettaTree(obj)

# from phyloinformatics schema
# ... nexml and nexus also supported!
rt = apc.RosettaTree.from_newick(newickstr)
rt = apc.RosettaTree.from_newick(pathlib.Path("read.newick"))
with open("read.newick", "r") as fp:
  rt = apc.RosettaTree.from_newick(fp)

# from alife standard data via Pandas
rt = apc.RosettaTree(pandas.read_csv("read-alifestd.csv"))

Then, convert or serialize data

# ... rt created as above
rt.as_alife  # pandas DataFrame
rt.as_biopython
rt.as_dendropy
rt.as_ete
rt.as_networkx
rt.as_phylotrack

# serialization, nexml and nexus schemata also supported
rt.to_newick()  # returns newick string
rt.to_newick(pathlib.Path("write.newick"))  # writes to path
with open("write.newick", "w") as fp:  # writes to file object
  rt.to_newick(fp)

# alifestd serialization
rt.as_alife.to_csv("write-alifestd.csv", index=False)

Use apc’s functional interface to convert between alife format other libraries’ tree objects

import alifedata_phyloinformatics_convert as apc
import pandas

alife_df = pandas.read_csv('alifedata.csv')

# biopython
tree = apc.alife_dataframe_tobiopython_tree(alife_df)
frame = apc.biopython_tree_to_alife_dataframe(tree)

# dendropy
tree = apc.alife_dataframe_to_dendropy_tree(alife_df)
frame = apc.dendropy_tree_to_alife_dataframe(tree)

# ete
ete_tree = apc.alife_dataframe_to_ete_tree(alife_df)
frame = apc.ete_tree_to_alife_dataframe(tree)

# networkx
digraph = apc.alife_dataframe_to_networkx_digraph(alife_df)
frame = apc.networkx_digraph_to_alife_dataframe(digraph)

# phylotrackpy
systematics = apc.alife_dataframe_to_phylotrack_systematics(alife_df)
frame = apc.phylotrack_systematics_to_alife_dataframe(systematics)

# partial support is also included for,
# - adjacency lists
# - anytree trees
# - scipy linkage matrices
# ... see API documentation for details

Command Line Interface

Use apc’s CLI toalifedata command to convert newick, nexml, and nexus data to alife standard phylogenetics data

Usage: alifedata-phyloinformatics-convert toalifedata [OPTIONS]

  convert standard alife phylogeny data to phloinformatics format

Options:
  --input-file FILENAME           phyloinformatics data file path; default
                                  stdin
  --input-schema TEXT             phyloinformatics data format schema; options
                                  include newick, nexml, and nexus  [required]
  --output-file FILENAME          alife data file path; default stdout
  --output-format TEXT            alife data file format; default csv
  --suppress-unifurcations / --keep-unifurcations
                                  Compress sequences of nodes with single
                                  descendants
  --help                          Show this message and exit.

Use the fromalifedata command to convert to other formats from alife standard phylogenetics data

Usage: alifedata-phyloinformatics-convert fromalifedata [OPTIONS]

  convert phloinformatics data to standard alife phylogeny format

Options:
  --input-file FILENAME           alife data file path; default stdin
  --input-format TEXT             alife data file format; default csv
  --output-file FILENAME          phyloinformatics data file path; default
                                  stdout
  --output-schema TEXT            phyloinformatics data format schema; options
                                  include newick, nexml, and nexus  [required]
  --suppress-unifurcations / --keep-unifurcations
                                  Compress sequences of nodes with single
                                  descendants
  --help                          Show this message and exit.

Installation

Install from PyPi

pip3 install alifedata-phyloinformatics-convert

Credits

Built using the DendroPy library. This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Download files

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

Source Distribution

alifedata-phyloinformatics-convert-0.15.1.tar.gz (172.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alifedata_phyloinformatics_convert-0.15.1-py2.py3-none-any.whl (33.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file alifedata-phyloinformatics-convert-0.15.1.tar.gz.

File metadata

File hashes

Hashes for alifedata-phyloinformatics-convert-0.15.1.tar.gz
Algorithm Hash digest
SHA256 c2cdd3ec4d38f90dc2e09536ae7b871f778e4777359e21fd1fd81881d604c627
MD5 1e8414abf139f25a52a49d4be4959613
BLAKE2b-256 a8eb46b6565c32fc01c3f2475baef6314812374cb418a6585339e80d6f9f4afb

See more details on using hashes here.

File details

Details for the file alifedata_phyloinformatics_convert-0.15.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for alifedata_phyloinformatics_convert-0.15.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ffec150ce5e1d7cd8c6e5c6b1de627a8434be95a5570682411836d914ae53521
MD5 43dcfc9320494fd0a92ec8954c5a7048
BLAKE2b-256 6965cb5b902ff39a215e5ebdae163cf5b48523206fe1015354bb7c2eba51d809

See more details on using hashes here.

Supported by

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