useDynLib(GenomicRanges)

import(methods)
importFrom(utils, as.roman, .DollarNames)
importFrom(stats, setNames)
importFrom(stats4, summary)
import(BiocGenerics)
import(S4Vectors)
import(IRanges)
import(GenomeInfoDb)
import(XVector)  # only for the "Views" method for integer vectors, the
                 # XIntegerViews class, and the "viewMins", "viewMaxs", and
                 # "viewSums" methods for XIntegerViews objects


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 classes
###

exportClasses(
    Constraint, Constraint_OR_NULL,
    GenomicRanges, GenomicRangesORmissing,
    GRanges, GPos,
    DelegatingGenomicRanges,
    GNCList,
    GenomicRangesORGRangesList, GRangesList,
    GenomicRangesList, SimpleGenomicRangesList
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S3 methods
###

S3method(duplicated, GenomicRanges)

S3method(sort, GenomicRanges)

S3method(summary, GenomicRanges)

### We also export them thru the export() directive so that (a) they can be
### called directly, (b) tab-completion on the name of the generic shows them,
### and (c) methods() doesn't asterisk them.
export(
    duplicated.GenomicRanges,

    sort.GenomicRanges,

    summary.GenomicRanges
)



### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 methods for generics not defined in GenomicRanges
###

exportMethods(
    length,
    names, "names<-",
    "[", "[<-", "[[", "[[<-", "$", "$<-",
    as.character, as.factor, as.data.frame,
    coerce,
    c,
    show,
    split, unlist,
    range,
    Ops,
    merge,

    ## Generics defined in the stats4 package:
    summary,

    ## Generics defined in the BiocGenerics package:
    duplicated, match,
    is.unsorted, order, sort, rank,
    union, intersect, setdiff,
    start, "start<-", end, "end<-", width, "width<-",
    strand, "strand<-", invertStrand,
    updateObject,

    ## Generics defined in S4Vectors:
    selfmatch,

    ## Generics defined in IRanges:
    elementMetadata, "elementMetadata<-",
    mcols, "mcols<-",
    values, "values<-",
    relistToClass,
    pcompare,
    ranges, "ranges<-",
    score, "score<-",
    findOverlaps, countOverlaps,
    shift, narrow, resize, flank, promoters, restrict, trim,
    reduce, gaps, disjoin, isDisjoint, disjointBins,
    coverage,
    punion, pintersect, psetdiff, pgap,
    precede, follow, nearest, distance, distanceToNearest,
    tile, slidingWindows,
    subset,

    ## Generics defined in GenomeInfoDb:
    seqinfo, "seqinfo<-",
    seqnames, "seqnames<-"
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export non-generic functions
###

export(
    phicoef,

    GRanges, .DollarNames.GenomicRanges, .DollarNames.GRanges,
    GPos,
    GNCList,
    GenomicRangesList, GRangesList,

    makeGRangesFromDataFrame,
    makeGRangesListFromDataFrame,
    makeGRangesListFromFeatureFragments,

    isSmallGenome, absoluteRanges, relativeRanges,
    tileGenome,
    bindAsGRanges, mcolAsRleList, binnedAverage
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 generics defined in GenomicRanges + export corresponding
### methods
###

export(
    ## constraint.R:
    #constraint, "constraint<-",
    checkConstraint,

    ## range-squeezers.R:
    granges, grglist, rglist,

    ## GPos-class.R:
    pos
)

### Exactly the same list as above.
exportMethods(
    #constraint, "constraint<-",
    checkConstraint,
    granges, grglist, rglist,
    pos
)

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Register S3 methods
###

S3method(.DollarNames, GenomicRanges)
S3method(.DollarNames, GRanges)
