# -*- coding: utf-8 -*-
from setuptools import setup

package_dir = \
{'': 'src'}

packages = \
['pygenomeviz']

package_data = \
{'': ['*']}

install_requires = \
['biopython>=1.79,<2.0', 'matplotlib>=3.5.2,<4.0.0', 'numpy>=1.21,<2.0']

setup_kwargs = {
    'name': 'pygenomeviz',
    'version': '0.0.9',
    'description': 'A genome visualization python package for comparative genomics',
    'long_description': '# pyGenomeViz\n\n![Python3](https://img.shields.io/badge/Language-Python3-steelblue)\n![OS](https://img.shields.io/badge/OS-_Windows_|_Mac_|_Linux-steelblue)\n![License](https://img.shields.io/badge/License-MIT-steelblue)\n[![Latest PyPI version](https://img.shields.io/pypi/v/pygenomeviz.svg)](https://pypi.python.org/pypi/pygenomeviz)\n[![Bioconda](https://img.shields.io/conda/vn/bioconda/pygenomeviz.svg?color=green)](https://anaconda.org/bioconda/pygenomeviz)\n[![CI](https://github.com/moshi4/pyGenomeViz/actions/workflows/ci.yml/badge.svg)](https://github.com/moshi4/pyGenomeViz/actions/workflows/ci.yml)\n\n## Overview\n\npyGenomeViz is a genome visualization python package for comparative genomics implemented in matplotlib.\nThis package is developed for the purpose of easily and beautifully plotting genomic\nfeatures and sequence similarity comparison links between multiple genomes.\nIt supports genome visualization of Genbank format file and can be saved figure in various formats (JPG/PNG/SVG/PDF).\nUser can use pyGenomeViz for interactive genome visualization figure plotting on jupyter notebook,\nor automatic genome visualization figure plotting in genome analysis scripts/pipelines.\n\nFor more information, please see full documentation [here](https://moshi4.github.io/pyGenomeViz/).\n\n![example05.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example05.png)  \n**Fig.1 Four *Erwinia phage* genome comparison result**\n\n![example06.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example06.png)  \n**Fig.2 Six *Enterobacteria phage* genome comparison result**\n\n## Installation\n\n`Python 3.7 or later` is required for installation.\n\n**Install PyPI package:**\n\n    pip install pygenomeviz\n\n**Install bioconda package:**\n\n    conda install -c conda-forge -c bioconda pygenomeviz\n\n## Examples\n\nJupyter notebooks containing code examples below is available [here](https://moshi4.github.io/pyGenomeViz/examples/basic_example/).\n\n### Basic Example\n\n#### Single Genome Track\n\n```python\nfrom pygenomeviz import GenomeViz\n\nname, genome_size = "Tutorial 01", 5000\ncds_list = ((100, 900, -1), (1100, 1300, 1), (1350, 1500, 1), (1520, 1700, 1), (1900, 2200, -1), (2500, 2700, 1), (2700, 2800, -1), (2850, 3000, -1), (3100, 3500, 1), (3600, 3800, -1), (3900, 4200, -1), (4300, 4700, -1), (4800, 4850, 1))\n\ngv = GenomeViz()\ntrack = gv.add_feature_track(name, genome_size)\nfor idx, cds in enumerate(cds_list, 1):\n    start, end, strand = cds\n    track.add_feature(start, end, strand, label=f"CDS{idx:02d}")\n\ngv.savefig("example01.png")\n```\n\n![example01.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example01.png)\n\n#### Multiple Genome Tracks & Links\n\n```python\nfrom pygenomeviz import GenomeViz\n\ngenome_list = (\n    {"name": "genome 01", "size": 1000, "cds_list": ((150, 300, 1), (500, 700, -1), (750, 950, 1))},\n    {"name": "genome 02", "size": 1300, "cds_list": ((50, 200, 1), (350, 450, 1), (700, 900, -1), (950, 1150, -1))},\n    {"name": "genome 03", "size": 1200, "cds_list": ((150, 300, 1), (350, 450, -1), (500, 700, -1), (701, 900, -1))},\n)\n\ngv = GenomeViz(tick_style="axis")\nfor genome in genome_list:\n    name, size, cds_list = genome["name"], genome["size"], genome["cds_list"]\n    track = gv.add_feature_track(name, size)\n    for idx, cds in enumerate(cds_list, 1):\n        start, end, strand = cds\n        track.add_feature(start, end, strand, label=f"gene{idx:02d}", linewidth=1, labelrotation=0, labelvpos="top", labelhpos="center", labelha="center")\n\n# Add links between "genome 01" and "genome 02"\ngv.add_link(("genome 01", 150, 300), ("genome 02", 50, 200))\ngv.add_link(("genome 01", 700, 500), ("genome 02", 900, 700))\ngv.add_link(("genome 01", 750, 950), ("genome 02", 1150, 950))\n# Add links between "genome 02" and "genome 03"\ngv.add_link(("genome 02", 50, 200), ("genome 03", 150, 300), normal_color="skyblue", inverted_color="lime", curve=True)\ngv.add_link(("genome 02", 350, 450), ("genome 03", 450, 350), normal_color="skyblue", inverted_color="lime", curve=True)\ngv.add_link(("genome 02", 900, 700), ("genome 03", 700, 500), normal_color="skyblue", inverted_color="lime", curve=True)\ngv.add_link(("genome 03", 900, 701), ("genome 02", 1150, 950), normal_color="skyblue", inverted_color="lime", curve=True)\n\ngv.savefig("example02.png")\n```\n\n![example02.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example02.png)\n\n### Practical Example\n\n#### Single Genome Track from Genbank file\n\n```python\nfrom pygenomeviz import Genbank, GenomeViz, load_dataset\n\ngbk_files, _ = load_dataset("enterobacteria_phage")\ngbk = Genbank(gbk_files[0])\n\ngv = GenomeViz()\ntrack = gv.add_feature_track(gbk.name, gbk.genome_length)\ntrack.add_genbank_features(gbk)\n\ngv.savefig("example03.png")\n```\n\n![example03.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example03.png)\n\n#### Multiple Genome Tracks & Links from Genbank files\n\n```python\nfrom pygenomeviz import Genbank, GenomeViz, load_dataset\n\ngv = GenomeViz(\n    fig_track_height=0.7,\n    feature_track_ratio=0.2,\n    tick_track_ratio=0.7,\n    tick_style="bar",\n    align_type="center",\n)\n\ngbk_files, links = load_dataset("escherichia_phage")\nfor gbk_file in gbk_files:\n    gbk = Genbank(gbk_file)\n    track = gv.add_feature_track(gbk.name, gbk.genome_length)\n    track.add_genbank_features(gbk, facecolor="limegreen", linewidth=0.5, arrow_shaft_ratio=1.0)\n\nfor link in links:\n    link_data1 = (link.ref_name, link.ref_start, link.ref_end)\n    link_data2 = (link.query_name, link.query_start, link.query_end)\n    gv.add_link(link_data1, link_data2, v=link.identity, curve=True)\n\ngv.savefig("example04.png")\n```\n\n![example04.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example04.png)\n\n### Customization Tips\n\nSince pyGenomeViz is implemented based on matplotlib, users can easily customize\nthe figure in the manner of matplotlib. Here are some tips for figure customization.\n\n#### Customization Tips 01\n\n- Add `GC Content` & `GC skew` subtrack\n- Add annotation label & fillbox\n- Add colorbar for links identity\n\n<details>\n<summary>Code</summary>\n\n```python\nfrom pygenomeviz import Genbank, GenomeViz, load_dataset\n\ngv = GenomeViz(\n    fig_width=12,\n    fig_track_height=0.7,\n    feature_track_ratio=0.5,\n    tick_track_ratio=0.3,\n    tick_style="axis",\n)\n\ngbk_files, links = load_dataset("erwinia_phage")\ngbk_list = [Genbank(gbk_file) for gbk_file in gbk_files]\nfor gbk in gbk_list:\n    track = gv.add_feature_track(gbk.name, gbk.genome_length)\n    track.add_genbank_features(gbk, plotstyle="arrow")\n\nmin_identity = int(min(link.identity for link in links))\nfor link in links:\n    link_data1 = (link.ref_name, link.ref_start, link.ref_end)\n    link_data2 = (link.query_name, link.query_start, link.query_end)\n    gv.add_link(link_data1, link_data2, v=link.identity, vmin=min_identity)\n\n# Add subtracks to top track for plotting \'GC content\' & \'GC skew\'\ngv.add_feature_subtrack(gv.top_track.name, "gc_content", ratio=0.7)\ngv.add_feature_subtrack(gv.top_track.name, "gc_skew", ratio=0.7)\n\nfig = gv.plotfig()\n\n# Add label annotation to top track\ntop_track = gv.top_track  # or, gv.get_track("MT939486") or gv.get_tracks()[0]\nlabel, start, end = "Inverted", 310000 + top_track.offset, 358000 + top_track.offset\ncenter = int((start + end) / 2)\ntop_track.ax.hlines(1.5, start, end, colors="red", linewidth=1, linestyles="dashed", clip_on=False)\ntop_track.ax.text(center, 2.0, label, fontsize=12, color="red", ha="center", va="bottom")\n\n# Add fillbox to top track\nx, y = (start, start, end, end), (1, -1, -1, 1)\ntop_track.ax.fill(x, y, fc="lime", linewidth=0, alpha=0.1, zorder=-10)\n\n# Plot GC content for top track\ngc_content_ax = gv.top_track.subtracks[0].ax  # or, gv.get_track("gc_content").ax\npos_list, gc_content_list = gbk_list[0].calc_gc_content()\ngc_content_ax.set_ylim(bottom=0, top=max(gc_content_list))\npos_list += gv.top_track.offset  # Offset is required if align_type is not \'left\'\ngc_content_ax.fill_between(pos_list, gc_content_list, alpha=0.2, color="blue")\ngc_content_ax.text(gv.top_track.offset, max(gc_content_list) / 2, "GC(%) ", ha="right", va="center", color="blue")\n\n# Plot GC skew for top track\ngc_skew_ax = gv.top_track.subtracks[1].ax  # or, gv.get_track("gc_skew").ax\npos_list, gc_skew_list = gbk_list[0].calc_gc_skew()\ngc_skew_abs_max = max(abs(gc_skew_list))\ngc_skew_ax.set_ylim(bottom=-gc_skew_abs_max, top=gc_skew_abs_max)\npos_list += gv.top_track.offset  # Offset is required if align_type is not \'left\'\ngc_skew_ax.fill_between(pos_list, gc_skew_list, alpha=0.2, color="red")\ngc_skew_ax.text(gv.top_track.offset, 0, "GC skew ", ha="right", va="center", color="red")\n\n# Set coloarbar for link\ngv.set_colorbar(fig, vmin=min_identity)\n\nfig.savefig("example05.png", bbox_inches="tight")\n```\n\n</details>\n\n![example05.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example05.png)\n\n#### Customization Tips 02\n\n- Add legends\n- Add colorbar for links identity\n\n<details>\n<summary>Code</summary>\n\n```python\nfrom matplotlib.lines import Line2D\nfrom matplotlib.patches import Patch\n\nfrom pygenomeviz import Genbank, GenomeViz, load_dataset\n\ngv = GenomeViz(\n    fig_width=10,\n    fig_track_height=0.7,\n    feature_track_ratio=0.5,\n    tick_track_ratio=0.5,\n    align_type="center",\n    tick_style="bar",\n    tick_labelsize=10,\n)\n\ngbk_files, links = load_dataset("enterobacteria_phage")\nfor idx, gbk_file in enumerate(gbk_files):\n    gbk = Genbank(gbk_file)\n    track = gv.add_feature_track(gbk.name, gbk.genome_length, labelsize=10)\n    track.add_genbank_features(\n        gbk,\n        label_type="product" if idx == 0 else None,  # Labeling only top track\n        label_filter=["hypothetical"],  # Ignore \'hypothetical ~~~\' label\n        labelsize=8,\n        labelvpos="top",\n        facecolor="skyblue",\n        linewidth=0.5,\n    )\n\nnormal_color, inverted_color, alpha = "chocolate", "limegreen", 0.5\nmin_identity = int(min(link.identity for link in links))\nfor link in links:\n    link_data1 = (link.ref_name, link.ref_start, link.ref_end)\n    link_data2 = (link.query_name, link.query_start, link.query_end)\n    gv.add_link(link_data1, link_data2, normal_color, inverted_color, alpha, v=link.identity, vmin=min_identity, curve=True)\n\nfig = gv.plotfig()\n\n# Add Legends (Maybe there is a better way)\nhandles = [\n    Line2D([], [], marker=">", color="skyblue", label="CDS", ms=10, ls="none"),\n    Patch(color=normal_color, label="Normal Link"),\n    Patch(color=inverted_color, label="Inverted Link"),\n]\nfig.legend(handles=handles, frameon=True, bbox_to_anchor=(1, 0.8), loc="upper left", ncol=1, handlelength=1, handleheight=1)\n\n# Set colorbar for link\ngv.set_colorbar(fig, bar_colors=[normal_color, inverted_color], alpha=alpha, vmin=min_identity, bar_height=0.15, bar_label="Identity", bar_labelsize=10)\n\nfig.savefig("example06.png", bbox_inches="tight")\n```\n\n</details>\n\n![example06.png](https://raw.githubusercontent.com/moshi4/pyGenomeViz/main/docs/images/example06.png)\n',
    'author': 'moshi4',
    'author_email': None,
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/moshi4/pyGenomeViz/',
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.7.1,<4.0.0',
}


setup(**setup_kwargs)
