import(methods)

importFrom(utils, download.file, untar, unzip, read.table, write.table,
                  browseURL, URLencode)
importFrom(stats, setNames)
importFrom(tools, R_user_dir, file_path_as_absolute, md5sum)

importFrom(R.utils, gunzip)
importFrom(curl, has_internet)
importFrom(httr, GET, HEAD, config, user_agent, stop_for_status,
                 content, headers)
importFrom(xml2, read_html)
importFrom(rvest, html_elements, html_text)
importFrom(xtable, xtable)
importFrom(jsonlite, fromJSON)
import(tibble)

importFrom(BiocGenerics, add_suffix)
import(S4Vectors)
import(IRanges)
importFrom(GenomeInfoDb, list_ftp_dir)
import(Biostrings)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S3 methods for S3 generics not defined in igblastr
###

S3method(print, alignment_summary)
S3method(print, auxdata_md5sum_df)
S3method(print, c_region_dbs_df)
S3method(print, fmt7footer)
S3method(print, fmt7record)
S3method(print, germline_dbs_df)
S3method(print, hit_table)
S3method(print, igblast_info)
S3method(print, igblastn_raw_output)
S3method(print, igdata_info)
S3method(print, outfmt7_specifiers)
S3method(print, query_details)
S3method(print, subregion_sequence_details)
S3method(print, VDJ_junction_details)
S3method(print, VDJ_rearrangement_summary)

S3method(summary, query_details)

### 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(
    print.alignment_summary,
    print.auxdata_md5sum_df,
    print.c_region_dbs_df,
    print.fmt7footer,
    print.fmt7record,
    print.germline_dbs_df,
    print.hit_table,
    print.igblast_info,
    print.igblastn_raw_output,
    print.igdata_info,
    print.outfmt7_specifiers,
    print.query_details,
    print.subregion_sequence_details,
    print.VDJ_junction_details,
    print.VDJ_rearrangement_summary,

    summary.query_details
)


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

export(
    ## translate_codons.R:
    remove_gaps,
    extract_codons,
    translate_codons,

    ## allele2gene.R:
    allele2gene,

    ## parse_imgt_fasta_headers.R:
    parse_imgt_fasta_headers,

    ## ndm_data-IO.R:
    validate_ndm_rows,
    read_ndm_data,
    write_ndm_data,
    same_alleles_annot,

    ## compute_V_gene_delineations.R:
    compute_V_gene_delineations,
    compute_imgt_intdata,

    ## auxdata-IO.R:
    read_auxdata,
    write_auxdata,

    ## compute_auxata.R:
    compute_auxdata,

    ## V_alleles-inspect.R:
    translate_V_alleles,
    V_allele_has_stop_codon,

    ## J_alleles-inspect.R:
    translate_J_alleles,
    J_allele_has_stop_codon,
    translate_fwr4,

    ## get_igblast_root.R:
    get_igblast_root, set_igblast_root,

    ## igblast_info.R:
    has_igblast,
    list_igblast_organisms,
    igblastn_version, makeblastdb_version, igblast_build, igblast_info,

    ## update_live_igdata.R:
    reset_live_igdata, update_live_igdata,
    time_since_live_igdata_last_checked, igdata_info,

    ## intdata-utils.R:
    get_intdata_path,
    load_intdata,
    show_intdata_disagreements,
    V_genes_with_varying_fwrcdr_boundaries,

    ## auxdata-utils.R:
    get_auxdata_path, get_igblast_auxiliary_data,
    load_auxdata, load_igblast_auxiliary_data,
    compute_germline_db_auxdata,

    ## install_igblast.R:
    install_igblast,

    ## reset_germline_dbs.R:
    reset_germline_dbs,

    ## list_germline_dbs.R:
    list_germline_dbs,
    rm_germline_db,

    ## use_germline_db.R:
    use_germline_db,
    load_germline_db,

    ## reset_c_region_dbs.R:
    reset_c_region_dbs,

    ## list_c_region_dbs.R:
    list_c_region_dbs,
    rm_c_region_db,

    ## use_c_region_db.R:
    use_c_region_db,
    load_c_region_db,

    ## install_custom_germline_db.R:
    install_custom_germline_db,

    ## download_OGRDB_germline_sequences.R:
    download_OGRDB_germline_sequences,

    ## download_OGRDB_germline_json.R:
    download_OGRDB_germline_json,
    extract_intdata_from_ogrdb_json,
    extract_auxdata_from_ogrdb_json,

    ## install_OGRDB_germline_db.R:
    #install_OGRDB_germline_db,

    ## download_IMGT_germline_sequences.R:
    IMGT_is_up,
    list_IMGT_releases,
    list_IMGT_organisms,
    download_IMGT_germline_sequences,

    ## install_IMGT_germline_db.R:
    install_IMGT_germline_db,
    install_IMGT_c_region_db,

    ## combine_germline_dbs.R:
    combine_germline_dbs,
    combine_c_region_dbs,

    ## augment_germline_db.R:
    augment_germline_db_V,
    augment_germline_db_D,
    augment_germline_db_J,

    ## read_igblastn_fmt7_output.R:
    list_outfmt7_specifiers,
    parse_outfmt7,
    read_igblastn_fmt7_output,

    ## read_igblastn_AIRR_output.R:
    read_igblastn_AIRR_output,

    ## igblastn.R:
    igblastn, igblastn_help,

    ## igbrowser.R:
    igbrowser, bcr_browser,

    ## summarizeMismatches.R:
    tabulate_mismatches,
    tabulate_insertions,
    tabulate_deletions,

    ## OAS-utils.R:
    OAS_is_up,
    read_OAS_csv_metadata,
    read_OAS_csv,
    extract_sequences_from_paired_OAS_df,
    list_paired_OAS_studies,
    list_paired_OAS_units,
    download_paired_OAS_units,
    extract_metadata_from_OAS_units,
    extract_sequences_from_paired_OAS_units
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S3 generics defined in igblastr and their methods
###

export(
    ## read_igblastn_fmt7_output.R:
    qseqid
)

S3method(qseqid, fmt7record)
S3method(qseqid, query_details)

### 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(
    qseqid.fmt7record,
    qseqid.query_details
)

