useDynLib(Biostrings)

import(methods)
importFrom(grDevices, rgb)
importFrom(stats, chisq.test, complete.cases, diffinv, pchisq, setNames)

importFrom(crayon, make_style, black)

import(BiocGenerics)
import(S4Vectors)
import(IRanges)
import(XVector)
import(Seqinfo)


### ==========================================================================
### BASIC CONTAINERS
### --------------------------------------------------------------------------
###   IUPAC_CODE_MAP.R
###   AMINO_ACID_CODE.R
###   GENETIC_CODE.R
###   XStringCodec-class.R
###   seqtype.R
###   XString-class.R
###   XStringSet-class.R
###   XStringSet-comparison.R
###   XStringViews-class.R
###   MaskedXString-class.R
###   XStringSetList-class.R
###   xscat.R

exportClasses(
    XString, BString, DNAString, RNAString, AAString,
    XStringSet, BStringSet, DNAStringSet, RNAStringSet, AAStringSet,
    XStringViews,
    MaskedXString,
    MaskedBString, MaskedDNAString, MaskedRNAString, MaskedAAString,
    XStringSetList,
    BStringSetList, DNAStringSetList, RNAStringSetList, AAStringSetList
)

export(
    ## IUPAC_CODE_MAP.R, AMINO_ACID_CODE.R, GENETIC_CODE.R:
    IUPAC_CODE_MAP, mergeIUPACLetters,
    AMINO_ACID_CODE, AA_ALPHABET, AA_STANDARD, AA_PROTEINOGENIC,
    GENETIC_CODE, RNA_GENETIC_CODE,
    GENETIC_CODE_TABLE, getGeneticCode,

    ## XStringCodec-class.R:
    DNA_BASES, RNA_BASES, DNA_ALPHABET, RNA_ALPHABET,

    ## seqtype.R:
    seqtype, "seqtype<-", get_seqtype_conversion_lookup, alphabet, xscodes,

    ## XString-class.R:
    extract_character_from_XString_by_positions,
    extract_character_from_XString_by_ranges,
    make_XString_from_string,
    BString, DNAString, RNAString, AAString,

    ## XStringSet-class.R:
    make_XStringSet_from_strings,
    BStringSet, DNAStringSet, RNAStringSet, AAStringSet,

    ## MaskedXString-class.R:
    unmasked,

    ## XStringSetList-class.R:
    BStringSetList, DNAStringSetList, RNAStringSetList, AAStringSetList,

    ## xscat.R:
    xscat,

    ## coloring.R:
    update_DNA_palette, update_RNA_palette, update_AA_palette, update_B_palette
)

exportMethods(
    length,
    nchar, width,
    seqtype, "seqtype<-",
    seqinfo, "seqinfo<-",
    updateObject,
    names, "names<-", "[", "[[",
    show, showAsCell,
    relistToClass,
    union, intersect, setdiff, setequal,
    "%in%", match,
    Compare, pcompare, "==", "!=", match,
    coerce, as.character, unlist, as.matrix, as.list, toString, toComplex,
    as.data.frame,
    windows, subseq, threebands, "subseq<-", collapse, gaps,
    Views,
    unmasked, maskedwidth, maskedratio, masks, "masks<-"
)


### ==========================================================================
### UTILITIES
### --------------------------------------------------------------------------
###   XStringSet-io.R
###   letter.R
###   getSeq.R
###   letterFrequency.R
###   dinucleotideFrequencyTest.R
###   lcsuffix.R
###   chartr.R
###   reverse.R
###   translate.R
###   toComplex.R
###   replaceAt.R
###   replaceLetterAt.R
###   injectHardMask.R
###   padAndClip.R
###   strsplit-methods.R
###   misc.R

export(
    ## XStringSet-io.R:
    readBStringSet, readDNAStringSet, readRNAStringSet, readAAStringSet,
    fasta.index, fasta.seqlengths, fastq.seqlengths, fastq.geometry,
    writeXStringSet,
    saveXStringSet,

    ## letter.R:
    letter,

    ## getSeq.R:
    getSeq,

    ## letterFrequency.R:
    letterFrequency,
    letterFrequencyInSlidingView,
    alphabetFrequency, hasOnlyBaseLetters, uniqueLetters,
    consensusMatrix, consensusString,
    mkAllStrings,
    oligonucleotideFrequency,
    dinucleotideFrequency, trinucleotideFrequency,
    nucleotideFrequencyAt,
    oligonucleotideTransitions,
    twoWayAlphabetFrequency,

    ## dinucleotideFrequencyTest.R
    dinucleotideFrequencyTest,

    ## lcsuffix.R:
    lcprefix, lcsuffix,

    ## chartr.R:
    replaceAmbiguities,

    ## reverseComplement.R:
    complement, reverseComplement,

    ## translate.R:
    translate, codons,

    ## toComplex.R:
    toComplex,

    ## replaceAt.R:
    extractAt, replaceAt,

    ## replaceLetterAt.R:
    replaceLetterAt, .inplaceReplaceLetterAt,

    ## injectHardMask.R:
    injectHardMask,

    ## padAndClip.R:
    padAndClip, stackStrings,

    ## strsplit-methods.R:
    strsplit,

    ## misc.R:
    N50
)

