# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# IMPORTS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
importFrom("R.methodsS3", "setMethodS3")
importFrom("R.methodsS3", "getMethodS3")
importFrom("R.oo", "setConstructorS3")
importFrom("R.utils", "use")

## Importing Object classes
importFrom("R.oo", "Package")
importFrom("R.utils", "Arguments")
importFrom("R.utils", "GenericSummary")

## Importing functions
importFrom("R.oo",
           "extend", "attachLocally", "startupMessage")

importFrom("R.cache",
           "getCachePath", "loadCache", "saveCache")

importFrom("R.utils",
           "cat", "capitalize", "copyDirectory", "createLink",
           "enter", "enterf", "exit", "filePath", "getAbsolutePath",
           "getRelativePath", "hpaste", "insert", "isDirectory",
           "isFile", "isPackageInstalled", "isZero", "less",
           "loadObject", "more", "popState", "popTemporaryFile",
           "printf", "pushState", "pushTemporaryFile", "resample",
           "saveObject", "stext", "subplots", "toCamelCase", "wrap")

importFrom("matrixStats",
           "binMeans", "colCumsums", "colDiffs", "colMins", "colMaxs",
           "rowAlls", "rowAnys", "rowMins", "weightedMedian")

importFrom("graphics",
           "abline", "arrows", "axis", "box", "lines",
           "mtext", "par", "plot", "points", "rect", "text")

importFrom("grDevices",
           "col2rgb", "rgb")

importFrom("stats",
           "approx", "cor", "cutree", "density", "end", "mad", "median",
           "na.omit", "quantile", "sd", "start", "weighted.mean")

importFrom("utils",
           "capture.output", "file_test", "getFromNamespace",
           "head", "packageVersion", "str", "tail", "write.table",
           "packageDescription", "install.packages")

importFrom("aroma.light",
           "callNaiveGenotypes", "findPeaksAndValleys", "normalizeTumorBoost")
	   
importFrom("DNAcopy",
           "segments.summary", "smooth.CNA", "CNA", "segment", "getbdry")

importFrom("listenv", "listenv")
importFrom("future", "%<-%", "%seed%", "%label%")
importFrom("parallel", "nextRNGStream")

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# EXPORTS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Export all public methods, that is, those without a preceeding dot
# in their names.
exportPattern("^[^\\.]")


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# S3 methods
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# AbstractCBS
S3method("adjustPloidyScale", "AbstractCBS")
S3method("all.equal", "AbstractCBS")
S3method("as.data.frame", "AbstractCBS")
S3method("clearCalls", "AbstractCBS")
S3method("drawChangePoints", "AbstractCBS")
S3method("drawKnownSegments", "AbstractCBS")
S3method("dropChangePoint", "AbstractCBS")
S3method("dropChangePoints", "AbstractCBS")
S3method("dropRegion", "AbstractCBS")
S3method("dropRegions", "AbstractCBS")
S3method("extractChromosome", "AbstractCBS")
S3method("extractChromosomes", "AbstractCBS")
S3method("extractCNs", "AbstractCBS")
S3method("extractRegion", "AbstractCBS")
S3method("extractRegions", "AbstractCBS")
S3method("extractSegment", "AbstractCBS")
S3method("extractSegments", "AbstractCBS")
S3method("getChangePoints", "AbstractCBS")
S3method("getChromosomeOffsets", "AbstractCBS")
S3method("getChromosomeRanges", "AbstractCBS")
S3method("getChromosomes", "AbstractCBS")
S3method("getLocusData", "AbstractCBS")
S3method("getLocusSignalNames", "AbstractCBS")
S3method("getMeanEstimators", "AbstractCBS")
S3method("getSampleName", "AbstractCBS")
S3method("getSegments", "AbstractCBS")
S3method("getSegmentSizes", "AbstractCBS")
S3method("getSegmentTrackPrefixes", "AbstractCBS")
S3method("hclustCNs", "AbstractCBS")
S3method("mergeThreeSegments", "AbstractCBS")
S3method("mergeTwoSegments", "AbstractCBS")
S3method("nbrOfChangePoints", "AbstractCBS")
S3method("nbrOfChromosomes", "AbstractCBS")
S3method("nbrOfLoci", "AbstractCBS")
S3method("nbrOfSegments", "AbstractCBS")
S3method("normalizeTotalCNs", "AbstractCBS")
S3method("normalizeTotalCNs", "PSCBS")
S3method("ploidy", "AbstractCBS")
S3method("ploidy<-", "AbstractCBS")
S3method("plotTracks", "AbstractCBS")
S3method("print", "AbstractCBS")
S3method("pruneByDP", "AbstractCBS")
S3method("pruneByHClust", "AbstractCBS")
S3method("renameChromosomes", "AbstractCBS")
S3method("report", "AbstractCBS")
S3method("resegment", "AbstractCBS")
S3method("resetSegments", "AbstractCBS")
S3method("sampleCNs", "AbstractCBS")
S3method("sampleName", "AbstractCBS")
S3method("sampleName<-", "AbstractCBS")
S3method("seqOfSegmentsByDP", "AbstractCBS")
S3method("setLocusData", "AbstractCBS")
S3method("setMeanEstimators", "AbstractCBS")
S3method("setPloidy", "AbstractCBS")
S3method("setSampleName", "AbstractCBS")
S3method("setSegments", "AbstractCBS")
S3method("shiftTCN", "AbstractCBS")
S3method("tileChromosomes", "AbstractCBS")
S3method("updateMeans", "AbstractCBS")
S3method("updateMeansTogether", "AbstractCBS")
S3method("writeWIG", "AbstractCBS")


# CBS
S3method("all.equal", "CBS")
S3method("as.character", "CBS")
S3method("as.data.frame", "CBS")
S3method("as.DNAcopy", "CBS")
S3method("c", "CBS")
S3method("callAmplifications", "CBS")
S3method("callArms", "CBS")
S3method("callGainsAndLosses", "CBS")
S3method("callGLAO", "CBS")
S3method("callOutliers", "CBS")
S3method("drawCentromeres", "CBS")
S3method("drawChromosomes", "CBS")
S3method("drawLevels", "CBS")
S3method("estimateDeltaCN", "CBS")
S3method("estimateStandardDeviation", "CBS")
S3method("extractCallsByLocus", "CBS")
S3method("extractChromosomes", "CBS")
S3method("extractCNs", "CBS")
S3method("extractSegmentMeansByLocus", "CBS")
S3method("extractSegments", "CBS")
S3method("extractTotalCNs", "CBS")
S3method("extractWIG", "CBS")
S3method("extractWIG", "AbstractCBS")
S3method("extractWIG", "PSCBS")
S3method("getCallStatistics", "CBS")
S3method("getCallStatisticsByArms", "CBS")
S3method("getChangePoints", "CBS")
S3method("getChromosomeRanges", "CBS")
S3method("getFGA", "CBS")
S3method("getFGG", "CBS")
S3method("getFGL", "CBS")
S3method("getFractionOfGenomeAltered", "CBS")
S3method("getFractionOfGenomeGained", "CBS")
S3method("getFractionOfGenomeLost", "CBS")
S3method("getLocusData", "CBS")
S3method("getLocusSignalNames", "CBS")
S3method("getSegments", "CBS")
S3method("getSegmentTrackPrefixes", "CBS")
S3method("getSignalType", "CBS")
S3method("getSmoothLocusData", "CBS")
S3method("highlightArmCalls", "CBS")
S3method("highlightCalls", "CBS")
S3method("highlightLocusCalls", "CBS")
S3method("isSegmentSplitter", "CBS")
S3method("isWholeChromosomeGained", "CBS")
S3method("isWholeChromosomeLost", "CBS")
S3method("joinSegments", "CBS")
S3method("mergeNonCalledSegments", "CBS")
S3method("mergeTwoSegments", "CBS")
S3method("nbrOfAmplifications", "CBS")
S3method("nbrOfGains", "CBS")
S3method("nbrOfLosses", "CBS")
S3method("plot", "CBS")
S3method("plotTracks", "CBS")
S3method("plotTracksManyChromosomes", "CBS")
S3method("pruneBySdUndo", "CBS")
S3method("resegment", "CBS")
S3method("segmentByCBS", "CBS")
S3method("seqOfSegmentsByDP", "CBS")
S3method("shiftTCN", "CBS")
S3method("signalType", "CBS")
S3method("signalType<-", "CBS")
S3method("subset", "CBS")
S3method("tileChromosomes", "CBS")
S3method("updateBoundaries", "CBS")
S3method("updateMeans", "CBS")
S3method("updateMeansTogether", "CBS")
S3method("writeLocusData", "CBS")
S3method("writeSegments", "CBS")

# CNA
S3method("segmentByCBS", "CNA")

# data.frame
S3method("callSegmentationOutliers", "data.frame")
S3method("encodeCalls", "data.frame")
S3method("dropSegmentationOutliers", "data.frame")
S3method("findLargeGaps", "data.frame")
S3method("gapsToSegments", "data.frame")
S3method("segmentByCBS", "data.frame")
S3method("segmentByNonPairedPSCBS", "data.frame")
S3method("segmentByPairedPSCBS", "data.frame")

# default
S3method("callAllelicBalance", "default")
S3method("callSegmentationOutliers", "default")
S3method("dropSegmentationOutliers", "default")
S3method("exampleData", "default")
S3method("findLargeGaps", "default")
S3method("findNeutralCopyNumberState", "default")
S3method("installDNAcopy", "default")
S3method("segmentByCBS", "default")
S3method("segmentByNonPairedPSCBS", "default")
S3method("segmentByPairedPSCBS", "default")
S3method("weightedQuantile", "default")

# DNAcopy
S3method("as.CBS", "DNAcopy")
S3method("drawLevels", "DNAcopy")
S3method("estimateStandardDeviation", "DNAcopy")
S3method("extractSegmentMeansByLocus", "DNAcopy")
S3method("getChromosomes", "DNAcopy")
S3method("getSampleNames", "DNAcopy")
S3method("nbrOfLoci", "DNAcopy")
S3method("nbrOfSamples", "DNAcopy")
S3method("nbrOfSegments", "DNAcopy")
S3method("writeSegments", "DNAcopy")

# matrix
S3method("seqOfSegmentsByDP", "matrix")

# NonPairedPSCBS
S3method("callROH", "NonPairedPSCBS")
S3method("getLocusData", "NonPairedPSCBS")
S3method("resegment", "NonPairedPSCBS")
S3method("updateMeans", "NonPairedPSCBS")

# numeric
S3method("testROH", "numeric")

