phylogenie 3.1.10__py3-none-any.whl → 3.1.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
phylogenie/__init__.py CHANGED
@@ -1,11 +1,3 @@
1
- from phylogenie.draw import (
2
- draw_colored_dated_tree_categorical,
3
- draw_colored_dated_tree_continuous,
4
- draw_colored_tree_categorical,
5
- draw_colored_tree_continuous,
6
- draw_dated_tree,
7
- draw_tree,
8
- )
9
1
  from phylogenie.generators import (
10
2
  AliSimDatasetGenerator,
11
3
  BDEITreeDatasetGenerator,
@@ -71,12 +63,6 @@ from phylogenie.treesimulator import (
71
63
  )
72
64
 
73
65
  __all__ = [
74
- "draw_colored_dated_tree_categorical",
75
- "draw_colored_dated_tree_continuous",
76
- "draw_colored_tree_categorical",
77
- "draw_colored_tree_continuous",
78
- "draw_dated_tree",
79
- "draw_tree",
80
66
  "AliSimDatasetGenerator",
81
67
  "BDEITreeDatasetGenerator",
82
68
  "BDSSTreeDatasetGenerator",
phylogenie/draw.py CHANGED
@@ -1,5 +1,5 @@
1
+ import datetime
1
2
  from dataclasses import dataclass
2
- from datetime import datetime
3
3
  from typing import Any, Literal, overload
4
4
 
5
5
  import matplotlib.colors as mcolors
@@ -21,7 +21,7 @@ from phylogenie.treesimulator import (
21
21
  @dataclass
22
22
  class CalibrationNode:
23
23
  node: Tree
24
- date: datetime
24
+ date: datetime.date
25
25
 
26
26
 
27
27
  Color = str | tuple[float, float, float] | tuple[float, float, float, float]
@@ -115,7 +115,7 @@ def draw_tree(
115
115
 
116
116
  def _depth_to_date(
117
117
  depth: float, calibration_nodes: tuple[CalibrationNode, CalibrationNode]
118
- ) -> datetime:
118
+ ) -> datetime.date:
119
119
  """
120
120
  Convert a depth value to a date using linear interpolation between two calibration nodes.
121
121
 
@@ -128,7 +128,7 @@ def _depth_to_date(
128
128
 
129
129
  Returns
130
130
  -------
131
- datetime
131
+ datetime.date
132
132
  The interpolated date corresponding to the given depth.
133
133
  """
134
134
  node1, node2 = calibration_nodes
@@ -224,7 +224,7 @@ def _init_colored_tree_categorical(
224
224
  color_by: str,
225
225
  ax: Axes | None = None,
226
226
  default_color: Color = "black",
227
- colormap: str | Colormap = "tab20",
227
+ colormap: str | dict[str, Color] | Colormap = "tab20",
228
228
  show_legend: bool = True,
229
229
  labels: dict[Any, str] | None = None,
230
230
  legend_kwargs: dict[str, Any] | None = None,
@@ -242,8 +242,11 @@ def _init_colored_tree_categorical(
242
242
  The matplotlib Axes to draw on. If None, uses the current Axes.
243
243
  default_color : Color, optional
244
244
  The color to use for nodes without the specified metadata.
245
- colormap : str | Colormap, optional
246
- The colormap to use for coloring categories. Defaults to 'tab20'.
245
+ colormap : str | dict[str, Color] | Colormap, optional
246
+ The colormap to use for coloring categories.
247
+ If a string, it is used to get a matplotlib colormap.
248
+ If a dict, it maps category values to colors directly.
249
+ Defaults to 'tab20'.
247
250
  show_legend : bool, optional
248
251
  Whether to display a legend for the categories.
249
252
  labels : dict[Any, str] | None, optional
@@ -259,13 +262,16 @@ def _init_colored_tree_categorical(
259
262
  if ax is None:
260
263
  ax = plt.gca()
261
264
 
265
+ features = {node: node[color_by] for node in tree if color_by in node.metadata}
262
266
  if isinstance(colormap, str):
263
267
  colormap = plt.get_cmap(colormap)
268
+ if isinstance(colormap, Colormap):
269
+ feature_colors = {
270
+ f: mcolors.to_hex(colormap(i)) for i, f in enumerate(set(features.values()))
271
+ }
272
+ else:
273
+ feature_colors = colormap
264
274
 
265
- features = {node: node[color_by] for node in tree if color_by in node.metadata}
266
- feature_colors = {
267
- f: mcolors.to_hex(colormap(i)) for i, f in enumerate(set(features.values()))
268
- }
269
275
  colors = {
270
276
  node: feature_colors[features[node]] if node in features else default_color
271
277
  for node in tree
@@ -294,7 +300,7 @@ def draw_colored_tree_categorical(
294
300
  ax: Axes | None = None,
295
301
  backward_time: bool = False,
296
302
  default_color: Color = "black",
297
- colormap: str | Colormap = "tab20",
303
+ colormap: str | dict[str, Color] | Colormap = "tab20",
298
304
  show_legend: bool = True,
299
305
  labels: dict[Any, str] | None = None,
300
306
  legend_kwargs: dict[str, Any] | None = None,
@@ -316,8 +322,11 @@ def draw_colored_tree_categorical(
316
322
  If True, the x-axis is inverted to represent time going backward.
317
323
  default_color : Color, optional
318
324
  The color to use for nodes without the specified metadata.
319
- colormap : str | Colormap, optional
320
- The colormap to use for coloring categories. Defaults to 'tab20'.
325
+ colormap : str | dict[str, Color] | Colormap, optional
326
+ The colormap to use for coloring categories.
327
+ If a string, it is used to get a matplotlib colormap.
328
+ If a dict, it maps category values to colors directly.
329
+ Defaults to 'tab20'.
321
330
  show_legend : bool, optional
322
331
  Whether to display a legend for the categories.
323
332
  labels : dict[Any, str] | None, optional
@@ -360,7 +369,7 @@ def draw_colored_dated_tree_categorical(
360
369
  color_by: str,
361
370
  ax: Axes | None = None,
362
371
  default_color: Color = "black",
363
- colormap: str | Colormap = "tab20",
372
+ colormap: str | dict[str, Color] | Colormap = "tab20",
364
373
  show_legend: bool = True,
365
374
  labels: dict[Any, str] | None = None,
366
375
  legend_kwargs: dict[str, Any] | None = None,
@@ -381,8 +390,11 @@ def draw_colored_dated_tree_categorical(
381
390
  The matplotlib Axes to draw on. If None, uses the current Axes.
382
391
  default_color : Color, optional
383
392
  The color to use for nodes without the specified metadata.
384
- colormap : str | Colormap, optional
385
- The colormap to use for coloring categories. Defaults to 'tab20'.
393
+ colormap : str | dict[str, Color] | Colormap, optional
394
+ The colormap to use for coloring categories.
395
+ If a string, it is used to get a matplotlib colormap.
396
+ If a dict, it maps category values to colors directly.
397
+ Defaults to 'tab20'.
386
398
  show_legend : bool, optional
387
399
  Whether to display a legend for the categories.
388
400
  labels : dict[Any, str] | None, optional
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phylogenie
3
- Version: 3.1.10
3
+ Version: 3.1.13
4
4
  Summary: Generate phylogenetic datasets with minimal setup effort
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -23,7 +23,6 @@ Dynamic: license-file
23
23
  [![PyPI version](https://img.shields.io/pypi/v/phylogenie)](https://pypi.org/project/phylogenie/)
24
24
  ![Downloads](https://img.shields.io/pypi/dm/phylogenie)
25
25
 
26
-
27
26
  Phylogenie is a [Python](https://www.python.org/) package designed to easily simulate phylogenetic datasets—such as trees and multiple sequence alignments (MSAs)—with minimal setup effort. Simply specify the distributions from which your parameters should be sampled, and Phylogenie will handle the rest!
28
27
 
29
28
  ## ✨ Features
@@ -73,21 +72,21 @@ Phylogenie relies on [AliSim](https://iqtree.github.io/doc/AliSim) for simulatin
73
72
 
74
73
  ## 🚀 Quick Start
75
74
 
76
- Once you have installed Phylogenie, check out the [examples](https://github.com/gabriele-marino/phylogenie/tree/main/examples) folder.
75
+ Once you have installed Phylogenie, check out the [tutorials](https://github.com/gabriele-marino/phylogenie/tree/main/tutorials) folder.
77
76
  It includes a collection of thoroughly commented configuration files, organized as a step-by-step tutorial. These examples will help you understand how to use Phylogenie in practice and can be easily adapted to fit your own workflow.
78
77
 
79
78
  For quick start, pick your favorite config file and run Phylogenie with:
80
79
  ```bash
81
- phylogenie examples/config_file.yaml
80
+ phylogenie tutorials/config_file.yaml
82
81
  ```
83
82
  This command will create the output dataset in the folder specified inside the configuration file, including data directories and metadata files for each dataset split defined in the config.
84
83
 
85
84
  >❗ *Tip*: Can’t choose just one config file?
86
- You can run them all at once by pointing Phylogenie to the folder! Just use: `phylogenie examples`. In this mode, Phylogenie will automatically find all `.yaml` files in the folder you specified and run for each of them!
85
+ You can run them all at once by pointing Phylogenie to the folder! Just use: `phylogenie tutorials`. In this mode, Phylogenie will automatically find all `.yaml` files in the folder you specified and run for each of them!
87
86
 
88
87
  ## 📖 Documentation
89
88
 
90
- - The [examples](https://github.com/gabriele-marino/phylogenie/tree/main/examples) folder contains many ready-to-use, extensively commented configuration files that serve as a step-by-step tutorial to guide you through using Phylogenie. You can explore them to learn how it works or adapt them directly to your own workflows.
89
+ - The [tutorials](https://github.com/gabriele-marino/phylogenie/tree/main/tutorials) folder contains many ready-to-use, extensively commented configuration files that serve as a step-by-step tutorial to guide you through using Phylogenie. You can explore them to learn how it works or adapt them directly to your own workflows.
91
90
  - A complete user guide and API reference are under development. In the meantime, feel free to [reach out](mailto:gabmarino.8601@email.com) if you have any questions about integrating Phylogenie into your workflows.
92
91
 
93
92
  ## 📄 License
@@ -1,5 +1,5 @@
1
- phylogenie/__init__.py,sha256=redo-SdvWwQPlyqOfdSW0TkkZf-aP98kLRCUIg4pB8c,3304
2
- phylogenie/draw.py,sha256=ZZvOQrmW_X9wUiOl5h2nvNBVX7BFH014EJ7evEI2orA,26840
1
+ phylogenie/__init__.py,sha256=RyH_mcEXcKtELTkl9HRzWcl2ANWN-G4K0BLigqR3_B4,2888
2
+ phylogenie/draw.py,sha256=z0f5g8t54DST-AxvFyNYREqpj41IhSIAjHIdrtVRH08,27449
3
3
  phylogenie/main.py,sha256=ry3B3HiwibZG3_qB58T5UhWy5dp6neYUtSqzL9LrSkA,1698
4
4
  phylogenie/mixins.py,sha256=wMwqP6zkqME9eMyzx5FS6-p9X8yW09jIC8jge8pHlkk,907
5
5
  phylogenie/msa.py,sha256=RGXxmo1WX9wi5NpEQTxMuH4zk8vM0f8A7Knm0YUJ9AI,2111
@@ -33,9 +33,9 @@ phylogenie/treesimulator/events/mutations.py,sha256=8Nqa2fg7fwaVNe5XSkGDSwp9pIKQ
33
33
  phylogenie/treesimulator/io/__init__.py,sha256=rfP-zp8SP8baq5_4dPAr10WH0W6KfoMCxdTZDCSXtzE,185
34
34
  phylogenie/treesimulator/io/newick.py,sha256=8Pr_jixByPOaVch18w-rFt62HYy0U97YMu0H-QSwIy0,3449
35
35
  phylogenie/treesimulator/io/nexus.py,sha256=zqT9dzj413z_s0hqp3Cdq5NMO6lv-zuuaJlaqzaqaB8,1847
36
- phylogenie-3.1.10.dist-info/licenses/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
37
- phylogenie-3.1.10.dist-info/METADATA,sha256=sdHbD8Gx14dS0TkKkN9dpmZkTKgt0ib__qtTX2noIo0,5195
38
- phylogenie-3.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
39
- phylogenie-3.1.10.dist-info/entry_points.txt,sha256=BBH8LoReHnNFnvq4sROEsVFegfkKJ6c_oHZ7bgK7Jl4,52
40
- phylogenie-3.1.10.dist-info/top_level.txt,sha256=1YGZJhKA9tN9qI0Hcj6Cn_sOoDpba0HQlNcgQTjMD-8,11
41
- phylogenie-3.1.10.dist-info/RECORD,,
36
+ phylogenie-3.1.13.dist-info/licenses/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
37
+ phylogenie-3.1.13.dist-info/METADATA,sha256=k0zK6rE7YTrt5ulq4i8doSKb-TH5GqoGdKmFt-Zam8c,5200
38
+ phylogenie-3.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
39
+ phylogenie-3.1.13.dist-info/entry_points.txt,sha256=BBH8LoReHnNFnvq4sROEsVFegfkKJ6c_oHZ7bgK7Jl4,52
40
+ phylogenie-3.1.13.dist-info/top_level.txt,sha256=1YGZJhKA9tN9qI0Hcj6Cn_sOoDpba0HQlNcgQTjMD-8,11
41
+ phylogenie-3.1.13.dist-info/RECORD,,