exportMethods(
    length, names, "[", "[[", rep,
    show,
    "==", "!=", duplicated, is.unsorted, order, sort, rank,
    coerce, as.character, as.matrix, as.list, toString, toComplex,
    letter,
    substr, substring,
    letterFrequency,
    letterFrequencyInSlidingView,
    alphabetFrequency, hasOnlyBaseLetters, uniqueLetters,
    consensusMatrix, consensusString,
    oligonucleotideFrequency,
    nucleotideFrequencyAt,
    dinucleotideFrequencyTest,
    lcprefix, lcsuffix,
    chartr,
    reverse, complement, reverseComplement,
    codons, translate,
    extractAt, replaceAt,
    replaceLetterAt,
    injectHardMask,
    strsplit, unstrsplit
)


### ==========================================================================
### STRING MATCHING
### --------------------------------------------------------------------------
###   MIndex-class.R
###   lowlevel-matching.R
###   match-utils.R
###   matchPattern.R
###   matchLRPatterns.R
###   trimLRPatterns.R
###   matchProbePair.R
###   matchPWM.R
###   findPalindromes.R
###   PDict-class.R
###   matchPDict.R

exportClasses(
    #SparseList,
    MIndex, ByPos_MIndex, MIndexList,
    PreprocessedTB, Twobit, ACtree2,
    PDict3Parts,
    PDict, TB_PDict, MTB_PDict, Expanded_TB_PDict
)

export(
    ## MIndex-class.R
    width0, startIndex, endIndex,
    extractAllMatches,

    ## lowlevel-matching.R
    neditStartingAt, neditEndingAt, neditAt,
    isMatchingStartingAt, isMatchingEndingAt, isMatchingAt,
    which.isMatchingStartingAt, which.isMatchingEndingAt, which.isMatchingAt,
    hasLetterAt,

    ## match-utils.R
    mismatch, nmatch, nmismatch,

    ## matchPattern.R
    gregexpr2, matchPattern, countPattern, vmatchPattern, vcountPattern,

    ## maskMotif.R
    maskMotif, mask,

    ## matchLRPatterns.R
    matchLRPatterns,

    ## trimLRPatterns.R
    trimLRPatterns,

    ## matchProbePair.R
    matchProbePair,

    ## matchPWM.R
    maxWeights, minWeights, maxScore, minScore, unitScale,
    PWM, PWMscoreStartingAt, matchPWM, countPWM,

    ## findPalindromes.R
    findPalindromes, palindromeArmLength,
    palindromeLeftArm, palindromeRightArm,

    ## PDict-class.R + matchPDict.R
    tb, tb.width, nnodes, hasAllFlinks, computeAllFlinks,
    patternFrequency, PDict,
    matchPDict, countPDict, whichPDict,
    vmatchPDict, vcountPDict, vwhichPDict
)

exportMethods(
    initialize,
    length, names, "names<-", show, "[[",
    startIndex, endIndex, unlist,
    neditStartingAt, neditEndingAt,
    isMatchingStartingAt, isMatchingEndingAt,
    mismatch, nmatch, nmismatch,
    coverage,
    matchPattern, countPattern, vcountPattern,
    maskMotif,
    matchLRPatterns, trimLRPatterns,
    matchProbePair,
    maxWeights, minWeights, maxScore, minScore,
    PWM, matchPWM, countPWM,
    findPalindromes,
    palindromeArmLength, palindromeLeftArm, palindromeRightArm,

    tb, tb.width, nnodes, hasAllFlinks, computeAllFlinks,
    head, tail,
    patternFrequency, PDict,
    matchPDict, countPDict, whichPDict,
    vmatchPDict, vcountPDict, vwhichPDict
)


### ==========================================================================
### STRING ALIGNMENT
### --------------------------------------------------------------------------
###   XStringQuality-class.R
###   QualityScaledXStringSet.R
###   MultipleAlignment.R

exportClasses(
    XStringQuality, PhredQuality, SolexaQuality, IlluminaQuality,
    QualityScaledXStringSet,
    QualityScaledBStringSet, QualityScaledDNAStringSet,
    QualityScaledRNAStringSet, QualityScaledAAStringSet
)

export(
    ## XStringQuality-class.R:
    PhredQuality, SolexaQuality, IlluminaQuality,
    encoding,

    ## QualityScaledXStringSet.R:
    quality,
    QualityScaledBStringSet, QualityScaledDNAStringSet,
    QualityScaledRNAStringSet, QualityScaledAAStringSet,
    readQualityScaledDNAStringSet, writeQualityScaledXStringSet,

    ## MultipleAlignment.R:
    DNAMultipleAlignment,
    RNAMultipleAlignment,
    AAMultipleAlignment,
    rowmask, "rowmask<-",
    colmask, "colmask<-",
    maskGaps,
    maskednrow, maskedncol, maskeddim,
    readDNAMultipleAlignment,
    readRNAMultipleAlignment,
    readAAMultipleAlignment,
    consensusViews,
    write.phylip
)

exportMethods(
    length, "[", rep,
    coerce, as.vector, as.character, as.matrix, toString,
    show, summary,
    start, end, width,
    Views,
    quality, encoding,
    parallel_slot_names,
    parallelVectorNames,
    nchar, names, "names<-", "[[", windows,
    consensusMatrix, consensusString,
    alphabetFrequency, as.list
)


### ==========================================================================
### MISCELLANEOUS
### --------------------------------------------------------------------------
###   longestConsecutive.R

export(
    longestConsecutive
)


### ==========================================================================
### STUFF THAT HAS MOVED TO THE pwalign PACKAGE
### --------------------------------------------------------------------------

S3method(print, moved_to_pwalign_pkg)

