コード例 #1
0
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)
コード例 #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()
コード例 #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()
コード例 #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
コード例 #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
コード例 #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
コード例 #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
コード例 #8
0
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]],
コード例 #9
0
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]],
コード例 #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()
コード例 #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()
コード例 #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)
コード例 #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()
コード例 #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()
コード例 #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)