Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pyard/ard.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,15 @@ def is_shortnull(self, allele):
"""
return allele in self.shortnulls and self._config["reduce_shortnull"]

def is_null(self, allele):
"""
Check if allele is a null allele.

@param allele: Allele to check for null
@return: boolean indicating whether allele is null or not
"""
return allele.endswith("N") and not self.is_mac(allele)

def is_exp_allele(self, allele):
"""
Test if allele is valid as a shortening (WHO rules)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_pyard.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,22 @@ def test_cache_info(self):
another_ard._redux_allele.cache_info().maxsize, higher_cache_size
)
self.assertEqual(another_ard.redux.cache_info().maxsize, higher_cache_size)

def test_is_null(self):
# a null allele
allele = "A*01:01N"
self.assertTrue(self.ard.is_null(allele), msg="A Null Allele")
# not null allele
allele = "A*01:01"
self.assertFalse(self.ard.is_null(allele), msg="not null allele")
# MACs ending with N shouldn't be called as Nulls
allele = "A*01:MN"
self.assertFalse(
self.ard.is_null(allele),
msg="MACs ending with N shouldn't be called as Nulls",
)
# MACs shouldn't be called as Nulls
allele = "A*01:AB"
self.assertFalse(
self.ard.is_null(allele), msg="MACs shouldn't be called as Nulls"
)