### Import libraries functions
import(methods)
import(plyr)
import(reshape2)
import(Biostrings)
import(IRanges)
import(GenomicRanges)
import(gridExtra)
import(BSgenome)
import(RColorBrewer)
import(cummeRbund)
import(ggplot2)
import(VennDiagram)
import(DBI)
import(DRIMSeq)
import(tximport)

### Import compiled code
useDynLib(IsoformSwitchAnalyzeR)

### Import specific functions
importFrom("grDevices", "dev.off", "hcl", "pdf", "png")
importFrom("graphics", "lines", "plot", "text", "title")
importFrom("stats", "dnorm", "na.omit", "optim", "p.adjust", "pchisq", "pnorm", "pt", "qnorm", "qt", "setNames", "weighted.mean", "wilcox.test")
importFrom("utils", "read.table", "setTxtProgressBar", "txtProgressBar")
importFrom('GenomeInfoDb','seqlevels','seqlevels<-')
importFrom('grid','grid.newpage')
importFrom('grid','pushViewport')
importFrom('grid','viewport')
importFrom('grid','grid.layout')
importFrom('DBI','dbGetQuery','dbDriver')
importFrom("stats", "as.formula", "model.matrix")
importFrom("edgeR", "calcNormFactors")
importFrom("stats", "prop.test")
importFrom("futile.logger","flog.threshold")

### Export functions from my R package
# Creating list
export('createSwitchAnalyzeRlist')
export('subsetSwitchAnalyzeRlist')

# Import data
export('importCufflinksCummeRbund')
export('importCufflinksFiles')
export('importGTF')
export('importIsoformExpression')
export('importRdata')
export('preFilter')

# Test isoform switches
export('isoformSwitchTestDRIMSeq')
export('isoformSwitchTest')
export('extractSwitchSummary')
export('extractSwitchOverlap')
export('extractTopSwitches')
export('extractCalibrationStatus')


# Analyze functional potential
export('CDSSet')
export('getCDS')
export('extractSequence')
export('analyzeORF')

export('analyzeCPAT')
export('analyzePFAM')
export('analyzeSignalP')

# Splicing analysis
export('analyzeAlternativeSplicing')
export('analyzeIntronRetention')
export('extractSplicingSummary')
export('extractSplicingEnrichment')
export('extractSplicingEnrichmentComparison')
export('extractSplicingGenomeWide')


# Switch consequences analysis
export('analyzeSwitchConsequences')
export('extractConsequenceSummary')
export('extractConsequenceEnrichment')
export('extractConsequenceEnrichmentComparison')
export('extractConsequenceGenomeWide')
export('extractGenomeWideAnalysis')


# Plotting
export('switchPlotTranscript')

export('switchPlotGeneExp')
export('switchPlotIsoExp')
export('switchPlotIsoUsage')

export('switchPlot')
export('switchPlotTopSwitches')

# High level function
export('isoformSwitchAnalysisPart1')
export('isoformSwitchAnalysisPart2')
export('isoformSwitchAnalysisCombined')

# other tools
export('extractExpressionMatrix')
export('prepareCuffExample')
export('isoformToGeneExp')

### Export classes
exportClasses("switchAnalyzeRlist")
#exportClasses("CDSSet")
#exportClasses("SpliceRList")

### Overload generic functions to work with my classes
S3method(dim,switchAnalyzeRlist)
S3method(nrow,switchAnalyzeRlist)
S3method(ncol,switchAnalyzeRlist)
S3method(head,switchAnalyzeRlist)
S3method(tail,switchAnalyzeRlist)
S3method(show,switchAnalyzeRlist)

#S3method(subset,switchAnalyzeRlist)
S3method(summary,switchAnalyzeRlist)
