Skip to content

Commit 6a33ae2

Browse files
committed
Create validate method
1 parent 3a2155e commit 6a33ae2

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

pyard/pyard.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,7 @@ def redux_gl(self, glstring: str, redux_type: VALID_REDUCTION_TYPES) -> str:
276276

277277
validate_reduction_type(redux_type)
278278

279-
try:
280-
self.isvalid_gl(glstring)
281-
except InvalidAlleleError as e:
282-
raise InvalidTypingError(
283-
f"{glstring} is not valid GL String. \n {e.message}", e
284-
)
279+
self.validate(glstring)
285280

286281
if re.search(r"\^", glstring):
287282
return self.sorted_unique_gl(
@@ -363,6 +358,21 @@ def redux_gl(self, glstring: str, redux_type: VALID_REDUCTION_TYPES) -> str:
363358

364359
return self.redux(glstring, redux_type)
365360

361+
def validate(self, glstring):
362+
"""
363+
Validates GL String
364+
Raise an exception if not valid.
365+
366+
:param glstring: GL String to validate
367+
:return: boolean indicating success
368+
"""
369+
try:
370+
return self.isvalid_gl(glstring)
371+
except InvalidAlleleError as e:
372+
raise InvalidTypingError(
373+
f"{glstring} is not valid GL String. \n {e.message}", e
374+
)
375+
366376
def is_XX(self, glstring: str, loc_antigen: str = None, code: str = None) -> bool:
367377
if loc_antigen is None or code is None:
368378
if ":" in glstring:

0 commit comments

Comments
 (0)