alifedata-phyloinformatics-convert
alifedata-phyloinformatics-convert helps apply traditional phyloinformatics software to alife standardized data
- Free software: MIT license
- Documentation: https://alifedata-phyloinformatics-convert.readthedocs.io.
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
import treeswift
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),
treeswift.Tree.read_tree_newick(newickstr),
networkx.DiGraph(),
pandas.DataFrame({"id": [0], "ancestor_list": "[None]"}), # alife standard
phylotrackpy.systematics.Systematics(lambda x: x),
]:
converter = apc.RosettaTree(obj)
# from phyloinformatics schema
# ... nexml and nexus also supported!
converter = apc.RosettaTree.from_newick(newickstr)
converter = apc.RosettaTree.from_newick(pathlib.Path("read.newick"))
with open("read.newick", "r") as fp:
converter = apc.RosettaTree.from_newick(fp)
# from alife standard data via Pandas
converter = apc.RosettaTree(pandas.read_csv("read-alifestd.csv"))
Then, convert or serialize data
# ... converter created as above
converter.as_alife # pandas DataFrame
converter.as_biopython
converter.as_dendropy
converter.as_ete
converter.as_networkx
converter.as_phylotrack
converter.as_treeswift
# serialization, nexml and nexus schemata also supported
converter.to_newick() # returns newick string
converter.to_newick(pathlib.Path("write.newick")) # writes to path
with open("write.newick", "w") as fp: # writes to file object
converter.to_newick(fp)
# alifestd serialization
converter.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)
# treeswift
treeswift_tree = apc.alife_dataframe_to_treeswift_tree(alife_df)
frame = apc.treeswift_tree_to_alife_dataframe(tree)
# 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
Citing
If alifedata-phyloinformatics-convert is used in scientific publication, please cite it as
Matthew Andres Moreno and Santiago Rodriguez Papa. (2024). mmore500/alifedata-phyloinformatics-convert. Zenodo. https://doi.org/10.5281/zenodo.10701178
@software{moreno2024apc,
author = {Matthew Andres Moreno AND Santiago {Rodriguez Papa}},
title = {mmore500/alifedata-phyloinformatics-convert},
month = feb,
year = 2024,
publisher = {Zenodo},
doi = {10.5281/zenodo.10701178},
url = {https://doi.org/10.5281/zenodo.10701178}
}
And don't forget to leave a star on GitHub!
Credits
Built using the DendroPy library. This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Metadata
Release files for alifedata-phyloinformatics-convert 0.19.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| alifedata-phyloinformatics-convert-0.19.3.tar.gz | 177.2 kB | Without provenance | Details for alifedata-phyloinformatics-convert-0.19.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| alifedata_phyloinformatics_convert-0.19.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for alifedata_phyloinformatics_convert-0.19.3-py2.py3-none-any.whl |
Total release size: 219.1 kB
Release files / alifedata-phyloinformatics-convert-0.19.3.tar.gz
| Download URL | alifedata-phyloinformatics-convert-0.19.3.tar.gz |
|---|---|
| Size | 177.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fddece392351898410a0b1741d213d2f4e09b130ee39ceeaaddfd4375619f408
|
|
BLAKE2b-256 checksum How to use checksums |
9a41aff0111e41f7a29abd9c5a15865fe523c0367ddb07b070ec1e432c109c88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / alifedata_phyloinformatics_convert-0.19.3-py2.py3-none-any.whl
| Download URL | alifedata_phyloinformatics_convert-0.19.3-py2.py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e0f9ebf41452e21e88070d91fc0135e4ec82f54215940aec825c07d20ef35c15
|
|
BLAKE2b-256 checksum How to use checksums |
25500c9de488f350b81b365511cf710bf8d38b214292ef07b4954b44edbbb2e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for alifedata-phyloinformatics-convert 0.19.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.