useDynLib(IRanges)

import(methods)
importFrom(utils, head, read.table, tail, stack)
importFrom(stats, start, end, update, var, cov, cor, sd, median, quantile, mad,
           IQR, smoothEnds, runmed, window, "window<-", aggregate, xtabs,
           na.omit, na.exclude, complete.cases)

exportClasses(
    characterORNULL,
    Annotated,
    Sequence,
    DataTable, DataTableORNULL,
    SimpleList, CompressedList,
    Ranges, RangesORmissing,
    IRanges, NormalIRanges,
    IntervalTree,
    Grouping, H2LGrouping, Dups,
    Partitioning, PartitioningByEnd, PartitioningByWidth,
    Binning,
    SharedVector, SharedVector_Pool,
    SharedRaw, SharedRaw_Pool,
    SharedInteger, SharedDouble,
    Views,
    XVector, XRaw, XInteger, XDouble,
    GroupedIRanges, XVectorList, XRawList,
    XIntegerViews,
    Rle, RleViews,
    MaskCollection,
    AtomicList, CompressedAtomicList, SimpleAtomicList,
    LogicalList, CompressedLogicalList, SimpleLogicalList,
    IntegerList, CompressedIntegerList, SimpleIntegerList,
    NumericList, CompressedNumericList, SimpleNumericList,
    ComplexList, CompressedComplexList, SimpleComplexList,
    CharacterList, CompressedCharacterList, SimpleCharacterList,
    RawList, CompressedRawList, SimpleRawList,
    RleList, CompressedRleList, SimpleRleList,
    RangesList, SimpleRangesList,
    IRangesList, CompressedIRangesList, SimpleIRangesList,
    NormalIRangesList, CompressedNormalIRangesList, SimpleNormalIRangesList,
    GappedRanges,
    RleViewsList, SimpleRleViewsList,
    DataFrame,
    DataFrameList, SimpleDataFrameList,
    SplitDataFrameList, CompressedSplitDataFrameList, SimpleSplitDataFrameList,
    RangedData, RangedDataList, FilterRules, RDApplyParams, RangesMatching,
    RangedSelection)

export(
    ## Non-generic functions:
    setValidity2, new2,
    isTRUEorFALSE, isSingleInteger, isSingleNumber, isSingleString,
    isSingleIntegerOrNA, isSingleNumberOrNA, isSingleStringOrNA,
    isConstant,
    normargShift,
    normargWeight,
    safeExplode,
    strsplitAsListOfIntegerVectors,
    svn.time,
    solveUserSEW0, IRanges, solveUserSEW,
    successiveIRanges,
    whichAsIRanges,
    asNormalIRanges,
    H2LGrouping, Dups, PartitioningByEnd, PartitioningByWidth, Binning,
    RangedData, RangedDataList,
    RangedSelection,
    FilterRules, RDApplyParams,
    RangesList,
    IRangesList,
    RleViewsList,
    MaskCollection.show_frame,
    Mask,
    read.gapMask,
    read.agpMask,
    read.liftMask,
    read.rmMask,
    read.trfMask,
    ##read.chain,
    SharedVector.compare,
    SharedVector.copy,
    SharedRaw,
    SharedRaw.readInts, SharedRaw.writeInts,
    SharedRaw.read, SharedRaw.write,
    SharedRaw.readComplexes,
    #SharedInteger, SharedInteger.read, SharedInteger.write,
    #SharedDouble, SharedDouble.read, SharedDouble.write,
    XRaw, XInteger, XDouble, XNumeric,
    newViews, successiveViews,
    SimpleList, DataFrame,
    LogicalList, IntegerList, NumericList, ComplexList,
    CharacterList, RawList, RleList,
    DataFrameList, SplitDataFrameList,
    coverage.normargWidth,

    ## Generic endomorphism functions
    endoapply,
    mendoapply,

    ## Casting apply functions and the like
    seqapply, mseqapply, tseqapply, seqsplit,
    
    ## Generic functions in the Sequence API:
    elementType, elementLengths,
    metadata, elementMetadata, "metadata<-", "elementMetadata<-",
    seqselect, "seqselect<-",
    mapply,
    Map,
    isEmpty,

    ## Generic functions in the Ranges API:
    width,
    mid,
    "start<-",
    "width<-",
    "end<-",
    shift,
    restrict,
    narrow,
    resize,
    threebands,
    reduce,
    gaps,
    findOverlaps, overlap, countOverlaps, countOverlap,
    subsetByOverlaps,
    nearest, precede, follow,
    reflect,
    flank,
    punion, pintersect, psetdiff, pgap,
    disjoin, disjointBins,
    ##map,

    ## Generic functions in the Rle API:
    Rle, runLength, runValue, nrun, "runLength<-", "runValue<-", shiftApply,
    findRange, findRun,
    paste,

    ## Generic functions in the Grouping API:
    nobj, grouplength, members, vmembers, togroup, togrouplength,
    high2low, low2high, grouprank, togrouprank,

    ## Generic functions in the GappedRanges API:
    ngap,

    ## Generic functions in the DataTable API:
    as.env,
    
    ## Other generic functions:
    isNormal,
    isDisjoint,
    whichFirstNotNormal,
    IntervalTree,
    xvcopy,
    reverse,
    coverage,
    nir_list,
    active, "active<-",
    maskedwidth, maskedratio,
    collapse,
    ranges, "ranges<-",
    subseq, "subseq<-",
    subject, Views, subviews, trim,
    slice,
    values, "values<-",
    columnMetadata, "columnMetadata<-",
    runmean, runsum, runwtsum, runq,
    viewApply, viewMins, viewMaxs, viewSums, viewMeans,
    viewWhichMins, viewWhichMaxs, viewRangeMins, viewRangeMaxs,
    cbind, rbind, table, xtabs,
    rangedData, "rangedData<-", applyFun, "applyFun<-", applyParams,
    "applyParams<-", simplify, "simplify<-",
    ##excludePattern, "excludePattern<-",
    filterRules, "filterRules<-",
    reducerFun, "reducerFun<-", reducerParams, "reducerParams<-",
    rdapply,
    universe, "universe<-", space, score, "score<-",
    matchMatrix, queryHits, subjectHits
)

