-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from pbashyal-nmdp/fix_4th_field_comparison
Smart Sort Fix and cleanup
- Loading branch information
Showing
5 changed files
with
113 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ | |
from .pyard import ARD | ||
|
||
__author__ = """NMDP Bioinformatics""" | ||
__version__ = '0.0.13' | ||
__version__ = '0.0.21' |
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,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 0.0.13 | ||
current_version = 0.0.21 | ||
commit = True | ||
tag = True | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import unittest | ||
|
||
from pyard.smart_sort import smart_sort_comparator | ||
|
||
|
||
class TestSmartSort(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
super().setUp() | ||
|
||
def test_same_comparator(self): | ||
allele = "HLA-A*01:01" | ||
self.assertEqual(smart_sort_comparator(allele, allele), 0) | ||
|
||
def test_equal_comparator(self): | ||
allele1 = "HLA-A*01:01" | ||
allele2 = "HLA-A*01:01" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), 0) | ||
|
||
def test_equal_comparator_G(self): | ||
# Should compare without G | ||
allele1 = "HLA-A*01:01G" | ||
allele2 = "HLA-A*01:01" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), 0) | ||
|
||
def test_equal_comparator_NG(self): | ||
# Should compare without N and G | ||
allele1 = "HLA-A*01:01G" | ||
allele2 = "HLA-A*01:01N" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), 0) | ||
|
||
def test_first_field_comparator_le(self): | ||
allele1 = "HLA-A*01:01" | ||
allele2 = "HLA-A*02:01" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), -1) | ||
|
||
def test_first_field_comparator_ge(self): | ||
allele1 = "HLA-A*02:01" | ||
allele2 = "HLA-A*01:01" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), 1) | ||
|
||
def test_second_field_comparator_le(self): | ||
allele1 = "HLA-A*01:01" | ||
allele2 = "HLA-A*01:02" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), -1) | ||
|
||
def test_second_field_comparator_le_smart(self): | ||
allele1 = "HLA-A*01:29" | ||
allele2 = "HLA-A*01:100" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), -1) | ||
|
||
def test_second_field_comparator_ge(self): | ||
allele1 = "HLA-A*01:02" | ||
allele2 = "HLA-A*01:01" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), 1) | ||
|
||
def test_third_field_comparator_le(self): | ||
allele1 = "HLA-A*01:01:01" | ||
allele2 = "HLA-A*01:01:20" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), -1) | ||
|
||
def test_third_field_comparator_le_smart(self): | ||
allele1 = "HLA-A*01:01:29" | ||
allele2 = "HLA-A*01:01:100" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), -1) | ||
|
||
def test_third_field_comparator_ge(self): | ||
allele1 = "HLA-A*01:01:02" | ||
allele2 = "HLA-A*01:01:01" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), 1) | ||
|
||
def test_fourth_field_comparator_le(self): | ||
allele1 = "HLA-A*01:01:01:01" | ||
allele2 = "HLA-A*01:01:01:20" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), -1) | ||
|
||
def test_fourth_field_comparator_le_smart(self): | ||
allele1 = "HLA-A*01:01:01:39" | ||
allele2 = "HLA-A*01:01:01:200" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), -1) | ||
|
||
def test_fourth_field_comparator_ge(self): | ||
allele1 = "HLA-A*01:01:01:30" | ||
allele2 = "HLA-A*01:01:01:09" | ||
self.assertEqual(smart_sort_comparator(allele1, allele2), 1) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |