# Path: pyPaSWAS/Core/Exceptions.py
# class CudaException(Exception):
#     '''
#     This class is used to warn the user that an exception in the cuda code has occurred.
#     '''
# 
# 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


from pyPaSWAS.Core.Exceptions import CudaException
from Bio.Seq import Seq
from pyPaSWAS.Core.SWSeqRecord import SWSeqRecord
        self.mismatches = 0
        self.query_identity = 0
        self.query_coverage = 0
        self.relative_score = 0
        self.distance = None
        self.rc = False

        #self.logger.debug('Initializing hit OK.')

    @staticmethod
    def _is_a_valid_location(location, sequence_length):
        ''' Verifies wether or not a location is valid.
            A location should contain two integers which should stand for the start of
            the alignment in a sequence (or target) and its stop position. Both start
            and stop should fall between the start and the end of the sequence or target.
        '''
        return isinstance(location, tuple) and len(location) == 2 and isinstance(location[0], int) and \
            isinstance(location[1], int) and 0 <= location[0] < sequence_length and \
            0 <= location[1] < sequence_length and location[0] < location[1]

    def _set_seq_location(self, location):
        ''' Sets the location of the alignment within the sequence.
            This location should be a tuple containing the positions at which the
            alignment begins and ends, respectively.
            Both values should be integers.
        '''
        if self._is_a_valid_location(location, self.sequence_info.original_length):
            #self.logger.debug('Set hit.seqlocation to {0}'.format(location))
            self.seq_location = location
        else:

# Path: pyPaSWAS/Core/Exceptions.py
# class CudaException(Exception):
#     '''
#     This class is used to warn the user that an exception in the cuda code has occurred.
#     '''
# 
# 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/Hit.py
from pyPaSWAS.Core.Exceptions import CudaException
from Bio.Seq import Seq
from pyPaSWAS.Core.SWSeqRecord import SWSeqRecord

        self.mismatches = 0
        self.query_identity = 0
        self.query_coverage = 0
        self.relative_score = 0
        self.distance = None
        self.rc = False

        #self.logger.debug('Initializing hit OK.')

    @staticmethod
    def _is_a_valid_location(location, sequence_length):
        ''' Verifies wether or not a location is valid.
            A location should contain two integers which should stand for the start of
            the alignment in a sequence (or target) and its stop position. Both start
            and stop should fall between the start and the end of the sequence or target.
        '''
        return isinstance(location, tuple) and len(location) == 2 and isinstance(location[0], int) and \
            isinstance(location[1], int) and 0 <= location[0] < sequence_length and \
            0 <= location[1] < sequence_length and location[0] < location[1]

    def _set_seq_location(self, location):
        ''' Sets the location of the alignment within the sequence.
            This location should be a tuple containing the positions at which the
            alignment begins and ends, respectively.
            Both values should be integers.
        '''
        if self._is_a_valid_location(location, self.sequence_info.original_length):
            #self.logger.debug('Set hit.seqlocation to {0}'.format(location))
            self.seq_location = location
        else:

            raise CudaException('Invalid sequence location: {0}, length={1}, {2}'.format(location, len(self.sequence_info.seq),self.sequence_info.original_length ))