# PairedPSCBS
S3method("adjustPloidyScale", "PairedPSCBS")
S3method("applyByRegion", "PairedPSCBS")
S3method("arrowsC1C2", "PairedPSCBS")
S3method("arrowsDeltaC1C2", "PairedPSCBS")
S3method("bootstrapCIs", "PairedPSCBS")
S3method("bootstrapSegmentsAndChangepoints", "PairedPSCBS")
S3method("bootstrapTCNandDHByRegion", "PairedPSCBS")
S3method("calcStatsForCopyNeutralABs", "PairedPSCBS")
S3method("callAB", "PairedPSCBS")
S3method("callABandHighAI", "PairedPSCBS")
S3method("callABandLowC1", "PairedPSCBS")
S3method("callAllelicBalanceByDH", "PairedPSCBS")
S3method("callCopyNeutral", "PairedPSCBS")
S3method("callCopyNeutralByTCNofAB", "PairedPSCBS")
S3method("callExtremeAllelicImbalanceByDH", "PairedPSCBS")
S3method("callGainNeutralLoss", "PairedPSCBS")
S3method("callGNL", "PairedPSCBS")
S3method("callGNLByTCNofAB", "PairedPSCBS")
S3method("callGNLByTCNofABv1", "PairedPSCBS")
S3method("callLOH", "PairedPSCBS")
S3method("callLowC1ByC1", "PairedPSCBS")
S3method("callNTCN", "PairedPSCBS")
S3method("callROH", "PairedPSCBS")
S3method("callROHOneSegment", "PairedPSCBS")
S3method("clearBootstrapSummaries", "PairedPSCBS")
S3method("drawChangePointsC1C2", "PairedPSCBS")
S3method("drawConfidenceBands", "PairedPSCBS")
S3method("drawLevels", "PairedPSCBS")
S3method("estimateDeltaAB", "PairedPSCBS")
S3method("estimateDeltaABBySmallDH", "PairedPSCBS")
S3method("estimateDeltaCN", "PairedPSCBS")
S3method("estimateDeltaLOH", "PairedPSCBS")
S3method("estimateDeltaLOHByMinC1ForNonAB", "PairedPSCBS")
S3method("estimateHighDHQuantileAtAB", "PairedPSCBS")
S3method("estimateKappa", "PairedPSCBS")
S3method("estimateKappaByC1Density", "PairedPSCBS")
S3method("estimateMeanForDH", "PairedPSCBS")
S3method("estimateStdDevForHeterozygousBAF", "PairedPSCBS")
S3method("extractC1C2", "PairedPSCBS")
S3method("extractCallsByLocus", "PairedPSCBS")
S3method("extractCNs", "PairedPSCBS")
S3method("extractDeltaC1C2", "PairedPSCBS")
S3method("extractDhSegment", "PairedPSCBS")
S3method("extractLocusLevelC1C2", "PairedPSCBS")
S3method("extractLocusLevelTCN", "PairedPSCBS")
S3method("extractMinorMajorCNs", "PairedPSCBS")
S3method("extractSegmentDataByLocus", "PairedPSCBS")
S3method("extractSegments", "PairedPSCBS")
S3method("extractTCNAndDHs", "PairedPSCBS")
S3method("findBootstrapSummaries", "PairedPSCBS")
S3method("getBootstrapLocusSets", "PairedPSCBS")
S3method("getChromosomeOffsets", "PairedPSCBS")
S3method("getChromosomeRanges", "PairedPSCBS")
S3method("getLocusData", "PairedPSCBS")
S3method("hasBootstrapSummaries", "PairedPSCBS")
S3method("linesC1C2", "PairedPSCBS")
S3method("linesDeltaC1C2", "PairedPSCBS")
S3method("mergeTwoSegments", "PairedPSCBS")
S3method("plot", "PairedPSCBS")
S3method("plotC1C2", "PairedPSCBS")
S3method("plotDeltaC1C2", "PairedPSCBS")
S3method("plotTracks", "PairedPSCBS")
S3method("plotTracks1", "PairedPSCBS")
S3method("plotTracks2", "PairedPSCBS")
S3method("plotTracksManyChromosomes", "PairedPSCBS")
S3method("pointsC1C2", "PairedPSCBS")
S3method("pointsDeltaC1C2", "PairedPSCBS")
S3method("postsegmentTCN", "PairedPSCBS")
S3method("resegment", "PairedPSCBS")
S3method("segmentByNonPairedPSCBS", "PairedPSCBS")
S3method("segmentByPairedPSCBS", "PairedPSCBS")
S3method("seqOfSegmentsByDP", "PairedPSCBS")
S3method("shiftTCN", "PairedPSCBS")
S3method("tileChromosomes", "PairedPSCBS")
S3method("unTumorBoost", "PairedPSCBS")
S3method("updateMeans", "PairedPSCBS")
S3method("updateMeansC1C2", "PairedPSCBS")
S3method("updateMeansTogether", "PairedPSCBS")

# PSCBS
S3method("as.data.frame", "PSCBS")
S3method("c", "PSCBS")
S3method("drawChangePoints", "PSCBS")
S3method("extractChromosomes", "PSCBS")
S3method("getChangePoints", "PSCBS")
S3method("getLocusData", "PSCBS")
S3method("getLocusSignalNames", "PSCBS")
S3method("getSegments", "PSCBS")
S3method("getSegmentTrackPrefixes", "PSCBS")
S3method("isLocallyPhased", "PSCBS")
S3method("isSegmentSplitter", "PSCBS")
S3method("writeSegments", "PSCBS")
