Metadata-Version: 2.1
Name: shiptv
Version: 0.4.1
Summary: Generate a standalone HTML file with an interactive phylogenetic tree using PhyloCanvas
Home-page: https://github.com/peterk87/shiptv
Author: Peter Kruczkiewicz
Author-email: peter.kruczkiewicz@gmail.com
License: Apache Software License 2.0
Keywords: shiptv
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: rich
Requires-Dist: typer
Requires-Dist: jinja2
Requires-Dist: pandas
Requires-Dist: biopython
Requires-Dist: requests

=================================================
Standalone HTML Interactive Phylogenetic Tree Viz
=================================================


.. image:: https://img.shields.io/pypi/v/shiptv.svg
        :target: https://pypi.python.org/pypi/shiptv

.. image:: https://github.com/peterk87/shiptv/workflows/CI/badge.svg
        :target: https://github.com/peterk87/shiptv/actions?query=workflow%3ACI

.. image:: https://readthedocs.org/projects/shiptv/badge/?version=latest
        :target: https://shiptv.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status


Generate a standalone HTML file with an interactive phylogenetic tree using PhyloCanvas_


* Free software: Apache Software License 2.0
* Documentation: https://shiptv.readthedocs.io.

*See test shiptv HTML output here:*

- `fmdv-5-shiptv.html`_


**Phylogenetic tree of 5 FMDV genomes**

.. image:: docs/images/fmdv5.png
        :alt: Phylogenetic tree of 5 FMDV genomes

**Phylogenetic tree of IAV HA gene sequences**

.. image:: docs/images/iav-ha-gene-tree-scrn.png
        :alt: Phylogenetic tree of IAV HA gene sequences


Features
--------

* Interactively view your tree in the browser with metadata highlighted beside your tree using PhyloCanvas.
* Visualize your own metadata! Provide a tab-delimited table as input with ``--metadata your-metadata-table.tsv``
* Select metadata fields to display beside phylogenetic tree with select box
* Automatically retrieve metadata from a GenBank file!
* Highlight branches with low support in the browser.
* Collapse branches with low support (e.g. ``-C 95`` for IQ-TREE trees with UFBoot ``-bb 1000`` to collapse branches with less than 95% support).
* Toggle full window mode with ``shift+ctrl+f``. Works well with F11 fullscreen mode.

Usage
-----

Show help info:

.. code-block::

    $ shiptv --help

Install shiptv completions for current shell:

.. code-block::

    $ shiptv --install-completion

Most basic usage would be to create a tree from a Newick format tree file:

.. code-block::

    $ shiptv -n newick.treefile -o shiptv-tree.html

More advanced usage would be to provide a tab-delimited table of metadata with the first field containing sample names identical to those in the Newick tree file:

.. code-block::

    $ shiptv -n newick.treefile --metadata my-metadata.tsv -o shiptv-tree.html


With a reference sequence Genbank file `ref.gb`, a Newick format phylogenetic tree `tree.nwk`, output a `tree.html` standalone HTML interactive phylogenetic tree visualization and a `metadata-table.tsv` tab-delimited table of metadata from `ref.gb`.

.. code-block:: bash

    shiptv -r ref.gb -n tree.nwk -o tree.html -m metadata-table.tsv


Help output

.. code-block::

    $ shiptv --help
    Usage: shiptv [OPTIONS]

      Create HTML tree visualization with metadata.

      The metadata for reference genomes can be extracted from the specified
      Genbank file.

      Any leaf names that are present in the tree but not present in the Genbank
      file are assumed to be user samples and are flagged as such in the
      metadata table as "user_sample"="Yes".

    Options:
      -n, --newick PATH               Phylogenetic tree Newick file  [required]
      -o, --output-html PATH          Output HTML tree path  [required]
      -N, --output-newick PATH        Output Newick file
      -r, --ref-genomes-genbank PATH  Reference genome sequences Genbank file
      -m, --output-metadata-table PATH
                                      Output metadata table path
      --leaflist PATH                 Optional leaf names to select from
                                      phylogenetic tree for pruned tree
                                      visualization. One leaf name per line.

      --genbank-metadata-fields PATH  Optional fields to extract from Genbank
                                      source metadata. One field per line.

      -M, --metadata PATH             Optional tab-delimited metadata for user
                                      samples to join with metadata derived from
                                      reference genome sequences Genbank file.
                                      Sample IDs must be in the first column.

      --metadata-fields-in-order PATH
                                      Optional list of fields in order to output
                                      in metadata table and HTML tree
                                      visualization. One field per line.

      --fix-metadata / --no-fix-metadata
                                      Try to automatically fix metadata from
                                      reference Genbank file.  [default: True]

      -C, --collapse-support FLOAT    Collapse internal branches below specified
                                      bootstrap support value (default -1 for no
                                      collapsing)  [default: -1.0]

      --highlight-user-samples / --no-highlight-user-samples
                                      Highlight user samples with metadata field
                                      in tree.  [default: False]

      --outgroup TEXT                 Tree outgroup taxa
      --midpoint-root / --no-midpoint-root
                                      Set midpoint root  [default: False]
      --verbose / --no-verbose        Verbose logs  [default: False]
      --install-completion            Install completion for the current shell.
      --show-completion               Show completion for the current shell, to
                                      copy it or customize the installation.

      --help                          Show this message and exit.



Credits
-------

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

.. _`fmdv-5-shiptv.html`: docs/data/fmdv-5-shiptv.html
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _PhyloCanvas: http://phylocanvas.org/


=======
History
=======

0.4.1 (2021-05-13)
------------------

* ensure tree rendered even if ``genomeMetadata`` object is empty in ``phylocanvas.html``
* add ``--version`` option to print shiptv version and exit
* add epilog to help with version info
* add example usage to help
* change ``--metadata`` short opt to ``-m`` from ``-M``
* change ``--output-metadata-table`` short opt from ``-m`` to ``-M``
* update lodash JS library to version 4.17.15


0.4.0 (2021-02-12)
------------------

* Add Select2 metadata field select box to show metadata fields in the order required
* Add Shift+Ctrl+F to toggle tree viz full window mode
* Using BioPython's Phylo module for phylogenetic tree manipulation. Removed ete3.
* Using Requests library to get JS and CSS to embed into HTML output
* Migrated to Typer from Click for CLI
* Added Rich for nicer logging and tracebacks
* Changed some options to be optional; only required options are ``-n/--newick`` and ``-o/--output-html``
* By default don't highlight user samples as a field of metadata in tree viz
* Allow user to optionally specify outgroup taxa name
* Allow user to optionally re-root tree at midpoint node
* Fixed warnings from Pandas when modifying view of dataframe by using ``.loc[]``
* Moved to GitHub Actions CI and PyPI deployment


0.3.0 (2019-10-02)
------------------

* Fix rendering of numeric and ISO date metadata fields
* Reference genomes Genbank now optional
* Updated docs


0.2.0 (2019-06-28)
------------------

* Added low support branch highlighting in tree HTML file
* Added option to collapse low support branches (`-C/--collapse-support`)
* Added option to output modified Newick tree file (`-N/--output-newick`)
* Fixed date/time parsing from Genbank files (#1)

0.1.0 (2019-05-10)
------------------

* First release on PyPI.


