From b714a0336e7dc01a3fffca62212c8f06aa4c5143 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 16 Apr 2020 15:36:27 -0600 Subject: [PATCH] Make it possible to override gap_element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `'-'` as a gap element doesn't work for my project. Currently, I am doing the following, but it seems pretty hack-ish: ```python import alignment alignment.vocabulary.GAP_ELEMENT = '∅' ``` This pull request would make it possible to define these values when initializing the `Vocabulary`. --- alignment/vocabulary.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/alignment/vocabulary.py b/alignment/vocabulary.py index dd1fabc..35b2d23 100644 --- a/alignment/vocabulary.py +++ b/alignment/vocabulary.py @@ -9,9 +9,13 @@ # Vocabulary ------------------------------------------------------------------ class Vocabulary(object): - def __init__(self): - self.__elementToCode = {GAP_ELEMENT: GAP_CODE} - self.__codeToElement = {GAP_CODE: GAP_ELEMENT} + def __init__(self, gap_code=None, gap_element=None): + if gap_code is None: + gap_code = GAP_CODE + if gap_element is None: + gap_element = GAP_ELEMENT + self.__elementToCode = {gap_element: gap_code} + self.__codeToElement = {gap_code: gap_element} def has(self, element): return element in self.__elementToCode