# Path: SDDetector/Entities/Gene.py
# class Gene(object):
# 
# 
#     def __init__(self, id, seqid, start, end, strand, lTranscripts=[]):
#         """Gene constructor"""
# 
#         self.id = id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.lTranscripts = lTranscripts
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.id,self.seqid,self.start,self.end,self.strand, self.lTranscripts) == (other.id, other.seqid, other.start, other.end, other.strand, other.lTranscripts))
# 
#     def __repr__(self):
#         """Gene representation"""
# 
#         return 'Gene: {}-{}-{}-{}-{}-{}'.format(self.id,self.seqid,self.start,self.end,self.strand, self.lTranscripts)
# 
# Path: SDDetector/Entities/Transcript.py
# class Transcript(object):
# 
# 
#     def __init__(self, id, seqid, start, end, strand, gene_id, lCDS=[]):
#         """Transcript constructor"""
# 
#         self.id = id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.gene_id = gene_id
#         self.lCDS = lCDS
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.id,self.seqid,self.start,self.end,self.strand,self.lCDS, self.gene_id) == (other.id, other.seqid, other.start, other.end, other.strand, other.lCDS, other.gene_id))
# 
#     def __repr__(self):
#         """Transcript representation"""
# 
#         return 'Transcript: {}-{}-{}-{}-{}-{}-{}'.format(self.id,self.seqid,self.start,self.end,self.strand,self.lCDS, self.gene_id)
# 
# Path: SDDetector/Entities/CDS.py
# class CDS(object):
# 
# 
#     def __init__(self,cds_id, seqid, start, end, strand, transcript_id):
#         """Transcript constructor"""
# 
#         self.cds_id = cds_id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.transcript_id = transcript_id
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.cds_id,self.seqid,self.start,self.end,self.strand,self.transcript_id) == (other.cds_id,other.seqid, other.start, other.end, other.strand, other.transcript_id))
# 
#     def __repr__(self):
#         """CDS representation"""
# 
#         return 'CDS: {}'.format(self.cds_id)


import logging
import re
from SDDetector.Entities.Gene import Gene
from SDDetector.Entities.Transcript import Transcript
from SDDetector.Entities.CDS import CDS
        """Get all genes"""
        
        return self.lGenes

    def _parse(self):
        """Parse the gff file"""

        dGenes = {}
        dTranscripts = {}
        dCDS = {}

        with open(self.inputGffFile, 'r') as input:
            for line in input:
                if not re.match('^#', line):
                    line = line.rstrip('\n')
                    values = line.split('\t')

                    if values[2] == 'gene':
                        id = self._getFeatureTagValue('ID',values[8])
                        currentGene = Gene(id, values[0], int(values[3]), int(values[4]), self._getStrand(values[6]))
                        dGenes[id] = currentGene
                        self.lGenes.append(currentGene)
                        
                    if values[2] == 'mRNA':
                        id = self._getFeatureTagValue('ID',values[8])
                        gene_id = self._getFeatureTagValue('Parent', values[8])
                        #gene_id = '{}_G'.format(id)
                        #currentGene = Gene(gene_id, values[0], int(values[3]), int(values[4]), self._getStrand(values[6]))
                        #dGenes[gene_id] = currentGene
                        #self.lGenes.append(currentGene)

# Path: SDDetector/Entities/Gene.py
# class Gene(object):
# 
# 
#     def __init__(self, id, seqid, start, end, strand, lTranscripts=[]):
#         """Gene constructor"""
# 
#         self.id = id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.lTranscripts = lTranscripts
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.id,self.seqid,self.start,self.end,self.strand, self.lTranscripts) == (other.id, other.seqid, other.start, other.end, other.strand, other.lTranscripts))
# 
#     def __repr__(self):
#         """Gene representation"""
# 
#         return 'Gene: {}-{}-{}-{}-{}-{}'.format(self.id,self.seqid,self.start,self.end,self.strand, self.lTranscripts)
# 
# Path: SDDetector/Entities/Transcript.py
# class Transcript(object):
# 
# 
#     def __init__(self, id, seqid, start, end, strand, gene_id, lCDS=[]):
#         """Transcript constructor"""
# 
#         self.id = id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.gene_id = gene_id
#         self.lCDS = lCDS
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.id,self.seqid,self.start,self.end,self.strand,self.lCDS, self.gene_id) == (other.id, other.seqid, other.start, other.end, other.strand, other.lCDS, other.gene_id))
# 
#     def __repr__(self):
#         """Transcript representation"""
# 
#         return 'Transcript: {}-{}-{}-{}-{}-{}-{}'.format(self.id,self.seqid,self.start,self.end,self.strand,self.lCDS, self.gene_id)
# 
# Path: SDDetector/Entities/CDS.py
# class CDS(object):
# 
# 
#     def __init__(self,cds_id, seqid, start, end, strand, transcript_id):
#         """Transcript constructor"""
# 
#         self.cds_id = cds_id
#         self.seqid = seqid
#         self.start = start
#         self.end = end
#         self.strand = strand
#         self.transcript_id = transcript_id
# 
#     def __eq__(self, other):
#         """Equality on all args"""
#       
#         return ((self.cds_id,self.seqid,self.start,self.end,self.strand,self.transcript_id) == (other.cds_id,other.seqid, other.start, other.end, other.strand, other.transcript_id))
# 
#     def __repr__(self):
#         """CDS representation"""
# 
#         return 'CDS: {}'.format(self.cds_id)


# Path: SDDetector/Parser/Gff/GffGeneParser.py
import logging
import re
from SDDetector.Entities.Gene import Gene
from SDDetector.Entities.Transcript import Transcript
from SDDetector.Entities.CDS import CDS

        """Get all genes"""
        
        return self.lGenes

    def _parse(self):
        """Parse the gff file"""

        dGenes = {}
        dTranscripts = {}
        dCDS = {}

        with open(self.inputGffFile, 'r') as input:
            for line in input:
                if not re.match('^#', line):
                    line = line.rstrip('\n')
                    values = line.split('\t')

                    if values[2] == 'gene':
                        id = self._getFeatureTagValue('ID',values[8])
                        currentGene = Gene(id, values[0], int(values[3]), int(values[4]), self._getStrand(values[6]))
                        dGenes[id] = currentGene
                        self.lGenes.append(currentGene)
                        
                    if values[2] == 'mRNA':
                        id = self._getFeatureTagValue('ID',values[8])
                        gene_id = self._getFeatureTagValue('Parent', values[8])
                        #gene_id = '{}_G'.format(id)
                        #currentGene = Gene(gene_id, values[0], int(values[3]), int(values[4]), self._getStrand(values[6]))
                        #dGenes[gene_id] = currentGene
                        #self.lGenes.append(currentGene)

                        currentTranscript = Transcript(id, values[0], int(values[3]), int(values[4]), self._getStrand(values[6]), gene_id)