bmlsa/tests/bmlsa/test_aligner.py
Harrison 7e3f43434e
Some checks failed
ydeng/bmlsa/pipeline/head There was a failure building this commit
Added documentation
2023-04-28 12:44:59 -05:00

52 lines
1.6 KiB
Python

import pytest
from Bio import SeqIO
from bmlsa.aligner import align_many_to_one_ssw
from bmlsa.cli import DEFAULT_ALIGNMENT_PARAMETERS
from bmlsa.datatypes import QuerySequence
from collections.abc import Iterable
@pytest.fixture
def reference_sequence():
return str(
list(SeqIO.parse("tests/resources/NC_045512_coding.fasta", "fasta"))[0].seq
)
@pytest.fixture
def queries():
return [
QuerySequence(
"ORF10",
"ATGGGCTATATAAACGTTTTCGCTTTTCCGTTTACGATATATAGTCTACTCTTGTGCAGAAT"
"GAATTCTCGTAACTACATAGCACAAGTAGATGTAGTTAACTTTAATCTCACATAG",
start=29558,
end=29674,
)
]
def test_align_many_to_one_returns_data(reference_sequence, queries):
results = align_many_to_one_ssw(
reference_sequence, queries, **DEFAULT_ALIGNMENT_PARAMETERS["BLASTp"]
)
assert isinstance(results, Iterable)
def test_align_many_to_one_returns_correct_data_structure(reference_sequence, queries):
results = align_many_to_one_ssw(
reference_sequence, queries, **DEFAULT_ALIGNMENT_PARAMETERS["BLASTp"]
)
for original, aligned_seq in results:
assert isinstance(original, QuerySequence)
assert isinstance(aligned_seq, QuerySequence)
def test_align_many_to_one_returns_correct_data(reference_sequence, queries):
results = align_many_to_one_ssw(
reference_sequence, queries, **DEFAULT_ALIGNMENT_PARAMETERS["BLASTp"]
)
for original, aligned_seq in results:
assert original.start == aligned_seq.start
assert original.end == aligned_seq.end