Skip to content

Commit

Permalink
update sytanx for new test
Browse files Browse the repository at this point in the history
  • Loading branch information
dengzq1234 committed May 30, 2024
1 parent 7739f27 commit c1533ac
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/test_ncbiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,33 +164,33 @@ def test_get_topology():
def test_merged_id():
ncbi = NCBITaxa(dbfile=DATABASE_PATH)
t1 = ncbi.get_lineage(649756)
self.assertEqual(t1, [1, 131567, 2, 1783272, 1239, 186801, 3085636, 186803, 207244, 649756])
assert t1 == [1, 131567, 2, 1783272, 1239, 186801, 3085636, 186803, 207244, 649756]
t2 = ncbi.get_lineage("649756")
self.assertEqual(t2, [1, 131567, 2, 1783272, 1239, 186801, 3085636, 186803, 207244, 649756])
assert t2 == [1, 131567, 2, 1783272, 1239, 186801, 3085636, 186803, 207244, 649756]


def test_ignore_unclassified():
# normal case
tree = PhyloTree('((9606, 9598), 10090);')
tree.annotate_ncbi_taxa(taxid_attr='name', ignore_unclassified=False)
self.assertEqual(tree.common_ancestor(['9606', '9598']).props.get("sci_name"), 'Homininae')
self.assertEqual(tree.common_ancestor(['9606', '10090']).props.get("sci_name"), 'Euarchontoglires')

assert tree.common_ancestor(['9606', '9598']).props.get("sci_name") == 'Homininae'
assert tree.common_ancestor(['9606', '10090']).props.get("sci_name") == 'Euarchontoglires'

# empty case
tree = PhyloTree('((9606, sample1), 10090);')
tree.annotate_ncbi_taxa(taxid_attr='name', ignore_unclassified=False)
self.assertEqual(tree.common_ancestor(['9606', 'sample1']).props.get("sci_name"), '')
self.assertEqual(tree.common_ancestor(['9606', 'sample1']).props.get("rank"), 'Unknown')
self.assertEqual(tree.common_ancestor(['9606', '10090']).props.get("sci_name"), '')


assert tree.common_ancestor(['9606', 'sample1']).props.get("sci_name") == ''
assert tree.common_ancestor(['9606', 'sample1']).props.get("rank") == 'Unknown'
assert tree.common_ancestor(['9606', '10090']).props.get("sci_name") == ''

# ignore unclassified
tree = PhyloTree('((9606, sample1), 10090);')
tree.annotate_ncbi_taxa(taxid_attr='name', ignore_unclassified=True)
self.assertEqual(tree.common_ancestor(['9606', 'sample1']).props.get("sci_name"), 'Homo sapiens')
self.assertEqual(tree.common_ancestor(['9606', 'sample1']).props.get("rank"), 'species')
self.assertEqual(tree.common_ancestor(['9606', '10090']).props.get("sci_name"), 'Euarchontoglires')

t1 = ncbi.get_lineage(649756)
assert t1 == [1, 131567, 2, 1783272, 1239, 186801, 3085636, 186803, 207244, 649756]
assert tree.common_ancestor(['9606', 'sample1']).props.get("sci_name") == 'Homo sapiens'
assert tree.common_ancestor(['9606', 'sample1']).props.get("rank") == 'species'
assert tree.common_ancestor(['9606', '10090']).props.get("sci_name") == 'Euarchontoglires'


t2 = ncbi.get_lineage('649756')
assert t2 == [1, 131567, 2, 1783272, 1239, 186801, 3085636, 186803, 207244, 649756]

0 comments on commit c1533ac

Please sign in to comment.