Skip to content

Commit 24ba639

Browse files
committed
Add is_null method to ARD
1 parent 2553832 commit 24ba639

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pyard/ard.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,15 @@ def is_shortnull(self, allele):
529529
"""
530530
return allele in self.shortnulls and self._config["reduce_shortnull"]
531531

532+
def is_null(self, allele):
533+
"""
534+
Check if allele is a null allele.
535+
536+
@param allele: Allele to check for null
537+
@return: boolean indicating whether allele is null or not
538+
"""
539+
return allele.endswith("N") and not self.is_mac(allele)
540+
532541
def is_exp_allele(self, allele):
533542
"""
534543
Test if allele is valid as a shortening (WHO rules)

tests/test_pyard.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,17 @@ def test_cache_info(self):
186186
another_ard._redux_allele.cache_info().maxsize, higher_cache_size
187187
)
188188
self.assertEqual(another_ard.redux.cache_info().maxsize, higher_cache_size)
189+
190+
def test_is_null(self):
191+
# a null allele
192+
allele = "A*01:01N"
193+
self.assertTrue(self.ard.is_null(allele))
194+
# not null allele
195+
allele = "A*01:01"
196+
self.assertFalse(self.ard.is_null(allele))
197+
# MACs ending with N shouldn't be called as Nulls
198+
allele = "A*01:MN"
199+
self.assertFalse(self.ard.is_null(allele))
200+
# MACs shouldn't be called as Nulls
201+
allele = "A*01:AB"
202+
self.assertFalse(self.ard.is_null(allele))

0 commit comments

Comments
 (0)