# 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)


import logging
import re
from SDDetector.Entities.Feature import Feature 
#!/usr/bin/env python



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

# 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
import logging
import re
from SDDetector.Entities.Feature import Feature 

#!/usr/bin/env python



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'))