useDynLib(rtracklayer, .registration = TRUE)

import(zlibbioc)

importFrom("stats", offset)

importFrom(utils, count.fields)

importFrom("XML", getNodeSet, xmlValue, xmlAttrs, htmlTreeParse,
           xmlInternalTreeParse, parseURI, newXMLNode, xmlChildren,
           addChildren, removeChildren, saveXML)

importFrom("RCurl", curlUnescape, fileUpload, getCurlHandle, getForm, getURL,
           postForm)

importFrom("BiocGenerics", rbind, cbind, lapply, sapply, unique)

importClassesFrom("IRanges",
                  RangedData, RangedDataList, DataTable,
                  Annotated, Vector, List, DataTableORNULL, characterORNULL,
                  RangedSelection, SimpleList, DataFrame)

importFrom("IRanges", DataFrame, IRanges, RangedDataList, RangedData,
           RangesList, Rle, RangedSelection, RleList, isSingleString,
           recycleIntegerArg, recycleNumericArg, isSingleStringOrNA,
           isTRUEorFALSE, isSingleNumberOrNA, PartitioningByWidth, shift)

importMethodsFrom("IRanges", elementLengths, window,
                  start, end, width, range,
                  "start<-", "end<-", "width<-",
                  split, lapply, sapply, unlist, unique,
                  as.vector, as.list, as.data.frame,
                  colnames,  rownames,
                  "colnames<-","rownames<-",
                  ranges, values, score,
                  "ranges<-", "values<-", "score<-",
                  space, universe, metadata,
                  "universe<-", "metadata<-",
                  isDisjoint, queryHits, findOverlaps, reduce, nrow, summary,
                  resize, mcols, "mcols<-", togroup)

importClassesFrom("GenomicRanges", GenomicRanges, GRanges, GRangesList,
                  GIntervalTree)

importFrom("GenomicRanges", GRanges, GRangesList, Seqinfo, genome, "genome<-",
           merge)

importMethodsFrom("GenomicRanges", seqnames, seqlengths, strand,  "strand<-",
                  seqinfo, "seqinfo<-", seqlevels, "seqlevels<-", coerce)

importFrom("Biostrings", get_seqtype_conversion_lookup, masks, writeXStringSet,
           "masks<-", DNAStringSet)

importFrom("BSgenome", installed.genomes, releaseDate, organism,
           providerVersion, provider, bsapply)

importFrom("Rsamtools", path, indexTabix, headerTabix, scanTabix, bgzip,
           TabixFile, index, asBam)

importMethodsFrom("Rsamtools", readGAlignmentsFromBam)

importClassesFrom("Rsamtools", RsamtoolsFile)

importFrom("tools", file_path_as_absolute, file_path_sans_ext)

exportClasses(BrowserSession, BrowserView, BrowserViewList,
              UCSCSession, UCSCView,
              UCSCData, TrackLine, BasicTrackLine, GraphTrackLine,
              Bed15TrackLine, UCSCTrackModes, BigWigSelection,
              UCSCSchema, Quickload, QuickloadGenome)

## File classes
exportClasses(RTLFile, CompressedFile, GFFFile, UCSCFile, BEDFile, WIGFile,
              ChainFile, FastaFile, GFF1File, GFF2File, GFF3File, BEDGraphFile,
              BED15File, GTFFile, GVFFile, BigWigFile, TwoBitFile)

exportMethods(activeView, "activeView<-", blocks, browseGenome,
              browserSession, "browserSession<-",
              browserView, browserViews,
              close, export, export.bed, export.bed15,
              export.bedGraph, export.gff, export.gff1, export.gff2,
              export.gff3, export.ucsc, export.wig, export.bw,
              export.2bit,
              import, import.bed, import.bed15, import.bedGraph,
              import.gff, import.gff1, import.gff2, import.gff3,
              import.ucsc, import.wig, import.bw, import.chain, import.2bit,
              "sequence<-", "track<-",
              track, trackNames, "trackNames<-", getTable,
              tableNames, trackName, "trackName<-",
              tableName, "tableName<-",
              ucscTrackModes, "ucscTrackModes<-",
              ucscSchema,
              coerce, initialize,
              show, summary, "[", ucscTableQuery,
              genome, "genome<-", chrom, "chrom<-", range, "range<-",
              visible, "visible<-",
              liftOver, offset, reversed,
              nrow, formatDescription,
              referenceSequence, "referenceSequence<-",
              asBED, asGFF,
              split,
              ## from IRanges
              start, end, "start<-", "end<-",
              score, "score<-",
              as.data.frame, space, mcols,
              ## from GenomicRanges
              strand, seqinfo, "seqinfo<-",
              ## from BSgenome
              organism, releaseDate
              )

export(genomeBrowsers, start, end, strand, "start<-", "end<-", width, "width<-",
       ranges, values, GenomicData, GenomicSelection,
       score, "score<-", as.data.frame, space,
       ucscGenomes, BigWigSelection, GRangesForUCSCGenome,
       GRangesForBSGenome, summary, seqinfo, genome, "genome<-",
       uri, Quickload, quickload, QuickloadGenome,
       organism, releaseDate, mcols, wigToBigWig,
       SeqinfoForBSGenome, SeqinfoForUCSCGenome, resource, path)

export(GFFFile, UCSCFile, BEDFile, WIGFile,
       ChainFile, FastaFile, GFF1File, GFF2File, GFF3File, BEDGraphFile,
       BED15File, GTFFile, GVFFile, BigWigFile, TwoBitFile)
