-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support site_positions_to_trim on MSA trim method
- Loading branch information
Showing
3 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.1.0" | ||
__version__ = "2.1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pytest | ||
import numpy as np | ||
|
||
from Bio import AlignIO | ||
from clipkit.msa import MSA | ||
|
||
def get_biopython_msa(file_path, file_format="fasta"): | ||
return AlignIO.read(open(file_path), file_format) | ||
|
||
|
||
class TestMSA(object): | ||
def test_clipkit_msa_from_bio_msa(self): | ||
bio_msa = get_biopython_msa("tests/unit/examples/simple.fa") | ||
msa = MSA.from_bio_msa(bio_msa) | ||
assert msa.header_info == [{'id': '1', 'name': '1', 'description': '1'}, {'id': '2', 'name': '2', 'description': '2'}, {'id': '3', 'name': '3', 'description': '3'}, {'id': '4', 'name': '4', 'description': '4'}, {'id': '5', 'name': '5', 'description': '5'}] | ||
expected_seq_records = np.array([ | ||
['A', '-', 'G', 'T', 'A', 'T'], | ||
['A', '-', 'G', '-', 'A', 'T'], | ||
['A', '-', 'G', '-', 'T', 'A'], | ||
['A', 'G', 'A', '-', 'T', 'A'], | ||
['A', 'C', 'a', '-', 'T', '-'] | ||
]) | ||
np.testing.assert_equal(msa.seq_records, expected_seq_records) | ||
|
||
def test_trim_by_provided_site_positions_np_array(self): | ||
bio_msa = get_biopython_msa("tests/unit/examples/simple.fa") | ||
msa = MSA.from_bio_msa(bio_msa) | ||
sites_to_trim = np.array([1, 4]) | ||
msa.trim(site_positions_to_trim=sites_to_trim) | ||
expected_sites_kept = np.array([ | ||
['A', 'G', 'T', 'T'], | ||
['A', 'G', '-', 'T'], | ||
['A', 'G', '-', 'A'], | ||
['A', 'A', '-', 'A'], | ||
['A', 'a', '-', '-'] | ||
]) | ||
np.testing.assert_equal(msa.sites_kept, expected_sites_kept) | ||
|
||
def test_trim_by_provided_site_positions_list(self): | ||
bio_msa = get_biopython_msa("tests/unit/examples/simple.fa") | ||
msa = MSA.from_bio_msa(bio_msa) | ||
sites_to_trim = [1, 4] | ||
msa.trim(site_positions_to_trim=sites_to_trim) | ||
expected_sites_kept = np.array([ | ||
['A', 'G', 'T', 'T'], | ||
['A', 'G', '-', 'T'], | ||
['A', 'G', '-', 'A'], | ||
['A', 'A', '-', 'A'], | ||
['A', 'a', '-', '-'] | ||
]) | ||
np.testing.assert_equal(msa.sites_kept, expected_sites_kept) |