# Path: crumbs/utils/tags.py
# UPPERCASE = 'upper'
# 
# LOWERCASE = 'lower'
# 
# SWAPCASE = 'swap'
# 
# Path: crumbs/seq/seq.py
# def get_description(seq):
#     seq_class = seq.kind
#     seq = seq.object
#     if seq_class == SEQITEM:
#         title_items = seq.lines[0].split(' ', 1)
#         desc = title_items[1] if len(title_items) == 2 else None
#     elif seq_class == SEQRECORD:
#         desc = seq.description
#         if desc == '<unknown description>':  # BioPython default
#             return None
#     return desc
# 
# def get_name(seq):
#     if 'SeqRecord' in seq.__class__.__name__:
#         seq_class = SEQRECORD
#     else:
#         seq_class = seq.kind
#         seq = seq.object
#     if seq_class == SEQITEM:
#         name = seq.name
#     elif seq_class == SEQRECORD:
#         name = seq.id
#     return name
# 
# def get_str_seq(seq):
#     seq_class = seq.kind
#     if seq_class == SEQITEM:
#         seq = seq.object.lines[1].strip()
#     elif seq_class == SEQRECORD:
#         seq = str(seq.object.seq)
#     return seq.strip()
# 
# def copy_seq(seqwrapper, seq=None, name=None):
#     seq_class = seqwrapper.kind
#     seq_obj = seqwrapper.object
#     if seq_class == SEQITEM:
#         seq = _copy_seqitem(seqwrapper, seq=seq, name=name)
#     elif seq_class == SEQRECORD:
#         seq_obj = _copy_seqrecord(seq_obj, seq=seq, name=name, id_=name)
#         seq = SeqWrapper(kind=seqwrapper.kind, object=seq_obj,
#                          file_format=seqwrapper.file_format)
#     return seq


import re
import itertools
from multiprocessing import Pool
from crumbs.utils.tags import UPPERCASE, LOWERCASE, SWAPCASE
from crumbs.seq.seq import get_description, get_name, get_str_seq, copy_seq
    It returns a list of (start, end) tuples'''
    start = 0
    for is_upper, group in itertools.groupby(string, lambda x: x.isupper()):
        group = list(group)
        end = start + len(group) - 1
        if is_upper:
            yield start, end
        start = end + 1


class ChangeCase(object):
    'It changes the sequence case.'

    def __init__(self, action):
        'The initiator'
        if action not in (UPPERCASE, LOWERCASE, SWAPCASE):
            msg = 'Action should be: uppercase, lowercase or invertcase'
            raise ValueError(msg)
        self.action = action

    def __call__(self, seqs):
        'It changes the case of the seqrecords.'
        action = self.action
        processed_seqs = []
        for seq in seqs:
            str_seq = get_str_seq(seq)
            if action == UPPERCASE:
                str_seq = str_seq.upper()
            elif action == LOWERCASE:
                str_seq = str_seq.lower()

# Path: crumbs/utils/tags.py
# UPPERCASE = 'upper'
# 
# LOWERCASE = 'lower'
# 
# SWAPCASE = 'swap'
# 
# Path: crumbs/seq/seq.py
# def get_description(seq):
#     seq_class = seq.kind
#     seq = seq.object
#     if seq_class == SEQITEM:
#         title_items = seq.lines[0].split(' ', 1)
#         desc = title_items[1] if len(title_items) == 2 else None
#     elif seq_class == SEQRECORD:
#         desc = seq.description
#         if desc == '<unknown description>':  # BioPython default
#             return None
#     return desc
# 
# def get_name(seq):
#     if 'SeqRecord' in seq.__class__.__name__:
#         seq_class = SEQRECORD
#     else:
#         seq_class = seq.kind
#         seq = seq.object
#     if seq_class == SEQITEM:
#         name = seq.name
#     elif seq_class == SEQRECORD:
#         name = seq.id
#     return name
# 
# def get_str_seq(seq):
#     seq_class = seq.kind
#     if seq_class == SEQITEM:
#         seq = seq.object.lines[1].strip()
#     elif seq_class == SEQRECORD:
#         seq = str(seq.object.seq)
#     return seq.strip()
# 
# def copy_seq(seqwrapper, seq=None, name=None):
#     seq_class = seqwrapper.kind
#     seq_obj = seqwrapper.object
#     if seq_class == SEQITEM:
#         seq = _copy_seqitem(seqwrapper, seq=seq, name=name)
#     elif seq_class == SEQRECORD:
#         seq_obj = _copy_seqrecord(seq_obj, seq=seq, name=name, id_=name)
#         seq = SeqWrapper(kind=seqwrapper.kind, object=seq_obj,
#                          file_format=seqwrapper.file_format)
#     return seq


# Path: crumbs/seq/utils/seq_utils.py
import re
import itertools
from multiprocessing import Pool
from crumbs.utils.tags import UPPERCASE, LOWERCASE, SWAPCASE
from crumbs.seq.seq import get_description, get_name, get_str_seq, copy_seq

    It returns a list of (start, end) tuples'''
    start = 0
    for is_upper, group in itertools.groupby(string, lambda x: x.isupper()):
        group = list(group)
        end = start + len(group) - 1
        if is_upper:
            yield start, end
        start = end + 1


class ChangeCase(object):
    'It changes the sequence case.'

    def __init__(self, action):
        'The initiator'
        if action not in (UPPERCASE, LOWERCASE, SWAPCASE):
            msg = 'Action should be: uppercase, lowercase or invertcase'
            raise ValueError(msg)
        self.action = action

    def __call__(self, seqs):
        'It changes the case of the seqrecords.'
        action = self.action
        processed_seqs = []
        for seq in seqs:
            str_seq = get_str_seq(seq)
            if action == UPPERCASE:
                str_seq = str_seq.upper()
            elif action == LOWERCASE:
                str_seq = str_seq.lower()

            elif action == SWAPCASE: