# Path: SDDetector/Entities/Feature.py
# class Feature(object):
# 
#     def __init__(self, id, seqid, start, end, strand, type):
#         """Feature constructor"""
# 
#         self.id = id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.type = type
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.id,self.seqid,self.start,self.end,self.strand, self.type) == (other.id, other.seqid, other.start, other.end, other.strand, other.type))
# 
#     def __repr__(self):
#         """Feature representation"""
# 
#         return 'Feature: {}-{}-{}-{}-{}-{}'.format(self.type,self.id,self.seqid,self.start,self.end,self.strand)
# 
# Path: SDDetector/Parser/Gff/GffTEParser.py
# class GffTEParser(object):
# 
#     def __init__(self, inputTEGffFile=""):
#         """Constructor"""
# 
#         self.inputTEGffFile = inputTEGffFile
# 
#     def getAllTEs(self):
#         """Return list of all TEs"""
# 
#         lTEs = []
#  
#         with open(self.inputTEGffFile,  'r') as input :
#             for line in input:
#                 if not re.match('^#',line):
#                     values = line.split('\t')
#                     # new match_part 
#                     if values[2] == 'match_part':
#                         m = re.match(r".*ID=([^;]*);.*",values[8])
#                         if m:
#                             strand = 1
#                             if values[6] == '-':
#                                 strand = -1
#                             lTEs.append(Feature(m.group(1),values[0] ,int(values[3]),int(values[4]),strand,'TE'))
#                         else:
#                             raise Exception('Cannot find tag ID for match_part feature in gff file: {}'.format(self.inputTEGffFile))
# 
#         input.close()
#         return lTEs


import unittest
from SDDetector.Entities.Feature import Feature
from SDDetector.Parser.Gff.GffTEParser import GffTEParser
#!/usr/bin/env python



class TestGffTEParser(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_getAllTEs(self):
        """Test getAllTEs method"""

        iGffTEParser = GffTEParser("test-data/TE.gff3")

# Path: SDDetector/Entities/Feature.py
# class Feature(object):
# 
#     def __init__(self, id, seqid, start, end, strand, type):
#         """Feature constructor"""
# 
#         self.id = id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.type = type
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.id,self.seqid,self.start,self.end,self.strand, self.type) == (other.id, other.seqid, other.start, other.end, other.strand, other.type))
# 
#     def __repr__(self):
#         """Feature representation"""
# 
#         return 'Feature: {}-{}-{}-{}-{}-{}'.format(self.type,self.id,self.seqid,self.start,self.end,self.strand)
# 
# Path: SDDetector/Parser/Gff/GffTEParser.py
# class GffTEParser(object):
# 
#     def __init__(self, inputTEGffFile=""):
#         """Constructor"""
# 
#         self.inputTEGffFile = inputTEGffFile
# 
#     def getAllTEs(self):
#         """Return list of all TEs"""
# 
#         lTEs = []
#  
#         with open(self.inputTEGffFile,  'r') as input :
#             for line in input:
#                 if not re.match('^#',line):
#                     values = line.split('\t')
#                     # new match_part 
#                     if values[2] == 'match_part':
#                         m = re.match(r".*ID=([^;]*);.*",values[8])
#                         if m:
#                             strand = 1
#                             if values[6] == '-':
#                                 strand = -1
#                             lTEs.append(Feature(m.group(1),values[0] ,int(values[3]),int(values[4]),strand,'TE'))
#                         else:
#                             raise Exception('Cannot find tag ID for match_part feature in gff file: {}'.format(self.inputTEGffFile))
# 
#         input.close()
#         return lTEs


# Path: tests/test_GffTEParser.py
import unittest
from SDDetector.Entities.Feature import Feature
from SDDetector.Parser.Gff.GffTEParser import GffTEParser

#!/usr/bin/env python



class TestGffTEParser(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_getAllTEs(self):
        """Test getAllTEs method"""

        iGffTEParser = GffTEParser("test-data/TE.gff3")

        lTEs = [Feature('mp1029-1_seq2_RLX-chim_CollD-B-R14-Map20','seq2',17438,17470,-1,'TE'),Feature('mp1029-2_seq2_RLX-chim_CollD-B-R14-Map20','seq2',17438,17783,-1,'TE')]