# Path: logparser/MoLFI/main/org/core/chromosome/template.py
# class Template:
#     """ An object representing the smallest element of a chromosome which is a template
#         Template is a list of strings
#     """
# 
#     def __init__(self, p_template: List[str]):
#         """ The constructor of the Class Template
#         initialize the object with a list of strings
#         and initialize the frequency and specificity with 0.0
#         and an empty list that will contain the line number matching the template
#         """
#         self.token = p_template
#         self.specificity = 0.0
#         self.matched_lines = []
#         self.changed = True
# 
#     def get_length(self):
#         """ Gets the number of strings in the list    
#         """
#         return len(self.token)
# 
#     def to_string(self):
#         """ Returns the template's token as one string
#         """
#         s = "[ "
#         for i in self.token:
#             s = s+i+' '
# 
#         s = s + ']'
#         return s
# 
#     def is_changed(self):
#         """ Returns the status of the template (changed or did not change)
#         """
#         return self.changed
# 
#     def set_changed(self, p_changed : bool):
#         """ Sets the status of a template to True if one of its tokens changes,
#         else the status is False (not changed)
#         """
#         self.changed = p_changed


from .template import Template




class Chromosome:
    """ A chromosome in this class is a dictionary
        key: int
        value: List[Templates]
    """

    def __init__(self, p_templates: dict()):
        """ The constructor with an attribute of type List of Template
        :param p_templates: a dictionary of Template
        """
        self.templates = p_templates
        self.coverage = 0

    def add_template(self, template: Template):
        """ Adds a template to the chromosome
        
        :param template: an object of type Template
        :return: the template will be added to the corresponding cluster
        with key = len(template)
        """
        key = template.get_length()
        if key in self.templates.keys():
            self.templates[key].append(template)
        else:
            self.templates[key] = []
            self.templates[key].append(template)


# Path: logparser/MoLFI/main/org/core/chromosome/template.py
# class Template:
#     """ An object representing the smallest element of a chromosome which is a template
#         Template is a list of strings
#     """
# 
#     def __init__(self, p_template: List[str]):
#         """ The constructor of the Class Template
#         initialize the object with a list of strings
#         and initialize the frequency and specificity with 0.0
#         and an empty list that will contain the line number matching the template
#         """
#         self.token = p_template
#         self.specificity = 0.0
#         self.matched_lines = []
#         self.changed = True
# 
#     def get_length(self):
#         """ Gets the number of strings in the list    
#         """
#         return len(self.token)
# 
#     def to_string(self):
#         """ Returns the template's token as one string
#         """
#         s = "[ "
#         for i in self.token:
#             s = s+i+' '
# 
#         s = s + ']'
#         return s
# 
#     def is_changed(self):
#         """ Returns the status of the template (changed or did not change)
#         """
#         return self.changed
# 
#     def set_changed(self, p_changed : bool):
#         """ Sets the status of a template to True if one of its tokens changes,
#         else the status is False (not changed)
#         """
#         self.changed = p_changed


# Path: logparser/MoLFI/main/org/core/chromosome/chromosome.py
from .template import Template




class Chromosome:
    """ A chromosome in this class is a dictionary
        key: int
        value: List[Templates]
    """

    def __init__(self, p_templates: dict()):
        """ The constructor with an attribute of type List of Template
        :param p_templates: a dictionary of Template
        """
        self.templates = p_templates
        self.coverage = 0

    def add_template(self, template: Template):
        """ Adds a template to the chromosome
        
        :param template: an object of type Template
        :return: the template will be added to the corresponding cluster
        with key = len(template)
        """
        key = template.get_length()
        if key in self.templates.keys():
            self.templates[key].append(template)
        else:
            self.templates[key] = []
            self.templates[key].append(template)


    def delete_template(self, template: Template):
