alifedata-phyloinformatics-convert


Namealifedata-phyloinformatics-convert JSON
Version 0.16.2 PyPI version JSON
download
home_pagehttps://github.com/mmore500/alifedata-phyloinformatics-convert
Summaryalifedata-phyloinformatics-convert helps apply traditional phyloinformatics software to alife standardized data
upload_time2024-02-20 20:56:03
maintainer
docs_urlNone
authorMatthew Andres Moreno
requires_python>=3.8
licenseMIT license
keywords alifedata-phyloinformatics-convert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==================================
alifedata-phyloinformatics-convert
==================================


.. image:: https://img.shields.io/pypi/v/alifedata-phyloinformatics-convert.svg
        :target: https://pypi.python.org/pypi/alifedata-phyloinformatics-convert
        :alt: PyPI Status

.. image:: https://github.com/mmore500/alifedata-phyloinformatics-convert/actions/workflows/CI.yml/badge.svg
        :target: https://github.com/mmore500/alifedata-phyloinformatics-convert/actions/workflows/CI.yml
        :alt: CI Status

.. image:: https://readthedocs.org/projects/alifedata-phyloinformatics-convert/badge/?version=latest
        :target: https://alifedata-phyloinformatics-convert.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status




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 :code:`apc`'s :code:`RosettaTree` interface for flexible conversion between phylogenetic data structures and schemas.
First, create a :code:`RosettaTree` object from any supported structure/schema

.. code-block:: python3

  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),
  ]:
    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

.. code-block:: python3

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

  # 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 :code:`apc`'s functional interface to convert between alife format other libraries' tree objects

.. code-block:: python3

  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 :code:`apc`'s CLI :code:`toalifedata` command to convert newick, nexml, and nexus data to alife standard phylogenetics data

.. code-block:: bash

  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 :code:`fromalifedata` command to convert to other formats from alife standard phylogenetics data

.. code-block:: bash

  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

.. code-block:: bash

  pip3 install alifedata-phyloinformatics-convert


Credits
-------

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

