# Path: pyPaSWAS/Core/SWSeqRecord.py
# class SWSeqRecord(SeqRecord):
#     '''
#     TODO: Docstring
#     '''
# 
#     start_position = 0
#     distance = 0
#     original_length = 0
# 
#     def __init__(self, seq, identifier, start_position=0, original_length = None, distance = 0, refID = None):
#         super(SWSeqRecord, self).__init__(seq.upper(), identifier)
#         self.start_position = start_position
#         if original_length ==None:
#             self.original_length = len(seq)
#         else:
#             self.original_length = original_length
#         self.distance = distance 
#         self.refID = refID
# 
#     def _compare(self, other):
#         '''
#         TODO: Docstring
#         :param other:
#         '''
#         self.distance = math.sqrt((self.count[0] - other.count[0]) ** 2 + (self.count[1] - other.count[1]) ** 2 +
#                                   (self.count[2] - other.count[2]) ** 2 + (self.count[3] - other.count[3]) ** 2 +
#                                   (self.count[4] - other.count[4]) ** 2)
#         other.distance = self.distance
#         return self.distance
# 
# Path: pyPaSWAS/Core/Exceptions.py
# class InvalidOptionException(Exception):
#     '''
#     This class is used to give a consistent user interface to exceptions that are specific for pyPaSWAS.
#     '''
# 
# Path: pyPaSWAS/Core/Exceptions.py
# class ReaderException(Exception):
#     ''' 
#     This class is used to indicate no sequences left in file.
#     '''


import os.path
from itertools import islice
from Bio import  SeqIO
from Bio.Seq import Seq
from pyPaSWAS.Core.SWSeqRecord import SWSeqRecord
from pyPaSWAS.Core.Exceptions import InvalidOptionException
from pyPaSWAS.Core.Exceptions import ReaderException
            return False

    def _set_path(self, path):
        '''Sets the path to the file which contains the records.'''
        if self._is_a_readable_file(path):
            self.path = path
        else:
            raise InvalidOptionException('{0} is not a file or the program is not allowed to access it.'.format(path))

    def _set_filetype(self):
        '''This method sets the type of the file that will be parsed.
            Should be overridden in each reader class.
        '''
        self.filetype = 'Unknown'

    def _set_limit_length(self, limit_length):
        '''sets the limit of the number of sequences that are to be compared at one time)'''
        try:
            self.limitlength = int(limit_length)
        except ValueError:
            raise InvalidOptionException('Limitlength should be an int but is {0}'.format(limit_length))

    def get_records(self):
        '''Getter for the parsed records'''
        #self.logger.debug('Returning records...')
        return self.records

    def complement_records(self):
        '''Appends the reverse complements to the parsed records '''
        #self.logger.debug('Creating complement sequences...')

# Path: pyPaSWAS/Core/SWSeqRecord.py
# class SWSeqRecord(SeqRecord):
#     '''
#     TODO: Docstring
#     '''
# 
#     start_position = 0
#     distance = 0
#     original_length = 0
# 
#     def __init__(self, seq, identifier, start_position=0, original_length = None, distance = 0, refID = None):
#         super(SWSeqRecord, self).__init__(seq.upper(), identifier)
#         self.start_position = start_position
#         if original_length ==None:
#             self.original_length = len(seq)
#         else:
#             self.original_length = original_length
#         self.distance = distance 
#         self.refID = refID
# 
#     def _compare(self, other):
#         '''
#         TODO: Docstring
#         :param other:
#         '''
#         self.distance = math.sqrt((self.count[0] - other.count[0]) ** 2 + (self.count[1] - other.count[1]) ** 2 +
#                                   (self.count[2] - other.count[2]) ** 2 + (self.count[3] - other.count[3]) ** 2 +
#                                   (self.count[4] - other.count[4]) ** 2)
#         other.distance = self.distance
#         return self.distance
# 
# Path: pyPaSWAS/Core/Exceptions.py
# class InvalidOptionException(Exception):
#     '''
#     This class is used to give a consistent user interface to exceptions that are specific for pyPaSWAS.
#     '''
# 
# Path: pyPaSWAS/Core/Exceptions.py
# class ReaderException(Exception):
#     ''' 
#     This class is used to indicate no sequences left in file.
#     '''


# Path: pyPaSWAS/Core/Readers.py
import os.path
from itertools import islice
from Bio import  SeqIO
from Bio.Seq import Seq
from pyPaSWAS.Core.SWSeqRecord import SWSeqRecord
from pyPaSWAS.Core.Exceptions import InvalidOptionException
from pyPaSWAS.Core.Exceptions import ReaderException

            return False

    def _set_path(self, path):
        '''Sets the path to the file which contains the records.'''
        if self._is_a_readable_file(path):
            self.path = path
        else:
            raise InvalidOptionException('{0} is not a file or the program is not allowed to access it.'.format(path))

    def _set_filetype(self):
        '''This method sets the type of the file that will be parsed.
            Should be overridden in each reader class.
        '''
        self.filetype = 'Unknown'

    def _set_limit_length(self, limit_length):
        '''sets the limit of the number of sequences that are to be compared at one time)'''
        try:
            self.limitlength = int(limit_length)
        except ValueError:
            raise InvalidOptionException('Limitlength should be an int but is {0}'.format(limit_length))

    def get_records(self):
        '''Getter for the parsed records'''
        #self.logger.debug('Returning records...')
        return self.records

    def complement_records(self):
        '''Appends the reverse complements to the parsed records '''
        #self.logger.debug('Creating complement sequences...')

        seqIO = lambda seqIO: SWSeqRecord(Seq(str(seqIO.seq.reverse_complement()), seqIO.seq.alphabet),