#!/usr/bin/env python

"""
Created by: Lee Bergstrand (2017)

Description: The step class.
"""

from modules.functional_element import parse_functional_element


class Step(object):
    """A class representing a step that supports the existence of a genome property."""

    def __init__(self, number, functional_elements=None):
        """
        Creates a new Step object.
        :param number: The position of the step in the step list.
        :param functional_elements: A list of FunctionalElements supporting this step.
        """

        if functional_elements is None:
            functional_elements = set

        self.number = int(number)
        self.id = identifier
        self.name = name
        self.functional_elements = functional_elements

    def __repr__(self):
        repr_data = ['Step ' + str(self.number),
                     'ID: ' + str(self.id),
                     'Name: ' + str(self.name),
                     'Evidences: ' + str(self.functional_elements)]
        return ', '.join(repr_data)


def parse_steps(genome_property_record):
    """
    Parses steps from a genome properties record.
    :param genome_property_record: A list of marker, content tuples representing genome property flat file lines.
    :return: A list of Step objects.
    """
    step_markers = ('SN', 'ID', 'DN', 'RQ', 'EV', 'TG')
    steps = []
    current_step_markers = []
    for marker, content in genome_property_record:
        if marker in step_markers:
            if not marker == 'SN':
                current_step_markers.append((marker, content))
            else:
                step_number = content
                functional_elements = parse_functional_element(current_step_markers)
                steps.append(Step(number=step_number, functional_elements=functional_elements))
                current_step_markers = []
    return steps

@@ -152,17 +152,18 @@
 _element
+s
 %0A
-
 %0A%0Aclass 
@@ -653,62 +653,8 @@
 er)%0A
-        self.id = identifier%0A        self.name = name%0A
     
@@ -782,100 +782,8 @@
 r),%0A
-                     'ID: ' + str(self.id),%0A                     'Name: ' + str(self.name),%0A
     
@@ -883,16 +883,427 @@
 _data)%0A%0A
+    @property%0A    def required(self):%0A        %22%22%22%0A        Checks if the step is required by checking if any of the functional elements are required.%0A        :return: True if the step is required.%0A        %22%22%22%0A        required_step = False%0A%0A        for element in self.functional_elements:%0A            if element.required:%0A                required_step = True%0A                break%0A%0A        return required_step%0A%0A
 %0Adef par
@@ -1650,24 +1650,44 @@
 arkers = %5B%5D%0A
+    step_number = 0%0A
     for mark
@@ -1896,30 +1896,37 @@
     
-step_number = content%0A
+if current_step_markers:%0A    
     
@@ -1983,16 +1983,17 @@
 _element
+s
 (current
@@ -2019,24 +2019,28 @@
             
+  
+  
 steps.append
@@ -2115,32 +2115,36 @@
                 
+    
 current_step_mar
@@ -2149,24 +2149,253 @@
 arkers = %5B%5D%0A
+                else:%0A                    step_number = int(content)%0A%0A    functional_elements = parse_functional_elements(current_step_markers)%0A    steps.append(Step(number=step_number, functional_elements=functional_elements))%0A%0A
     return s

Implement updates to the step class.