phykit 2.1.93__tar.gz → 2.2.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.1.93 → phykit-2.2.0}/PKG-INFO +18 -2
- {phykit-2.1.93 → phykit-2.2.0}/phykit/cli_registry.py +1 -3
- {phykit-2.1.93 → phykit-2.2.0}/phykit/errors.py +2 -5
- {phykit-2.1.93 → phykit-2.2.0}/phykit/helpers/boolean_argument_parsing.py +5 -5
- {phykit-2.1.93 → phykit-2.2.0}/phykit/helpers/caching.py +83 -19
- phykit-2.2.0/phykit/helpers/circular_layout.py +998 -0
- phykit-2.2.0/phykit/helpers/color_annotations.py +423 -0
- phykit-2.2.0/phykit/helpers/discrete_models.py +1093 -0
- phykit-2.2.0/phykit/helpers/files.py +243 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/helpers/geological_timescale.py +14 -4
- phykit-2.2.0/phykit/helpers/json_output.py +101 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/helpers/parallel.py +147 -39
- phykit-2.2.0/phykit/helpers/parsimony_utils.py +827 -0
- phykit-2.2.0/phykit/helpers/pgls_utils.py +357 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/helpers/plot_config.py +380 -41
- phykit-2.2.0/phykit/helpers/quartet_utils.py +283 -0
- phykit-2.2.0/phykit/helpers/stats_summary.py +374 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/helpers/streaming.py +66 -53
- phykit-2.2.0/phykit/helpers/trait_parsing.py +294 -0
- phykit-2.2.0/phykit/helpers/tree_paths.py +125 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/phykit.py +942 -149
- {phykit-2.1.93 → phykit-2.2.0}/phykit/service_factories.py +1 -2
- phykit-2.2.0/phykit/services/alignment/_fasta.py +198 -0
- phykit-2.2.0/phykit/services/alignment/alignment_entropy.py +480 -0
- phykit-2.2.0/phykit/services/alignment/alignment_length.py +94 -0
- phykit-2.2.0/phykit/services/alignment/alignment_length_no_gaps.py +238 -0
- phykit-2.2.0/phykit/services/alignment/alignment_outlier_taxa.py +1033 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/alignment/alignment_recoding.py +58 -18
- phykit-2.2.0/phykit/services/alignment/alignment_subsample.py +465 -0
- phykit-2.2.0/phykit/services/alignment/base.py +288 -0
- phykit-2.2.0/phykit/services/alignment/column_score.py +385 -0
- phykit-2.2.0/phykit/services/alignment/composition_per_taxon.py +523 -0
- phykit-2.2.0/phykit/services/alignment/compositional_bias_per_site.py +708 -0
- phykit-2.2.0/phykit/services/alignment/create_concatenation_matrix.py +961 -0
- phykit-2.2.0/phykit/services/alignment/dfoil.py +519 -0
- phykit-2.2.0/phykit/services/alignment/dna_threader.py +773 -0
- phykit-2.2.0/phykit/services/alignment/dstatistic.py +871 -0
- phykit-2.2.0/phykit/services/alignment/evolutionary_rate_per_site.py +444 -0
- phykit-2.2.0/phykit/services/alignment/faidx.py +63 -0
- phykit-2.2.0/phykit/services/alignment/gc_content.py +445 -0
- phykit-2.2.0/phykit/services/alignment/identity_matrix.py +994 -0
- phykit-2.2.0/phykit/services/alignment/mask_alignment.py +429 -0
- phykit-2.2.0/phykit/services/alignment/occupancy_filter.py +511 -0
- phykit-2.2.0/phykit/services/alignment/occupancy_per_taxon.py +266 -0
- phykit-2.2.0/phykit/services/alignment/pairwise_identity.py +1042 -0
- phykit-2.2.0/phykit/services/alignment/parsimony_informative_sites.py +267 -0
- phykit-2.2.0/phykit/services/alignment/phylo_gwas.py +1713 -0
- phykit-2.2.0/phykit/services/alignment/plot_alignment_qc.py +414 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/alignment/rcv.py +6 -1
- phykit-2.2.0/phykit/services/alignment/rcvt.py +296 -0
- phykit-2.2.0/phykit/services/alignment/rename_fasta_entries.py +220 -0
- phykit-2.2.0/phykit/services/alignment/sum_of_pairs_score.py +496 -0
- phykit-2.2.0/phykit/services/alignment/taxon_groups.py +218 -0
- phykit-2.2.0/phykit/services/alignment/variable_sites.py +178 -0
- phykit-2.2.0/phykit/services/tree/ancestral_reconstruction.py +2812 -0
- phykit-2.2.0/phykit/services/tree/base.py +1392 -0
- phykit-2.2.0/phykit/services/tree/bipartition_support_stats.py +531 -0
- phykit-2.2.0/phykit/services/tree/branch_length_multiplier.py +128 -0
- phykit-2.2.0/phykit/services/tree/character_map.py +1102 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/chronogram.py +414 -146
- phykit-2.2.0/phykit/services/tree/collapse_branches.py +166 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/concordance_asr.py +507 -200
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/consensus_network.py +471 -129
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/consensus_tree.py +92 -23
- phykit-2.2.0/phykit/services/tree/cont_map.py +829 -0
- phykit-2.2.0/phykit/services/tree/cophylo.py +1072 -0
- phykit-2.2.0/phykit/services/tree/covarying_evolutionary_rates.py +887 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/density_map.py +294 -185
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/discordance_asymmetry.py +596 -151
- phykit-2.2.0/phykit/services/tree/dtt.py +929 -0
- phykit-2.2.0/phykit/services/tree/dvmc.py +106 -0
- phykit-2.2.0/phykit/services/tree/evo_tempo_map.py +1123 -0
- phykit-2.2.0/phykit/services/tree/evolutionary_rate.py +38 -0
- phykit-2.2.0/phykit/services/tree/faiths_pd.py +206 -0
- phykit-2.2.0/phykit/services/tree/fit_continuous.py +858 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/fit_discrete.py +141 -26
- phykit-2.2.0/phykit/services/tree/hidden_paralogy_check.py +295 -0
- phykit-2.2.0/phykit/services/tree/hybridization.py +1174 -0
- phykit-2.2.0/phykit/services/tree/independent_contrasts.py +685 -0
- phykit-2.2.0/phykit/services/tree/internal_branch_stats.py +427 -0
- phykit-2.2.0/phykit/services/tree/internode_labeler.py +86 -0
- phykit-2.2.0/phykit/services/tree/kf_distance.py +167 -0
- phykit-2.2.0/phykit/services/tree/last_common_ancestor_subtree.py +207 -0
- phykit-2.2.0/phykit/services/tree/lb_score.py +714 -0
- phykit-2.2.0/phykit/services/tree/ltt.py +524 -0
- phykit-2.2.0/phykit/services/tree/monophyly_check.py +550 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/nearest_neighbor_interchange.py +144 -34
- phykit-2.2.0/phykit/services/tree/neighbor_net.py +943 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/network_signal.py +398 -146
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/ou_shift_detection.py +504 -252
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/ouwie.py +1039 -579
- phykit-2.2.0/phykit/services/tree/parsimony_score.py +613 -0
- phykit-2.2.0/phykit/services/tree/patristic_distances.py +732 -0
- phykit-2.2.0/phykit/services/tree/phenogram.py +640 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/phylo_anova.py +472 -194
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/phylo_heatmap.py +363 -97
- phykit-2.2.0/phykit/services/tree/phylo_impute.py +758 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/phylo_logistic.py +310 -99
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/phylo_path.py +477 -212
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/phylogenetic_glm.py +466 -147
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/phylogenetic_ordination.py +563 -155
- phykit-2.2.0/phykit/services/tree/phylogenetic_regression.py +629 -0
- phykit-2.2.0/phykit/services/tree/phylogenetic_signal.py +719 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/phylomorphospace.py +170 -67
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/polytomy_test.py +469 -135
- phykit-2.2.0/phykit/services/tree/print_tree.py +84 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/prune_tree.py +42 -17
- phykit-2.2.0/phykit/services/tree/quartet_network.py +1335 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/quartet_pie.py +393 -81
- phykit-2.2.0/phykit/services/tree/rate_heterogeneity.py +1330 -0
- phykit-2.2.0/phykit/services/tree/relative_rate_test.py +811 -0
- phykit-2.2.0/phykit/services/tree/rename_tree_tips.py +210 -0
- phykit-2.2.0/phykit/services/tree/rf_distance.py +476 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/root_tree.py +34 -9
- phykit-2.2.0/phykit/services/tree/saturation.py +858 -0
- phykit-2.2.0/phykit/services/tree/simmap_summary.py +776 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/spectral_discordance.py +545 -132
- phykit-2.2.0/phykit/services/tree/spr.py +380 -0
- phykit-2.2.0/phykit/services/tree/spurious_sequence.py +231 -0
- phykit-2.2.0/phykit/services/tree/stochastic_character_map.py +1326 -0
- phykit-2.2.0/phykit/services/tree/terminal_branch_stats.py +375 -0
- phykit-2.2.0/phykit/services/tree/threshold_model.py +1252 -0
- phykit-2.2.0/phykit/services/tree/tip_labels.py +40 -0
- phykit-2.2.0/phykit/services/tree/tip_to_tip_distance.py +538 -0
- phykit-2.2.0/phykit/services/tree/tip_to_tip_node_distance.py +202 -0
- phykit-2.2.0/phykit/services/tree/total_tree_length.py +44 -0
- phykit-2.2.0/phykit/services/tree/trait_correlation.py +583 -0
- phykit-2.2.0/phykit/services/tree/trait_rate_map.py +886 -0
- phykit-2.2.0/phykit/services/tree/transfer_annotations.py +295 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/tree_space.py +420 -136
- phykit-2.2.0/phykit/services/tree/treeness.py +40 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/treeness_over_rcv.py +28 -7
- phykit-2.2.0/phykit/services/tree/vcv_utils.py +832 -0
- phykit-2.2.0/phykit/version.py +1 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit.egg-info/PKG-INFO +18 -2
- {phykit-2.1.93 → phykit-2.2.0}/phykit.egg-info/SOURCES.txt +2 -0
- phykit-2.1.93/phykit/helpers/circular_layout.py +0 -315
- phykit-2.1.93/phykit/helpers/color_annotations.py +0 -250
- phykit-2.1.93/phykit/helpers/discrete_models.py +0 -299
- phykit-2.1.93/phykit/helpers/files.py +0 -137
- phykit-2.1.93/phykit/helpers/json_output.py +0 -26
- phykit-2.1.93/phykit/helpers/parsimony_utils.py +0 -345
- phykit-2.1.93/phykit/helpers/pgls_utils.py +0 -181
- phykit-2.1.93/phykit/helpers/quartet_utils.py +0 -173
- phykit-2.1.93/phykit/helpers/stats_summary.py +0 -66
- phykit-2.1.93/phykit/helpers/trait_parsing.py +0 -133
- phykit-2.1.93/phykit/services/alignment/alignment_entropy.py +0 -131
- phykit-2.1.93/phykit/services/alignment/alignment_length.py +0 -25
- phykit-2.1.93/phykit/services/alignment/alignment_length_no_gaps.py +0 -84
- phykit-2.1.93/phykit/services/alignment/alignment_outlier_taxa.py +0 -353
- phykit-2.1.93/phykit/services/alignment/alignment_subsample.py +0 -281
- phykit-2.1.93/phykit/services/alignment/base.py +0 -112
- phykit-2.1.93/phykit/services/alignment/column_score.py +0 -79
- phykit-2.1.93/phykit/services/alignment/composition_per_taxon.py +0 -78
- phykit-2.1.93/phykit/services/alignment/compositional_bias_per_site.py +0 -231
- phykit-2.1.93/phykit/services/alignment/create_concatenation_matrix.py +0 -494
- phykit-2.1.93/phykit/services/alignment/dfoil.py +0 -271
- phykit-2.1.93/phykit/services/alignment/dna_threader.py +0 -162
- phykit-2.1.93/phykit/services/alignment/dstatistic.py +0 -420
- phykit-2.1.93/phykit/services/alignment/evolutionary_rate_per_site.py +0 -154
- phykit-2.1.93/phykit/services/alignment/faidx.py +0 -42
- phykit-2.1.93/phykit/services/alignment/gc_content.py +0 -114
- phykit-2.1.93/phykit/services/alignment/identity_matrix.py +0 -497
- phykit-2.1.93/phykit/services/alignment/mask_alignment.py +0 -101
- phykit-2.1.93/phykit/services/alignment/occupancy_filter.py +0 -299
- phykit-2.1.93/phykit/services/alignment/occupancy_per_taxon.py +0 -53
- phykit-2.1.93/phykit/services/alignment/pairwise_identity.py +0 -293
- phykit-2.1.93/phykit/services/alignment/parsimony_informative_sites.py +0 -99
- phykit-2.1.93/phykit/services/alignment/phylo_gwas.py +0 -683
- phykit-2.1.93/phykit/services/alignment/plot_alignment_qc.py +0 -213
- phykit-2.1.93/phykit/services/alignment/rcvt.py +0 -122
- phykit-2.1.93/phykit/services/alignment/rename_fasta_entries.py +0 -78
- phykit-2.1.93/phykit/services/alignment/sum_of_pairs_score.py +0 -170
- phykit-2.1.93/phykit/services/alignment/taxon_groups.py +0 -124
- phykit-2.1.93/phykit/services/alignment/variable_sites.py +0 -71
- phykit-2.1.93/phykit/services/tree/ancestral_reconstruction.py +0 -1810
- phykit-2.1.93/phykit/services/tree/base.py +0 -228
- phykit-2.1.93/phykit/services/tree/bipartition_support_stats.py +0 -152
- phykit-2.1.93/phykit/services/tree/branch_length_multiplier.py +0 -57
- phykit-2.1.93/phykit/services/tree/character_map.py +0 -714
- phykit-2.1.93/phykit/services/tree/collapse_branches.py +0 -47
- phykit-2.1.93/phykit/services/tree/cont_map.py +0 -623
- phykit-2.1.93/phykit/services/tree/cophylo.py +0 -559
- phykit-2.1.93/phykit/services/tree/covarying_evolutionary_rates.py +0 -409
- phykit-2.1.93/phykit/services/tree/dtt.py +0 -411
- phykit-2.1.93/phykit/services/tree/dvmc.py +0 -41
- phykit-2.1.93/phykit/services/tree/evo_tempo_map.py +0 -667
- phykit-2.1.93/phykit/services/tree/evolutionary_rate.py +0 -24
- phykit-2.1.93/phykit/services/tree/faiths_pd.py +0 -148
- phykit-2.1.93/phykit/services/tree/fit_continuous.py +0 -612
- phykit-2.1.93/phykit/services/tree/hidden_paralogy_check.py +0 -148
- phykit-2.1.93/phykit/services/tree/hybridization.py +0 -710
- phykit-2.1.93/phykit/services/tree/independent_contrasts.py +0 -200
- phykit-2.1.93/phykit/services/tree/internal_branch_stats.py +0 -101
- phykit-2.1.93/phykit/services/tree/internode_labeler.py +0 -52
- phykit-2.1.93/phykit/services/tree/kf_distance.py +0 -101
- phykit-2.1.93/phykit/services/tree/last_common_ancestor_subtree.py +0 -54
- phykit-2.1.93/phykit/services/tree/lb_score.py +0 -220
- phykit-2.1.93/phykit/services/tree/ltt.py +0 -213
- phykit-2.1.93/phykit/services/tree/monophyly_check.py +0 -124
- phykit-2.1.93/phykit/services/tree/neighbor_net.py +0 -601
- phykit-2.1.93/phykit/services/tree/parsimony_score.py +0 -162
- phykit-2.1.93/phykit/services/tree/patristic_distances.py +0 -141
- phykit-2.1.93/phykit/services/tree/phenogram.py +0 -493
- phykit-2.1.93/phykit/services/tree/phylo_impute.py +0 -424
- phykit-2.1.93/phykit/services/tree/phylogenetic_regression.py +0 -382
- phykit-2.1.93/phykit/services/tree/phylogenetic_signal.py +0 -445
- phykit-2.1.93/phykit/services/tree/print_tree.py +0 -47
- phykit-2.1.93/phykit/services/tree/quartet_network.py +0 -798
- phykit-2.1.93/phykit/services/tree/rate_heterogeneity.py +0 -923
- phykit-2.1.93/phykit/services/tree/relative_rate_test.py +0 -410
- phykit-2.1.93/phykit/services/tree/rename_tree_tips.py +0 -84
- phykit-2.1.93/phykit/services/tree/rf_distance.py +0 -151
- phykit-2.1.93/phykit/services/tree/saturation.py +0 -312
- phykit-2.1.93/phykit/services/tree/simmap_summary.py +0 -571
- phykit-2.1.93/phykit/services/tree/spr.py +0 -275
- phykit-2.1.93/phykit/services/tree/spurious_sequence.py +0 -93
- phykit-2.1.93/phykit/services/tree/stochastic_character_map.py +0 -713
- phykit-2.1.93/phykit/services/tree/terminal_branch_stats.py +0 -111
- phykit-2.1.93/phykit/services/tree/threshold_model.py +0 -867
- phykit-2.1.93/phykit/services/tree/tip_labels.py +0 -26
- phykit-2.1.93/phykit/services/tree/tip_to_tip_distance.py +0 -183
- phykit-2.1.93/phykit/services/tree/tip_to_tip_node_distance.py +0 -59
- phykit-2.1.93/phykit/services/tree/total_tree_length.py +0 -32
- phykit-2.1.93/phykit/services/tree/trait_correlation.py +0 -351
- phykit-2.1.93/phykit/services/tree/trait_rate_map.py +0 -644
- phykit-2.1.93/phykit/services/tree/transfer_annotations.py +0 -174
- phykit-2.1.93/phykit/services/tree/treeness.py +0 -23
- phykit-2.1.93/phykit/services/tree/vcv_utils.py +0 -194
- phykit-2.1.93/phykit/version.py +0 -1
- {phykit-2.1.93 → phykit-2.2.0}/LICENSE.md +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/README.md +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/__init__.py +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/__main__.py +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/helpers/__init__.py +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/__init__.py +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/alignment/__init__.py +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/base.py +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit/services/tree/__init__.py +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit.egg-info/dependency_links.txt +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit.egg-info/entry_points.txt +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit.egg-info/requires.txt +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/phykit.egg-info/top_level.txt +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/setup.cfg +0 -0
- {phykit-2.1.93 → phykit-2.2.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: phykit
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Home-page: https://github.com/jlsteenwyk/phykit
|
|
5
5
|
Author: Jacob L. Steenwyk
|
|
6
6
|
Author-email: jlsteenwyk@gmail.com
|
|
@@ -15,6 +15,22 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE.md
|
|
18
|
+
Requires-Dist: biopython>=1.82
|
|
19
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
20
|
+
Requires-Dist: numpy>=1.24.0
|
|
21
|
+
Requires-Dist: scipy>=1.11.3
|
|
22
|
+
Requires-Dist: scikit-learn>=1.4.2
|
|
23
|
+
Requires-Dist: umap-learn>=0.5.0
|
|
24
|
+
Requires-Dist: tqdm>=4.65.0
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
Dynamic: requires-dist
|
|
33
|
+
Dynamic: requires-python
|
|
18
34
|
|
|
19
35
|
<p align="center">
|
|
20
36
|
<a href="https://github.com/jlsteenwyk/phykit">
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"""Declarative CLI alias registry."""
|
|
2
2
|
|
|
3
|
-
from typing import Dict
|
|
4
|
-
|
|
5
3
|
|
|
6
4
|
# Map user-facing aliases (and a few long-form synonyms) to Phykit handler names.
|
|
7
|
-
ALIAS_TO_HANDLER:
|
|
5
|
+
ALIAS_TO_HANDLER: dict[str, str] = {
|
|
8
6
|
# version
|
|
9
7
|
"version": "version",
|
|
10
8
|
"v": "version",
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"""Shared PhyKIT exception types."""
|
|
2
2
|
|
|
3
|
-
from typing import Iterable, List
|
|
4
|
-
|
|
5
3
|
|
|
6
4
|
class PhykitUserError(SystemExit):
|
|
7
5
|
"""User-facing error that should be rendered by the CLI with a specific exit code."""
|
|
8
6
|
|
|
9
|
-
def __init__(self, messages
|
|
10
|
-
self.messages:
|
|
7
|
+
def __init__(self, messages, code: int = 2):
|
|
8
|
+
self.messages: list[str] = list(messages)
|
|
11
9
|
super().__init__(code)
|
|
12
|
-
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
def str2bool(v):
|
|
5
2
|
if isinstance(v, bool):
|
|
6
3
|
return v
|
|
7
|
-
|
|
4
|
+
value = v.lower()
|
|
5
|
+
if value in ("true", "t", "1"):
|
|
8
6
|
return True
|
|
9
|
-
elif
|
|
7
|
+
elif value in ("false", "f", "0"):
|
|
10
8
|
return False
|
|
11
9
|
else:
|
|
10
|
+
import argparse
|
|
11
|
+
|
|
12
12
|
raise argparse.ArgumentTypeError("Boolean value expected.")
|
|
@@ -2,13 +2,62 @@
|
|
|
2
2
|
Caching utilities for expensive computations
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import hashlib
|
|
6
|
-
import pickle
|
|
7
5
|
import os
|
|
8
|
-
import tempfile
|
|
9
6
|
from functools import wraps, lru_cache
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class _LazyPickle:
|
|
10
|
+
_module = None
|
|
11
|
+
|
|
12
|
+
def _load(self):
|
|
13
|
+
module = self._module
|
|
14
|
+
if module is None:
|
|
15
|
+
import pickle as module
|
|
16
|
+
|
|
17
|
+
self._module = module
|
|
18
|
+
|
|
19
|
+
return module
|
|
20
|
+
|
|
21
|
+
def _resolve(self, name):
|
|
22
|
+
value = getattr(self._load(), name)
|
|
23
|
+
setattr(self, name, value)
|
|
24
|
+
return value
|
|
25
|
+
|
|
26
|
+
def dump(self, *args, **kwargs):
|
|
27
|
+
return self._resolve("dump")(*args, **kwargs)
|
|
28
|
+
|
|
29
|
+
def dumps(self, *args, **kwargs):
|
|
30
|
+
return self._resolve("dumps")(*args, **kwargs)
|
|
31
|
+
|
|
32
|
+
def load(self, *args, **kwargs):
|
|
33
|
+
return self._resolve("load")(*args, **kwargs)
|
|
34
|
+
|
|
35
|
+
def loads(self, *args, **kwargs):
|
|
36
|
+
return self._resolve("loads")(*args, **kwargs)
|
|
37
|
+
|
|
38
|
+
def __getattr__(self, name):
|
|
39
|
+
return self._resolve(name)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
pickle = _LazyPickle()
|
|
43
|
+
_MD5 = None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _json_dumps(*args, **kwargs):
|
|
47
|
+
import json
|
|
48
|
+
|
|
49
|
+
return json.dumps(*args, **kwargs)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _md5(*args, **kwargs):
|
|
53
|
+
global _MD5
|
|
54
|
+
|
|
55
|
+
if _MD5 is None:
|
|
56
|
+
from hashlib import md5 as _hashlib_md5
|
|
57
|
+
|
|
58
|
+
_MD5 = _hashlib_md5
|
|
59
|
+
|
|
60
|
+
return _MD5(*args, **kwargs)
|
|
12
61
|
|
|
13
62
|
|
|
14
63
|
class ResultCache:
|
|
@@ -24,6 +73,8 @@ class ResultCache:
|
|
|
24
73
|
cache_dir: Directory for cache files (uses temp dir if None)
|
|
25
74
|
"""
|
|
26
75
|
if cache_dir is None:
|
|
76
|
+
import tempfile
|
|
77
|
+
|
|
27
78
|
cache_dir = os.path.join(tempfile.gettempdir(), 'phykit_cache')
|
|
28
79
|
|
|
29
80
|
self.cache_dir = cache_dir
|
|
@@ -31,6 +82,14 @@ class ResultCache:
|
|
|
31
82
|
|
|
32
83
|
def _get_cache_key(self, *args, **kwargs) -> str:
|
|
33
84
|
"""Generate a unique cache key from function arguments."""
|
|
85
|
+
if not kwargs:
|
|
86
|
+
if len(args) == 0:
|
|
87
|
+
return _md5(b"").hexdigest()
|
|
88
|
+
if len(args) == 1:
|
|
89
|
+
arg = args[0]
|
|
90
|
+
if isinstance(arg, (str, int, float, bool)):
|
|
91
|
+
return _md5(str(arg).encode()).hexdigest()
|
|
92
|
+
|
|
34
93
|
# Create a string representation of arguments
|
|
35
94
|
key_parts = []
|
|
36
95
|
|
|
@@ -39,7 +98,7 @@ class ResultCache:
|
|
|
39
98
|
key_parts.append(str(arg))
|
|
40
99
|
elif hasattr(arg, '__dict__'):
|
|
41
100
|
# For objects, use their attributes
|
|
42
|
-
key_parts.append(
|
|
101
|
+
key_parts.append(_json_dumps(vars(arg), sort_keys=True, default=str))
|
|
43
102
|
else:
|
|
44
103
|
key_parts.append(str(arg))
|
|
45
104
|
|
|
@@ -47,9 +106,9 @@ class ResultCache:
|
|
|
47
106
|
key_parts.append(f"{k}={v}")
|
|
48
107
|
|
|
49
108
|
key_string = "_".join(key_parts)
|
|
50
|
-
return
|
|
109
|
+
return _md5(key_string.encode()).hexdigest()
|
|
51
110
|
|
|
52
|
-
def get(self, cache_key: str) ->
|
|
111
|
+
def get(self, cache_key: str) -> object:
|
|
53
112
|
"""Retrieve cached result."""
|
|
54
113
|
cache_file = os.path.join(self.cache_dir, f"{cache_key}.pkl")
|
|
55
114
|
|
|
@@ -63,7 +122,7 @@ class ResultCache:
|
|
|
63
122
|
|
|
64
123
|
return None
|
|
65
124
|
|
|
66
|
-
def set(self, cache_key: str, value:
|
|
125
|
+
def set(self, cache_key: str, value: object) -> None:
|
|
67
126
|
"""Store result in cache."""
|
|
68
127
|
cache_file = os.path.join(self.cache_dir, f"{cache_key}.pkl")
|
|
69
128
|
|
|
@@ -76,9 +135,10 @@ class ResultCache:
|
|
|
76
135
|
|
|
77
136
|
def clear(self) -> None:
|
|
78
137
|
"""Clear all cached results."""
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
138
|
+
with os.scandir(self.cache_dir) as entries:
|
|
139
|
+
for entry in entries:
|
|
140
|
+
if entry.name.endswith('.pkl'):
|
|
141
|
+
os.remove(entry.path)
|
|
82
142
|
|
|
83
143
|
|
|
84
144
|
def cached_computation(cache_instance: ResultCache = None):
|
|
@@ -94,7 +154,7 @@ def cached_computation(cache_instance: ResultCache = None):
|
|
|
94
154
|
if cache_instance is None:
|
|
95
155
|
cache_instance = ResultCache()
|
|
96
156
|
|
|
97
|
-
def decorator(func:
|
|
157
|
+
def decorator(func: object) -> object:
|
|
98
158
|
@wraps(func)
|
|
99
159
|
def wrapper(*args, **kwargs):
|
|
100
160
|
# Generate cache key
|
|
@@ -135,7 +195,6 @@ def cached_tree_distance(tree_pickle: bytes, tip1: str, tip2: str) -> float:
|
|
|
135
195
|
Returns:
|
|
136
196
|
Distance between tips
|
|
137
197
|
"""
|
|
138
|
-
import pickle
|
|
139
198
|
tree = pickle.loads(tree_pickle)
|
|
140
199
|
return tree.distance(tip1, tip2)
|
|
141
200
|
|
|
@@ -166,13 +225,13 @@ class AlignmentCache:
|
|
|
166
225
|
self.get_column.cache_clear()
|
|
167
226
|
|
|
168
227
|
@lru_cache(maxsize=128)
|
|
169
|
-
def get_stats(self, alignment_hash: str, stat_type: str) ->
|
|
228
|
+
def get_stats(self, alignment_hash: str, stat_type: str) -> object:
|
|
170
229
|
"""
|
|
171
230
|
Get cached alignment statistics.
|
|
172
231
|
"""
|
|
173
232
|
return self._stats_cache.get(f"{alignment_hash}_{stat_type}")
|
|
174
233
|
|
|
175
|
-
def set_stats(self, alignment_hash: str, stat_type: str, stats:
|
|
234
|
+
def set_stats(self, alignment_hash: str, stat_type: str, stats: object) -> None:
|
|
176
235
|
"""
|
|
177
236
|
Cache alignment statistics.
|
|
178
237
|
"""
|
|
@@ -190,16 +249,21 @@ class AlignmentCache:
|
|
|
190
249
|
self.get_stats.cache_clear()
|
|
191
250
|
|
|
192
251
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
_alignment_cache = AlignmentCache()
|
|
252
|
+
_result_cache = None
|
|
253
|
+
_alignment_cache = None
|
|
196
254
|
|
|
197
255
|
|
|
198
256
|
def get_result_cache() -> ResultCache:
|
|
199
257
|
"""Get global result cache instance."""
|
|
258
|
+
global _result_cache
|
|
259
|
+
if _result_cache is None:
|
|
260
|
+
_result_cache = ResultCache()
|
|
200
261
|
return _result_cache
|
|
201
262
|
|
|
202
263
|
|
|
203
264
|
def get_alignment_cache() -> AlignmentCache:
|
|
204
265
|
"""Get global alignment cache instance."""
|
|
266
|
+
global _alignment_cache
|
|
267
|
+
if _alignment_cache is None:
|
|
268
|
+
_alignment_cache = AlignmentCache()
|
|
205
269
|
return _alignment_cache
|