exportMethods(
    ## Methods for generics defined elsewhere:
    lapply, sapply, tapply,
    "[", "[<-", "[[", "[[<-", "$",
    "==", "!=", "<=", ">=", "<", ">",
    Ops, Math, Math2, Summary, Complex,
    coerce,
    show,
    summary,
    length, "length<-",
    names, "names<-",
    nrow, NROW, ncol, NCOL, dim,
    rownames, colnames, dimnames,
    "rownames<-", "colnames<-", "dimnames<-",
    duplicated, unique,
    order, sort, rank, is.unsorted,
    rev,
    rep, rep.int,
    head, tail,
    start, end,
    min, max, range,
    pmax, pmin, pmax.int, pmin.int, diff,
    mean, var, cov, cor, sd, median, quantile, mad, IQR, smoothEnds, runmed,
    subset, window, "window<-", aggregate,
    nchar, substr, substring, chartr, tolower, toupper, sub, gsub,
    levels, "levels<-", nlevels,
    as.vector,
    as.logical, as.integer, as.numeric, as.complex, as.character, as.raw,
    as.factor,
    as.matrix,
    as.data.frame,
    as.list,
    as.table,
    toString,
    unlist, stack,
    update,
    append,
    "!", which,
    c,
    union, intersect, setdiff,
    split, splitRanges,
    eval, with, within,
    t,
    is.na, na.omit, na.exclude, complete.cases,
    "%in%", by, match,
    Reduce, Filter, Find, Position,
    updateObject,

    ## Methods for generics defined in this package:
    endoapply,
    mendoapply,
    seqselect, "seqselect<-",
    mapply,
    Map,
    isEmpty,
    width,
    "start<-",
    "width<-",
    "end<-",
    isNormal,
    isDisjoint,
    whichFirstNotNormal,
    shift,
    restrict,
    narrow,
    resize,
    threebands,
    reduce,
    gaps,
    punion, pintersect, psetdiff,
    xvcopy,
    reverse,
    coverage,
    nobj, grouplength, members, vmembers, togroup, togrouplength,
    high2low, low2high, grouprank, togrouprank,
    ngap,
    nir_list,
    active, "active<-",
    desc, "desc<-",
    maskedwidth, maskedratio,
    collapse,
    subseq, "subseq<-",
    subject, Views, subviews, trim,
    Rle, runLength, runValue, nrun, "runLength<-", "runValue<-", shiftApply,
    findRange,
    runmean, runsum, runwtsum, runq,
    viewApply, viewMins, viewMaxs, viewSums, viewMeans,
    viewWhichMins, viewWhichMaxs
)