.. _DendroPy: https://github.com/jeetsukuruman/dendropy
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mmore500/alifedata-phyloinformatics-convert",
    "name": "alifedata-phyloinformatics-convert",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "alifedata-phyloinformatics-convert",
    "author": "Matthew Andres Moreno",
    "author_email": "m.more500@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4b/0d/35086a393d45707a04e25216f822ddf6cd39fe43ec916d8dbaeba113a313/alifedata-phyloinformatics-convert-0.16.2.tar.gz",
    "platform": null,
    "description": "==================================\nalifedata-phyloinformatics-convert\n==================================\n\n\n.. image:: https://img.shields.io/pypi/v/alifedata-phyloinformatics-convert.svg\n        :target: https://pypi.python.org/pypi/alifedata-phyloinformatics-convert\n        :alt: PyPI Status\n\n.. image:: https://github.com/mmore500/alifedata-phyloinformatics-convert/actions/workflows/CI.yml/badge.svg\n        :target: https://github.com/mmore500/alifedata-phyloinformatics-convert/actions/workflows/CI.yml\n        :alt: CI Status\n\n.. image:: https://readthedocs.org/projects/alifedata-phyloinformatics-convert/badge/?version=latest\n        :target: https://alifedata-phyloinformatics-convert.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n\n\n\nalifedata-phyloinformatics-convert helps apply traditional phyloinformatics software to alife standardized data\n\n\n* Free software: MIT license\n* Documentation: https://alifedata-phyloinformatics-convert.readthedocs.io.\n\nUsage\n-----\n\nUse :code:`apc`'s :code:`RosettaTree` interface for flexible conversion between phylogenetic data structures and schemas.\nFirst, create a :code:`RosettaTree` object from any supported structure/schema\n\n.. code-block:: python3\n\n  import io\n  import pathlib\n\n  import alifedata_phyloinformatics_convert as apc\n  import anytree\n  import Bio\n  import dendropy\n  import ete3 as ete\n  import networkx\n  import pandas\n  import phylotrackpy\n\n  newickstr = \"((A,B),(C,D));\"\n\n  for obj in [\n    anytree.AnyNode(),\n    Bio.Phylo.read(io.StringIO(newickstr), \"newick\"),\n    dendropy.Tree.get(data=newickstr, schema=\"newick\"),\n    ete.Tree(newickstr),\n    networkx.DiGraph(),\n    pandas.DataFrame({\"id\": [0], \"ancestor_list\": \"[None]\"}),  # alife standard\n    phylotrackpy.systematics.Systematics(lambda x: x),\n  ]:\n    converter = apc.RosettaTree(obj)\n\n  # from phyloinformatics schema\n  # ... nexml and nexus also supported!\n  converter = apc.RosettaTree.from_newick(newickstr)\n  converter = apc.RosettaTree.from_newick(pathlib.Path(\"read.newick\"))\n  with open(\"read.newick\", \"r\") as fp:\n    converter = apc.RosettaTree.from_newick(fp)\n\n  # from alife standard data via Pandas\n  converter = apc.RosettaTree(pandas.read_csv(\"read-alifestd.csv\"))\n\nThen, convert or serialize data\n\n.. code-block:: python3\n\n  # ... converter created as above\n  converter.as_alife  # pandas DataFrame\n  converter.as_biopython\n  converter.as_dendropy\n  converter.as_ete\n  converter.as_networkx\n  converter.as_phylotrack\n\n  # serialization, nexml and nexus schemata also supported\n  converter.to_newick()  # returns newick string\n  converter.to_newick(pathlib.Path(\"write.newick\"))  # writes to path\n  with open(\"write.newick\", \"w\") as fp:  # writes to file object\n    converter.to_newick(fp)\n\n  # alifestd serialization\n  converter.as_alife.to_csv(\"write-alifestd.csv\", index=False)\n\nUse :code:`apc`'s functional interface to convert between alife format other libraries' tree objects\n\n.. code-block:: python3\n\n  import alifedata_phyloinformatics_convert as apc\n  import pandas\n\n  alife_df = pandas.read_csv('alifedata.csv')\n\n  # biopython\n  tree = apc.alife_dataframe_tobiopython_tree(alife_df)\n  frame = apc.biopython_tree_to_alife_dataframe(tree)\n\n  # dendropy\n  tree = apc.alife_dataframe_to_dendropy_tree(alife_df)\n  frame = apc.dendropy_tree_to_alife_dataframe(tree)\n\n  # ete\n  ete_tree = apc.alife_dataframe_to_ete_tree(alife_df)\n  frame = apc.ete_tree_to_alife_dataframe(tree)\n\n  # networkx\n  digraph = apc.alife_dataframe_to_networkx_digraph(alife_df)\n  frame = apc.networkx_digraph_to_alife_dataframe(digraph)\n\n  # phylotrackpy\n  systematics = apc.alife_dataframe_to_phylotrack_systematics(alife_df)\n  frame = apc.phylotrack_systematics_to_alife_dataframe(systematics)\n\n  # partial support is also included for,\n  # - adjacency lists\n  # - anytree trees\n  # - scipy linkage matrices\n  # ... see API documentation for details\n\nCommand Line Interface\n----------------------\n\nUse :code:`apc`'s CLI :code:`toalifedata` command to convert newick, nexml, and nexus data to alife standard phylogenetics data\n\n.. code-block:: bash\n\n  Usage: alifedata-phyloinformatics-convert toalifedata [OPTIONS]\n\n    convert standard alife phylogeny data to phloinformatics format\n\n  Options:\n    --input-file FILENAME           phyloinformatics data file path; default\n                                    stdin\n    --input-schema TEXT             phyloinformatics data format schema; options\n                                    include newick, nexml, and nexus  [required]\n    --output-file FILENAME          alife data file path; default stdout\n    --output-format TEXT            alife data file format; default csv\n    --suppress-unifurcations / --keep-unifurcations\n                                    Compress sequences of nodes with single\n                                    descendants\n    --help                          Show this message and exit.\n\n\n\nUse the :code:`fromalifedata` command to convert to other formats from alife standard phylogenetics data\n\n.. code-block:: bash\n\n  Usage: alifedata-phyloinformatics-convert fromalifedata [OPTIONS]\n\n    convert phloinformatics data to standard alife phylogeny format\n\n  Options:\n    --input-file FILENAME           alife data file path; default stdin\n    --input-format TEXT             alife data file format; default csv\n    --output-file FILENAME          phyloinformatics data file path; default\n                                    stdout\n    --output-schema TEXT            phyloinformatics data format schema; options\n                                    include newick, nexml, and nexus  [required]\n    --suppress-unifurcations / --keep-unifurcations\n                                    Compress sequences of nodes with single\n                                    descendants\n    --help                          Show this message and exit.\n\nInstallation\n------------\n\nInstall from PyPi\n\n.. code-block:: bash\n\n  pip3 install alifedata-phyloinformatics-convert\n\n\nCredits\n-------\n\nBuilt using the `DendroPy`_ library.\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _DendroPy: https://github.com/jeetsukuruman/dendropy\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "alifedata-phyloinformatics-convert helps apply traditional phyloinformatics software to alife standardized data",
    "version": "0.16.2",
    "project_urls": {
        "Homepage": "https://github.com/mmore500/alifedata-phyloinformatics-convert"
    },
    "split_keywords": [
        "alifedata-phyloinformatics-convert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45f9a588aa8e3015480a9e68de592e942421f6b8243d83fbdf9b448e08446f24",
                "md5": "37ed318ab69462452f038a9a7bbf6e00",
                "sha256": "93d7297aa39681767a75b382055cc71b59a411221396a6837289a5efe9979069"
            },
            "downloads": -1,
            "filename": "alifedata_phyloinformatics_convert-0.16.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37ed318ab69462452f038a9a7bbf6e00",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 34100,
            "upload_time": "2024-02-20T20:56:02",
            "upload_time_iso_8601": "2024-02-20T20:56:02.344631Z",
            "url": "https://files.pythonhosted.org/packages/45/f9/a588aa8e3015480a9e68de592e942421f6b8243d83fbdf9b448e08446f24/alifedata_phyloinformatics_convert-0.16.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b0d35086a393d45707a04e25216f822ddf6cd39fe43ec916d8dbaeba113a313",
                "md5": "dcd551a9f7ec17f958faf416a18a24ae",
                "sha256": "547fcb1ab6f20a29f6f7670df969870a94563293783d1c5a6a09d1dd945e57da"
            },
            "downloads": -1,
            "filename": "alifedata-phyloinformatics-convert-0.16.2.tar.gz",
            "has_sig": false,
            "md5_digest": "dcd551a9f7ec17f958faf416a18a24ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 173012,
            "upload_time": "2024-02-20T20:56:03",
            "upload_time_iso_8601": "2024-02-20T20:56:03.770921Z",
            "url": "https://files.pythonhosted.org/packages/4b/0d/35086a393d45707a04e25216f822ddf6cd39fe43ec916d8dbaeba113a313/alifedata-phyloinformatics-convert-0.16.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-20 20:56:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mmore500",
    "github_project": "alifedata-phyloinformatics-convert",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "alifedata-phyloinformatics-convert"
}
        
Elapsed time: 0.18583s