def METHOD_NAME(self, transcript_dict, epitopes):
    extracted_peptides = {}
    for index, epitope in sorted(epitopes.items()):
        p = re.compile('^(.+)_pos([0-9]+)_len([0-9]+)$')
        identifier = p.search(index).group(1)
        original_position = p.search(index).group(2)
        length = p.search(index).group(3)
        full_sequence = transcript_dict[identifier]
        #find all occurrences of the epitope in the full sequence
        occurrences = [n for n in range(len(full_sequence)) if full_sequence.find(epitope, n) == n]
        #epitope occurs once in the full sequence
        if len(occurrences) == 1:
            new_position = occurrences[0]
        #epitope occurs multiple times
        else:
            #find the occurence that is closest to the original positon and use that
            new_position = min(occurrences, key=lambda x:abs(original_position-1-x))
        length = int(length)
        n_mer = int(self.n_mer)
        if len(full_sequence) <= n_mer:
            extracted_sequence = full_sequence
        else:
            wingspan = (n_mer - length) / 2
            start = math.ceil(new_position - wingspan)
            end = math.ceil(new_position + length + wingspan)
            if start < 0:
                remainder = math.fabs(start)
                end += remainder
            if end > len(full_sequence):
                remainder = end - len(full_sequence)
                start -= remainder
            if start < 0:
                start = 0
            extracted_sequence = full_sequence[int(start):int(end)]
        exists = False
        for other_index, other_extracted_sequence in extracted_peptides.items():
            if other_extracted_sequence == extracted_sequence:
                print("Sequence for item %s is identical to sequence for item %s. Skipping %s" % (index, other_index, index))
                exists = True
        if not exists:
            extracted_peptides[index] = extracted_sequence
    return extracted_peptides