def test_tigger(alignment_text):
    a = Alignment()
    a.parse(alignment_text)
    bitsets, slow_rates = slow_tiger(a)
    tigger = TigerDNA()
    tigger.build_bitsets(a)
    fast_rates = tigger.calc_rates()
    assert np.allclose(slow_rates, fast_rates)
Example #2
0
def test_subset():
    a = Alignment()
    a.parse(INTERLEAVED)

    ss = FakeSubset([0, 1, 5, 7])
    b = SubsetAlignment(a, ss)
    assert b.sequence_length == len(ss.columns)
    for i, c in enumerate(ss.columns):
        assert (b.data[:, i] == a.data[:, c]).all()
Example #3
0
def test_subset():
    a = Alignment()
    a.parse(INTERLEAVED)

    ss = FakeSubset([0, 1, 5, 7])
    b = SubsetAlignment(a, ss)
    assert b.sequence_length == len(ss.columns)
    for i, c in enumerate(ss.columns):
        assert (b.data[:, i] == a.data[:, c]).all()
Example #4
0
def test_load_and_save_phy(phyml_path):
    a = Alignment()
    a.read(phyml_path)
    b = Alignment()
    b.parse(write_and_get_stream(a))

    assert (a.data == b.data).all()
    assert a.species == b.species
Example #5
0
def test_simple():
    a = Alignment()
    a.parse(BASIC)
    assert a.species_count == 5
    assert a.sequence_length == 10
    assert a.data.shape == (5, 10)

    b = Alignment()
    b.parse(write_and_get_stream(a))

    assert (a.data == b.data).all()
    assert a.species == b.species
Example #6
0
def test_load_and_save_phy(phyml_path):
    a = Alignment()
    a.read(phyml_path)
    b = Alignment()
    b.parse(write_and_get_stream(a))

    assert (a.data == b.data).all()
    assert a.species == b.species
Example #7
0
def test_simple():
    a = Alignment()
    a.parse(BASIC)
    assert a.species_count == 5
    assert a.sequence_length == 10
    assert a.data.shape == (5, 10)

    b = Alignment()
    b.parse(write_and_get_stream(a))

    assert (a.data == b.data).all()
    assert a.species == b.species
import pytest
import os
from partfinder import morph_tiger
from partfinder.alignment import Alignment

MORPH_DATA = """
5 25
tax1        1101100000111111021200001
tax2        110110010?0011100212?0000
tax3        ?11210?1010?00101000?010?
tax4        1021011201000010111111111
tax5        10?1011311000120121211111

"""

MORPH_ALIGN = Alignment()
MORPH_ALIGN.parse(MORPH_DATA)


def test_set_parts():
    set_parts = morph_tiger.create_set_parts(MORPH_ALIGN)
    assert set_parts == [
        [[0, 1, 3, 4]],
        [[3, 4], [0, 1, 2]],
        [[0, 1], [2], [3]],
        [[0, 1, 3, 4], [2]],
        [[3, 4], [0, 1, 2]],
        [[0, 1, 2], [3, 4]],
        [[0, 1], [3, 4]],
        [[0], [1, 2], [3], [4]],
        [[0, 1, 2, 3], [4]],
import pytest
import os
from partfinder import morph_tiger
from partfinder.alignment import Alignment

MORPH_DATA = """
5 25
tax1        1101100000111111021200001
tax2        110110010?0011100212?0000
tax3        ?11210?1010?00101000?010?
tax4        1021011201000010111111111
tax5        10?1011311000120121211111

"""

MORPH_ALIGN = Alignment()
MORPH_ALIGN.parse(MORPH_DATA)


def test_set_parts():
    set_parts = morph_tiger.create_set_parts(MORPH_ALIGN)
    assert set_parts == [[[0, 1, 3, 4]], [[3, 4], [0, 1, 2]],
                         [[0, 1], [2], [3]], [[0, 1, 3, 4], [2]],
                         [[3, 4], [0, 1, 2]], [[0, 1, 2], [3, 4]],
                         [[0, 1], [3, 4]], [[0], [1, 2], [3], [4]],
                         [[0, 1, 2, 3], [4]], [[0], [2, 3, 4]],
                         [[1, 2, 3, 4], [0]], [[1, 3, 4], [0]],
                         [[2, 3, 4], [0, 1]], [[2, 3], [0, 1, 4]],
                         [[0, 1, 2, 3], [4]], [[1, 2, 3, 4], [0]],
                         [[0, 1], [2, 3, 4]], [[2], [3], [0, 1, 4]],
                         [[2], [0, 1, 3, 4]], [[2], [3], [0, 1, 4]],
Example #10
0
def test_too_many_species(caplog):
    a = Alignment()
    with pytest.raises(AlignmentError):
        a.parse(TOO_MANY_SPECIES)
    assert "Phyml format error" in caplog.text()
Example #11
0
def test_too_few_species(caplog):
    a = Alignment()
    with pytest.raises(AlignmentError):
        a.parse(TOO_FEW_SPECIES)
    assert "too many species" in caplog.text()
Example #12
0
def test_interleaved():
    a = Alignment()
    a.parse(INTERLEAVED)
    assert a.species_count == 5
    assert a.sequence_length == 30
    assert a.data.shape == (5, 30)
Example #13
0
def test_too_many_species(caplog):
    a = Alignment()
    with pytest.raises(AlignmentError):
        a.parse(TOO_MANY_SPECIES)
    assert "Phyml format error" in caplog.text()
Example #14
0
def test_too_few_species(caplog):
    a = Alignment()
    with pytest.raises(AlignmentError):
        a.parse(TOO_FEW_SPECIES)
    assert "too many species" in caplog.text()
Example #15
0
def test_interleaved():
    a = Alignment()
    a.parse(INTERLEAVED)
    assert a.species_count == 5
    assert a.sequence_length == 30
    assert a.data.shape == (5, 30)