Skip to content

API: Rename apps #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions changelog.d/20250702_161144_robert.mcarthur_rename_apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Contributors

- A bullet item for the Contributors category.

-->
<!--
### ENH

- A bullet item for the ENH category.

-->
<!--
### BUG

- A bullet item for the BUG category.

-->

### API

- All apps have been renamed to take the form `piq_<func_name>`.


<!--
### DOC

- A bullet item for the DOC category.

-->
<!--
### Deprecations

- A bullet item for the Deprecations category.

-->
<!--
### Discontinued

- A bullet item for the Discontinued category.

-->
2 changes: 1 addition & 1 deletion docs/apps/app_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
divergent = get_app("dvs_nmost", n=10, k=6)
just_nucs = get_app("omit_degenerates") # has to go after the divergent selector
min_length = get_app("min_length", length=600)
best_model = get_app("piqtree_mfinder")
best_model = get_app("piq_model_finder")
app = loader + divergent + just_nucs + min_length + best_model
model_counts = Counter(
str(result.best_aic)
Expand Down
4 changes: 2 additions & 2 deletions docs/apps/available_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# %%
from cogent3 import app_help

app_help("piqtree_phylo")
app_help("piq_build_tree")

# %%
from cogent3 import app_help

app_help("piqtree_fit")
app_help("piq_fit_tree")
8 changes: 4 additions & 4 deletions docs/apps/fit_tree.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# We evaluate a support for a specific phylogeny using `piqtree_fit`.
# We evaluate a support for a specific phylogeny using `piq_fit_tree`.
# For this simple case, we will assess the support for a specific phylogeny using the GTR model on one alignment.

# %%
Expand All @@ -20,21 +20,21 @@
tree.get_figure().show()

# %% [markdown]
# We now take a look at the help for the `piqtree_fit` app.
# We now take a look at the help for the `piq_fit_tree` app.

# %%

from cogent3 import app_help

app_help("piqtree_fit")
app_help("piq_fit_tree")

# %% [markdown]
# We fit a GTR model and estimate the nucleotide frequencies by maximum likelihood.

# %%
from cogent3 import get_app

fit_gtr = get_app("piqtree_fit", tree, model="GTR+FO")
fit_gtr = get_app("piq_fit_tree", tree, model="GTR+FO")
fit_gtr

# %% [markdown]
Expand Down
12 changes: 6 additions & 6 deletions docs/apps/model_finder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# We use the `piqtree_mfinder` app to rank models. This is the python binding to the IQ-TREE ModelFinder tool.
# We use the `piq_model_finder` app to rank models. This is the python binding to the IQ-TREE ModelFinder tool.

# %%
from cogent3 import app_help, get_app, load_aligned_seqs
Expand All @@ -10,13 +10,13 @@
aln = load_aligned_seqs(aln_path, moltype="dna", format="phylip")

# %% [markdown]
# Get help and then apply `piqtree_mfinder`.
# Get help and then apply `piq_model_finder`.

# %%
app_help("piqtree_mfinder")
app_help("piq_model_finder")

# %%
mfinder = get_app("piqtree_mfinder")
mfinder = get_app("piq_model_finder")
ranked = mfinder(aln)
ranked

Expand All @@ -37,9 +37,9 @@
# ## Using the best model
# You can apply the selected model to a phylogenetic analysis.
# > **Note**
# > The process is the same for both the `piqtree_phylo` and the `piqtree_fit` apps.
# > The process is the same for both the `piq_build_tree` and the `piq_fit_tree` apps.

# %%
fit = get_app("piqtree_phylo", selected)
fit = get_app("piq_build_tree", selected)
fitted = fit(aln)
fitted
14 changes: 7 additions & 7 deletions docs/apps/nj.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# The Neighbour-Joining method uses genetic distances to build a phylogenetic tree. `piqtree` provides only `piqtree_jc_dists` for this. `cogent3` includes many more methods. The results of either can be used to build a tree. For divergent sequences we will use Lake's paralinear measure as it accomodates divergent sequence compositions.
# The Neighbour-Joining method uses genetic distances to build a phylogenetic tree. `piqtree` provides only `piq_jc_distances` for this. `cogent3` includes many more methods. The results of either can be used to build a tree. For divergent sequences we will use Lake's paralinear measure as it accomodates divergent sequence compositions.

# %%
import cogent3
Expand All @@ -18,16 +18,16 @@
dists

# %% [markdown]
# Get help on the `piqtree_nj` app.
# Get help on the `piq_nj_tree` app.

# %%
cogent3.app_help("piqtree_nj")
cogent3.app_help("piq_nj_tree")

# %% [markdown]
# Make an app and apply it to the distance matrix.

# %%
nj = cogent3.get_app("piqtree_nj")
nj = cogent3.get_app("piq_nj_tree")
tree = nj(dists)

# %% [markdown]
Expand All @@ -43,11 +43,11 @@

# %% [markdown]
# ## Combining the piqtree dist and nj apps
# We can combine the `piqtree_jc_dists` and `piqtree_nj` apps to build a tree from an alignment in one step.
# We can combine the `piq_jc_distances` and `piq_nj_tree` apps to build a tree from an alignment in one step.

# %%
jc = cogent3.get_app("piqtree_jc_dists")
nj = cogent3.get_app("piqtree_nj")
jc = cogent3.get_app("piq_jc_distances")
nj = cogent3.get_app("piq_nj_tree")
app = jc + nj
tree = app(aln)
tree.get_figure().show()
6 changes: 3 additions & 3 deletions docs/apps/pairwise_dist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# We estimate pairwise distances via the Jukes-Cantor model with the `piqtree_jc_dists` app.
# We estimate pairwise distances via the Jukes-Cantor model with the `piq_jc_distances` app.

# %%
import cogent3
Expand All @@ -13,12 +13,12 @@
# We get help on the `piqtree_jc_dist` app.

# %%
cogent3.app_help("piqtree_jc_dists")
cogent3.app_help("piq_jc_distances")

# %% [markdown]
# Make an app and apply it to the alignment.

# %%
jc_dists = cogent3.get_app("piqtree_jc_dists")
jc_dists = cogent3.get_app("piq_jc_distances")
dists = jc_dists(aln)
dists
8 changes: 4 additions & 4 deletions docs/apps/phylo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# We use the `piqtree_phylo` app to build phylogenies.
# We use the `piq_build_tree` app to build phylogenies.
# For this simple case, we will build a single phylogeny using the GTR model on one alignment.
# We have a utility script for this documentation that provides the local path to that data. We will then load that data and, as it contains quite a few sequences, we will use a subset of it. We use methods on the `cogent3` object to do that.

Expand All @@ -14,21 +14,21 @@


# %% [markdown]
# We now take a look at the help for the `piqtree_phylo` app.
# We now take a look at the help for the `piq_build_tree` app.

# %%

from cogent3 import app_help

app_help("piqtree_phylo")
app_help("piq_build_tree")

# %% [markdown]
# We build an app for estimating phylogenies with a GTR model

# %%
from cogent3 import get_app

phylo_gtr = get_app("piqtree_phylo", model="GTR", bootstrap_reps=1000)
phylo_gtr = get_app("piq_build_tree", model="GTR", bootstrap_reps=1000)
phylo_gtr

# %% [markdown]
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ doc = [
]

[project.entry-points."cogent3.app"]
piqtree_phylo = "piqtree._app:piqtree_phylo"
piqtree_fit = "piqtree._app:piqtree_fit"
piqtree_random_tree = "piqtree._app:piqtree_random_tree"
piqtree_jc_dists = "piqtree._app:piqtree_jc_dists"
piqtree_nj = "piqtree._app:piqtree_nj"
piqtree_mfinder = "piqtree._app:piqtree_mfinder"
piqtree_consensus = "piqtree._app:piqtree_consensus"
piq_build_tree = "piqtree._app:piq_build_tree"
piq_fit_tree = "piqtree._app:piq_fit_tree"
piq_random_tree = "piqtree._app:piq_random_tree"
piq_jc_distances = "piqtree._app:piq_jc_distances"
piq_nj_tree = "piqtree._app:piq_nj_tree"
piq_model_finder = "piqtree._app:piq_model_finder"
piq_consensus_tree = "piqtree._app:piq_consensus_tree"

[project.entry-points."cogent3.hook"]
quick_tree = "piqtree._app:piqtree_nj"
quick_tree = "piqtree._app:piq_nj_tree"

[tool.setuptools.dynamic]
version = { attr = "piqtree.__version__" }
Expand Down
28 changes: 14 additions & 14 deletions src/piqtree/_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


@composable.define_app
class piqtree_phylo:
class piq_build_tree:
@extend_docstring_from(build_tree)
def __init__(
self,
Expand Down Expand Up @@ -53,7 +53,7 @@ def main(


@composable.define_app
class piqtree_fit:
class piq_fit_tree:
@extend_docstring_from(fit_tree)
def __init__(
self,
Expand Down Expand Up @@ -82,7 +82,7 @@ def main(

@composable.define_app
@extend_docstring_from(random_tree)
def piqtree_random_tree(
def piq_random_tree(
num_taxa: int,
tree_mode: TreeGenMode,
rand_seed: int | None = None,
Expand All @@ -91,7 +91,7 @@ def piqtree_random_tree(


@composable.define_app
class piqtree_jc_dists:
class piq_jc_distances:
@extend_docstring_from(jc_distances)
def __init__(
self,
Expand All @@ -113,7 +113,7 @@ def main(

@composable.define_app
@extend_docstring_from(nj_tree)
def piqtree_nj(
def piq_nj_tree(
dists: c3_types.PairwiseDistanceType,
*,
allow_negative: bool = False,
Expand All @@ -126,15 +126,15 @@ def piqtree_nj(

@composable.define_app
@extend_docstring_from(model_finder)
def piqtree_mfinder(
def piq_model_finder(
aln: c3_types.AlignedSeqsType,
) -> ModelFinderResult | c3_types.SerialisableType:
return model_finder(aln)


@composable.define_app
@extend_docstring_from(consensus_tree)
def piqtree_consensus(
def piq_consensus_tree(
trees: Iterable[cogent3.PhyloNode],
*,
min_support: float = 0.5,
Expand All @@ -143,11 +143,11 @@ def piqtree_consensus(


_ALL_APP_NAMES = [
"piqtree_phylo",
"piqtree_fit",
"piqtree_random_tree",
"piqtree_jc_dists",
"piqtree_nj",
"piqtree_mfinder",
"piqtree_consensus",
"piq_build_tree",
"piq_fit_tree",
"piq_random_tree",
"piq_jc_distances",
"piq_nj_tree",
"piq_model_finder",
"piq_consensus_tree",
]
Loading