phykit 2.2.0__tar.gz → 2.3.0__tar.gz
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.
- {phykit-2.2.0 → phykit-2.3.0}/PKG-INFO +1 -1
- {phykit-2.2.0 → phykit-2.3.0}/phykit/cli_registry.py +4 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/parsimony_utils.py +145 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/phykit.py +144 -3
- {phykit-2.2.0 → phykit-2.3.0}/phykit/service_factories.py +1 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/__init__.py +1 -0
- phykit-2.3.0/phykit/services/alignment/codon_dnds.py +400 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/character_map.py +172 -29
- phykit-2.3.0/phykit/version.py +1 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit.egg-info/PKG-INFO +1 -1
- {phykit-2.2.0 → phykit-2.3.0}/phykit.egg-info/SOURCES.txt +1 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit.egg-info/entry_points.txt +4 -0
- phykit-2.2.0/phykit/version.py +0 -1
- {phykit-2.2.0 → phykit-2.3.0}/LICENSE.md +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/README.md +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/__init__.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/__main__.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/errors.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/__init__.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/boolean_argument_parsing.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/caching.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/circular_layout.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/color_annotations.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/discrete_models.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/files.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/geological_timescale.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/json_output.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/parallel.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/pgls_utils.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/plot_config.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/quartet_utils.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/stats_summary.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/streaming.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/trait_parsing.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/helpers/tree_paths.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/__init__.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/_fasta.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/alignment_entropy.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/alignment_length.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/alignment_length_no_gaps.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/alignment_outlier_taxa.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/alignment_recoding.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/alignment_subsample.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/base.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/column_score.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/composition_per_taxon.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/compositional_bias_per_site.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/create_concatenation_matrix.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/dfoil.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/dna_threader.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/dstatistic.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/evolutionary_rate_per_site.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/faidx.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/gc_content.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/identity_matrix.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/mask_alignment.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/occupancy_filter.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/occupancy_per_taxon.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/pairwise_identity.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/parsimony_informative_sites.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/phylo_gwas.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/plot_alignment_qc.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/rcv.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/rcvt.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/rename_fasta_entries.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/sum_of_pairs_score.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/taxon_groups.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/alignment/variable_sites.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/base.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/__init__.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/ancestral_reconstruction.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/base.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/bipartition_support_stats.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/branch_length_multiplier.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/chronogram.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/collapse_branches.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/concordance_asr.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/consensus_network.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/consensus_tree.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/cont_map.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/cophylo.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/covarying_evolutionary_rates.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/density_map.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/discordance_asymmetry.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/dtt.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/dvmc.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/evo_tempo_map.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/evolutionary_rate.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/faiths_pd.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/fit_continuous.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/fit_discrete.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/hidden_paralogy_check.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/hybridization.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/independent_contrasts.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/internal_branch_stats.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/internode_labeler.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/kf_distance.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/last_common_ancestor_subtree.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/lb_score.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/ltt.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/monophyly_check.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/nearest_neighbor_interchange.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/neighbor_net.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/network_signal.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/ou_shift_detection.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/ouwie.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/parsimony_score.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/patristic_distances.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phenogram.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylo_anova.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylo_heatmap.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylo_impute.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylo_logistic.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylo_path.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylogenetic_glm.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylogenetic_ordination.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylogenetic_regression.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylogenetic_signal.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/phylomorphospace.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/polytomy_test.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/print_tree.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/prune_tree.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/quartet_network.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/quartet_pie.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/rate_heterogeneity.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/relative_rate_test.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/rename_tree_tips.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/rf_distance.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/root_tree.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/saturation.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/simmap_summary.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/spectral_discordance.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/spr.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/spurious_sequence.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/stochastic_character_map.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/terminal_branch_stats.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/threshold_model.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/tip_labels.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/tip_to_tip_distance.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/tip_to_tip_node_distance.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/total_tree_length.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/trait_correlation.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/trait_rate_map.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/transfer_annotations.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/tree_space.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/treeness.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/treeness_over_rcv.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit/services/tree/vcv_utils.py +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit.egg-info/dependency_links.txt +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit.egg-info/requires.txt +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/phykit.egg-info/top_level.txt +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/setup.cfg +0 -0
- {phykit-2.2.0 → phykit-2.3.0}/setup.py +0 -0
|
@@ -46,6 +46,10 @@ ALIAS_TO_HANDLER: dict[str, str] = {
|
|
|
46
46
|
"seqid": "identity_matrix",
|
|
47
47
|
"comp_taxon": "composition_per_taxon",
|
|
48
48
|
"comp_tax": "composition_per_taxon",
|
|
49
|
+
"codon_dnds": "codon_dnds",
|
|
50
|
+
"dnds": "codon_dnds",
|
|
51
|
+
"dn_ds": "codon_dnds",
|
|
52
|
+
"kaks": "codon_dnds",
|
|
49
53
|
"pis": "parsimony_informative_sites",
|
|
50
54
|
"rel_comp_var": "rcv",
|
|
51
55
|
"relative_composition_variability": "rcv",
|
|
@@ -480,6 +480,151 @@ def _mask_to_state_set(states: tuple[str, ...], mask: int):
|
|
|
480
480
|
)
|
|
481
481
|
|
|
482
482
|
|
|
483
|
+
def sankoff_downpass(
|
|
484
|
+
tree,
|
|
485
|
+
tip_states: dict[str, list[str]],
|
|
486
|
+
) -> tuple[
|
|
487
|
+
dict[int, list[tuple[int, ...]]],
|
|
488
|
+
list[tuple[str, ...]],
|
|
489
|
+
list[int],
|
|
490
|
+
]:
|
|
491
|
+
"""Calculate exact unordered-parsimony costs on any tree topology.
|
|
492
|
+
|
|
493
|
+
Unlike the optimized Fitch path, this dynamic program handles nodes with
|
|
494
|
+
any number of children without introducing arbitrary binary resolutions.
|
|
495
|
+
Missing states (``?`` and ``-``) are compatible with every observed state.
|
|
496
|
+
"""
|
|
497
|
+
n_chars = len(next(iter(tip_states.values())))
|
|
498
|
+
wildcard = {"?", "-"}
|
|
499
|
+
observed_states = [set() for _ in range(n_chars)]
|
|
500
|
+
for states in tip_states.values():
|
|
501
|
+
for index, state in enumerate(states):
|
|
502
|
+
if state not in wildcard:
|
|
503
|
+
observed_states[index].add(state)
|
|
504
|
+
|
|
505
|
+
states_by_char = [
|
|
506
|
+
tuple(sorted(states)) if states else ("?",)
|
|
507
|
+
for states in observed_states
|
|
508
|
+
]
|
|
509
|
+
state_indexes = [
|
|
510
|
+
{state: index for index, state in enumerate(states)}
|
|
511
|
+
for states in states_by_char
|
|
512
|
+
]
|
|
513
|
+
|
|
514
|
+
clades = _postorder_clades_direct(tree)
|
|
515
|
+
if clades is None:
|
|
516
|
+
clades = list(tree.find_clades(order="postorder"))
|
|
517
|
+
unreachable = len(clades) + 1
|
|
518
|
+
node_costs: dict[int, list[tuple[int, ...]]] = {}
|
|
519
|
+
|
|
520
|
+
for clade in clades:
|
|
521
|
+
cid = id(clade)
|
|
522
|
+
children = clade.clades
|
|
523
|
+
if not children:
|
|
524
|
+
costs_by_char = []
|
|
525
|
+
for index, state in enumerate(tip_states[clade.name]):
|
|
526
|
+
state_count = len(states_by_char[index])
|
|
527
|
+
if state in wildcard:
|
|
528
|
+
costs_by_char.append((0,) * state_count)
|
|
529
|
+
continue
|
|
530
|
+
|
|
531
|
+
observed_index = state_indexes[index][state]
|
|
532
|
+
costs_by_char.append(
|
|
533
|
+
tuple(
|
|
534
|
+
0 if candidate == observed_index else unreachable
|
|
535
|
+
for candidate in range(state_count)
|
|
536
|
+
)
|
|
537
|
+
)
|
|
538
|
+
node_costs[cid] = costs_by_char
|
|
539
|
+
continue
|
|
540
|
+
|
|
541
|
+
child_costs = [node_costs[id(child)] for child in children]
|
|
542
|
+
costs_by_char = []
|
|
543
|
+
for char_index, states in enumerate(states_by_char):
|
|
544
|
+
state_count = len(states)
|
|
545
|
+
parent_costs = []
|
|
546
|
+
for parent_index in range(state_count):
|
|
547
|
+
total = 0
|
|
548
|
+
for child in child_costs:
|
|
549
|
+
child_char_costs = child[char_index]
|
|
550
|
+
total += min(
|
|
551
|
+
cost + (child_index != parent_index)
|
|
552
|
+
for child_index, cost in enumerate(child_char_costs)
|
|
553
|
+
)
|
|
554
|
+
parent_costs.append(total)
|
|
555
|
+
costs_by_char.append(tuple(parent_costs))
|
|
556
|
+
node_costs[cid] = costs_by_char
|
|
557
|
+
|
|
558
|
+
root_costs = node_costs[id(tree.root)]
|
|
559
|
+
scores = [min(costs) for costs in root_costs]
|
|
560
|
+
return node_costs, states_by_char, scores
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
def sankoff_uppass(
|
|
564
|
+
tree,
|
|
565
|
+
node_costs: dict[int, list[tuple[int, ...]]],
|
|
566
|
+
states_by_char: list[tuple[str, ...]],
|
|
567
|
+
parent_map: dict[int, object],
|
|
568
|
+
optimization: str = "acctran",
|
|
569
|
+
) -> dict[int, list[str]]:
|
|
570
|
+
"""Trace back one deterministic, globally optimal reconstruction.
|
|
571
|
+
|
|
572
|
+
DELTRAN prefers inheriting the parent state when a tie permits delaying a
|
|
573
|
+
change. ACCTRAN prefers a different child state when a tie permits moving
|
|
574
|
+
that change toward the root. Root ties use lexical state order for stable
|
|
575
|
+
output independent of child order.
|
|
576
|
+
"""
|
|
577
|
+
node_states: dict[int, list[str]] = {}
|
|
578
|
+
root = tree.root
|
|
579
|
+
root_costs = node_costs[id(root)]
|
|
580
|
+
node_states[id(root)] = [
|
|
581
|
+
states[min_costs.index(min(min_costs))]
|
|
582
|
+
for states, min_costs in zip(states_by_char, root_costs)
|
|
583
|
+
]
|
|
584
|
+
|
|
585
|
+
clades = _preorder_clades_direct(tree)
|
|
586
|
+
if clades is None:
|
|
587
|
+
clades = list(tree.find_clades(order="preorder"))
|
|
588
|
+
|
|
589
|
+
delay_changes = optimization == "deltran"
|
|
590
|
+
for clade in clades:
|
|
591
|
+
if clade == root:
|
|
592
|
+
continue
|
|
593
|
+
|
|
594
|
+
cid = id(clade)
|
|
595
|
+
parent_states = node_states[id(parent_map[cid])]
|
|
596
|
+
costs_by_char = node_costs[cid]
|
|
597
|
+
assigned = []
|
|
598
|
+
for states, costs, parent_state in zip(
|
|
599
|
+
states_by_char,
|
|
600
|
+
costs_by_char,
|
|
601
|
+
parent_states,
|
|
602
|
+
):
|
|
603
|
+
transition_costs = [
|
|
604
|
+
cost + (state != parent_state)
|
|
605
|
+
for state, cost in zip(states, costs)
|
|
606
|
+
]
|
|
607
|
+
best_cost = min(transition_costs)
|
|
608
|
+
candidates = [
|
|
609
|
+
state
|
|
610
|
+
for state, cost in zip(states, transition_costs)
|
|
611
|
+
if cost == best_cost
|
|
612
|
+
]
|
|
613
|
+
if delay_changes and parent_state in candidates:
|
|
614
|
+
assigned.append(parent_state)
|
|
615
|
+
continue
|
|
616
|
+
|
|
617
|
+
changed_candidates = [
|
|
618
|
+
state for state in candidates if state != parent_state
|
|
619
|
+
]
|
|
620
|
+
assigned.append(
|
|
621
|
+
changed_candidates[0] if changed_candidates else candidates[0]
|
|
622
|
+
)
|
|
623
|
+
node_states[cid] = assigned
|
|
624
|
+
|
|
625
|
+
return node_states
|
|
626
|
+
|
|
627
|
+
|
|
483
628
|
def fitch_uppass_acctran(
|
|
484
629
|
tree,
|
|
485
630
|
node_state_sets: dict[int, list[set[str]]],
|
|
@@ -546,6 +546,9 @@ class Phykit:
|
|
|
546
546
|
- detects site-wise compositional biases in an alignment
|
|
547
547
|
composition_per_taxon (alias: comp_taxon; comp_tax)
|
|
548
548
|
- calculates sequence composition per taxon
|
|
549
|
+
codon_dnds (alias: dnds; dn_ds; kaks)
|
|
550
|
+
- estimate pairwise nonsynonymous and synonymous
|
|
551
|
+
substitution rates from a codon alignment
|
|
549
552
|
create_concatenation_matrix (alias: create_concat; cc)
|
|
550
553
|
- create concatenation matrix from a set of alignments
|
|
551
554
|
evolutionary_rate_per_site (alias: evo_rate_per_site; erps)
|
|
@@ -1994,6 +1997,111 @@ class Phykit:
|
|
|
1994
1997
|
_add_json_argument(parser)
|
|
1995
1998
|
_run_service(parser, argv, PairwiseIdentity)
|
|
1996
1999
|
|
|
2000
|
+
@staticmethod
|
|
2001
|
+
def codon_dnds(argv):
|
|
2002
|
+
parser = _new_parser(
|
|
2003
|
+
description=_dedent(
|
|
2004
|
+
f"""\
|
|
2005
|
+
{help_header}
|
|
2006
|
+
|
|
2007
|
+
Estimate pairwise nonsynonymous substitutions per
|
|
2008
|
+
nonsynonymous site (dN), synonymous substitutions per
|
|
2009
|
+
synonymous site (dS), and omega (dN/dS) from an
|
|
2010
|
+
in-frame codon alignment.
|
|
2011
|
+
|
|
2012
|
+
Available estimators are Nei-Gojobori 1986 (NG86),
|
|
2013
|
+
Li-Wu-Luo 1985 (LWL85), Yang-Nielsen 2000 (YN00),
|
|
2014
|
+
and Goldman-Yang 1994 maximum likelihood (ML). NG86
|
|
2015
|
+
is the default. ML can be substantially slower for
|
|
2016
|
+
alignments containing many taxa.
|
|
2017
|
+
|
|
2018
|
+
Alignment length must be divisible by three. Gaps
|
|
2019
|
+
must occupy complete codons (---). Codons containing
|
|
2020
|
+
gaps or ambiguous bases are excluded independently
|
|
2021
|
+
for each sequence pair. Terminal stop codons are
|
|
2022
|
+
excluded. Internal stops fail by default.
|
|
2023
|
+
|
|
2024
|
+
Summary statistics are printed by default. Use
|
|
2025
|
+
--verbose to print one TSV row per pair. Omega is a
|
|
2026
|
+
descriptive pairwise estimate; this command does not
|
|
2027
|
+
perform a branch- or site-selection significance test.
|
|
2028
|
+
|
|
2029
|
+
Aliases:
|
|
2030
|
+
codon_dnds, dnds, dn_ds, kaks
|
|
2031
|
+
Command line interfaces:
|
|
2032
|
+
pk_codon_dnds, pk_dnds, pk_dn_ds, pk_kaks
|
|
2033
|
+
|
|
2034
|
+
Usage:
|
|
2035
|
+
phykit codon_dnds <alignment>
|
|
2036
|
+
[--method NG86|LWL85|YN00|ML]
|
|
2037
|
+
[--genetic-code <int>] [--kappa <float>]
|
|
2038
|
+
[--codon-frequency F1x4|F3x4|F61]
|
|
2039
|
+
[--stop-policy error|skip] [--reference <taxon>]
|
|
2040
|
+
[-v/--verbose] [--json]
|
|
2041
|
+
|
|
2042
|
+
Options
|
|
2043
|
+
=====================================================
|
|
2044
|
+
<alignment> in-frame nucleotide
|
|
2045
|
+
alignment
|
|
2046
|
+
|
|
2047
|
+
--method dN/dS estimator
|
|
2048
|
+
(default: NG86)
|
|
2049
|
+
|
|
2050
|
+
--genetic-code NCBI genetic-code ID
|
|
2051
|
+
(default: 1)
|
|
2052
|
+
|
|
2053
|
+
--kappa transition/transversion
|
|
2054
|
+
ratio used by NG86
|
|
2055
|
+
(default: 1.0)
|
|
2056
|
+
|
|
2057
|
+
--codon-frequency codon-frequency model used
|
|
2058
|
+
by ML (default: F3x4)
|
|
2059
|
+
|
|
2060
|
+
--stop-policy fail on internal stops or
|
|
2061
|
+
exclude them pairwise
|
|
2062
|
+
(default: error)
|
|
2063
|
+
|
|
2064
|
+
--reference estimate only pairs that
|
|
2065
|
+
include this exact taxon ID
|
|
2066
|
+
|
|
2067
|
+
-v/--verbose print pairwise TSV results
|
|
2068
|
+
|
|
2069
|
+
--json output structured JSON
|
|
2070
|
+
"""
|
|
2071
|
+
),
|
|
2072
|
+
)
|
|
2073
|
+
parser.add_argument("alignment", type=str, help=SUPPRESS)
|
|
2074
|
+
parser.add_argument(
|
|
2075
|
+
"--method",
|
|
2076
|
+
type=str.upper,
|
|
2077
|
+
choices=("NG86", "LWL85", "YN00", "ML"),
|
|
2078
|
+
default="NG86",
|
|
2079
|
+
help=SUPPRESS,
|
|
2080
|
+
)
|
|
2081
|
+
parser.add_argument(
|
|
2082
|
+
"--genetic-code", type=int, default=1, help=SUPPRESS
|
|
2083
|
+
)
|
|
2084
|
+
parser.add_argument("--kappa", type=float, default=1.0, help=SUPPRESS)
|
|
2085
|
+
parser.add_argument(
|
|
2086
|
+
"--codon-frequency",
|
|
2087
|
+
type=str.upper,
|
|
2088
|
+
choices=("F1X4", "F3X4", "F61"),
|
|
2089
|
+
default="F3X4",
|
|
2090
|
+
help=SUPPRESS,
|
|
2091
|
+
)
|
|
2092
|
+
parser.add_argument(
|
|
2093
|
+
"--stop-policy",
|
|
2094
|
+
choices=("error", "skip"),
|
|
2095
|
+
default="error",
|
|
2096
|
+
help=SUPPRESS,
|
|
2097
|
+
)
|
|
2098
|
+
parser.add_argument("--reference", type=str, default=None, help=SUPPRESS)
|
|
2099
|
+
parser.add_argument(
|
|
2100
|
+
"-v", "--verbose", action="store_true", required=False, help=SUPPRESS
|
|
2101
|
+
)
|
|
2102
|
+
_add_json_argument(parser)
|
|
2103
|
+
_run_service(parser, argv, CodonDnDs)
|
|
2104
|
+
|
|
1997
2105
|
@staticmethod
|
|
1998
2106
|
def identity_matrix(argv):
|
|
1999
2107
|
parser = _new_parser(
|
|
@@ -3011,7 +3119,7 @@ class Phykit:
|
|
|
3011
3119
|
{help_header}
|
|
3012
3120
|
|
|
3013
3121
|
Map discrete character changes onto a phylogenetic tree
|
|
3014
|
-
using
|
|
3122
|
+
using unordered parsimony, classifying each change as a
|
|
3015
3123
|
synapomorphy, convergence, or reversal.
|
|
3016
3124
|
|
|
3017
3125
|
Two optimization strategies are supported:
|
|
@@ -3023,7 +3131,11 @@ class Phykit:
|
|
|
3023
3131
|
Output is a cladogram (default) or phylogram (with
|
|
3024
3132
|
--phylogram) annotated with colored circles indicating
|
|
3025
3133
|
character state changes on each branch. Polytomies are
|
|
3026
|
-
|
|
3134
|
+
retained and analyzed directly.
|
|
3135
|
+
|
|
3136
|
+
Tree and matrix taxon labels are matched exactly and are
|
|
3137
|
+
case-sensitive. Mismatches are errors unless
|
|
3138
|
+
--allow-taxon-mismatch is specified.
|
|
3027
3139
|
|
|
3028
3140
|
Summary statistics include tree length (total parsimony
|
|
3029
3141
|
steps), consistency index (CI), and retention index (RI).
|
|
@@ -3036,7 +3148,9 @@ class Phykit:
|
|
|
3036
3148
|
Usage:
|
|
3037
3149
|
phykit character_map -t <tree> -d <data> -o <output>
|
|
3038
3150
|
[--optimization acctran|deltran] [--phylogram]
|
|
3039
|
-
[--characters 0,1,3] [--
|
|
3151
|
+
[--characters 0,1,3] [--allow-taxon-mismatch]
|
|
3152
|
+
[--change-marker-size <float>] [--change-fontsize <float>]
|
|
3153
|
+
[--verbose] [--json]
|
|
3040
3154
|
[--fig-width <float>] [--fig-height <float>]
|
|
3041
3155
|
[--dpi <int>] [--no-title] [--title <str>]
|
|
3042
3156
|
[--legend-position <str>]
|
|
@@ -3067,6 +3181,17 @@ class Phykit:
|
|
|
3067
3181
|
plot (e.g., 0,1,3); all
|
|
3068
3182
|
characters shown by default
|
|
3069
3183
|
|
|
3184
|
+
--allow-taxon-mismatch warn and analyze only taxa shared
|
|
3185
|
+
by the tree and character matrix;
|
|
3186
|
+
mismatches are errors by default
|
|
3187
|
+
|
|
3188
|
+
--change-marker-size character-change circle size in
|
|
3189
|
+
points squared; must be positive
|
|
3190
|
+
|
|
3191
|
+
--change-fontsize font size for character indices
|
|
3192
|
+
and state transitions; must be
|
|
3193
|
+
positive
|
|
3194
|
+
|
|
3070
3195
|
--verbose print per-character details
|
|
3071
3196
|
including CI/RI and changes
|
|
3072
3197
|
|
|
@@ -3095,6 +3220,18 @@ class Phykit:
|
|
|
3095
3220
|
"--characters", type=str, default=None,
|
|
3096
3221
|
required=False, help=SUPPRESS, metavar=""
|
|
3097
3222
|
)
|
|
3223
|
+
parser.add_argument(
|
|
3224
|
+
"--allow-taxon-mismatch", action="store_true",
|
|
3225
|
+
required=False, help=SUPPRESS,
|
|
3226
|
+
)
|
|
3227
|
+
parser.add_argument(
|
|
3228
|
+
"--change-marker-size", type=float, default=None,
|
|
3229
|
+
required=False, help=SUPPRESS, metavar="",
|
|
3230
|
+
)
|
|
3231
|
+
parser.add_argument(
|
|
3232
|
+
"--change-fontsize", type=float, default=None,
|
|
3233
|
+
required=False, help=SUPPRESS, metavar="",
|
|
3234
|
+
)
|
|
3098
3235
|
parser.add_argument(
|
|
3099
3236
|
"--verbose", action="store_true", required=False, help=SUPPRESS
|
|
3100
3237
|
)
|
|
@@ -10053,6 +10190,10 @@ def pairwise_identity(argv=None):
|
|
|
10053
10190
|
Phykit.pairwise_identity(sys.argv[1:])
|
|
10054
10191
|
|
|
10055
10192
|
|
|
10193
|
+
def codon_dnds(argv=None):
|
|
10194
|
+
Phykit.codon_dnds(sys.argv[1:])
|
|
10195
|
+
|
|
10196
|
+
|
|
10056
10197
|
def identity_matrix(argv=None):
|
|
10057
10198
|
Phykit.identity_matrix(sys.argv[1:])
|
|
10058
10199
|
|
|
@@ -26,6 +26,7 @@ AlignmentOutlierTaxa = _LazyServiceFactory("phykit.services.alignment.alignment_
|
|
|
26
26
|
ColumnScore = _LazyServiceFactory("phykit.services.alignment.column_score", "ColumnScore")
|
|
27
27
|
CompositionalBiasPerSite = _LazyServiceFactory("phykit.services.alignment.compositional_bias_per_site", "CompositionalBiasPerSite")
|
|
28
28
|
CompositionPerTaxon = _LazyServiceFactory("phykit.services.alignment.composition_per_taxon", "CompositionPerTaxon")
|
|
29
|
+
CodonDnDs = _LazyServiceFactory("phykit.services.alignment.codon_dnds", "CodonDnDs")
|
|
29
30
|
CreateConcatenationMatrix = _LazyServiceFactory("phykit.services.alignment.create_concatenation_matrix", "CreateConcatenationMatrix")
|
|
30
31
|
DNAThreader = _LazyServiceFactory("phykit.services.alignment.dna_threader", "DNAThreader")
|
|
31
32
|
Dtt = _LazyServiceFactory("phykit.services.tree.dtt", "Dtt")
|
|
@@ -10,6 +10,7 @@ _EXPORTS = {
|
|
|
10
10
|
"ColumnScore": "column_score",
|
|
11
11
|
"CompositionalBiasPerSite": "compositional_bias_per_site",
|
|
12
12
|
"CompositionPerTaxon": "composition_per_taxon",
|
|
13
|
+
"CodonDnDs": "codon_dnds",
|
|
13
14
|
"CreateConcatenationMatrix": "create_concatenation_matrix",
|
|
14
15
|
"DNAThreader": "dna_threader",
|
|
15
16
|
"Dstatistic": "dstatistic",
|