Skip to content

Commit

Permalink
TST: add fit_tree and build_tree tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcar17 committed Jul 5, 2024
1 parent 0d857f0 commit 6773e8a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
16 changes: 16 additions & 0 deletions tests/test_build_tree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import piqtree2
import pytest
from cogent3 import load_aligned_seqs, make_tree


@pytest.fixture()
def four_otu(DATA_DIR):
aln = load_aligned_seqs(DATA_DIR / "example.fasta", moltype="dna")
aln = aln.take_seqs(["Human", "Chimpanzee", "Rhesus", "Mouse"])
return aln.omit_gap_pos(allowed_gap_frac=0)


def test_phylogenetic_analysis(four_otu):
expected = make_tree("(Human,Chimpanzee,(Rhesus,Mouse));")
got = piqtree2.build_tree(four_otu, "JC", rand_seed=1)
assert expected.same_topology(got)
18 changes: 18 additions & 0 deletions tests/test_fit_tree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import piqtree2
import pytest
from cogent3 import get_app, load_aligned_seqs, make_tree


@pytest.fixture
def three_otu(DATA_DIR):
aln = load_aligned_seqs(DATA_DIR / "example.fasta", moltype="dna")
aln = aln.take_seqs(["Human", "Rhesus", "Mouse"])
return aln.omit_gap_pos(allowed_gap_frac=0)


def test_piqtree_fit(three_otu):
tree_topology = make_tree(tip_names=three_otu.names)
app = get_app("model", "JC69", tree=tree_topology)
expected = app(three_otu)
got = piqtree2.fit_tree(three_otu, tree_topology, "JC", rand_seed=1)
assert got.params["lnL"] == pytest.approx(expected.lnL)
7 changes: 0 additions & 7 deletions tests/test_phylogenetic_analysis.py

This file was deleted.

0 comments on commit 6773e8a

Please sign in to comment.