R/upload.fasta.to.goanna.R

Defines functions upload.fasta.to.goanna

Documented in upload.fasta.to.goanna

#' Upload protein FASTA files to GOanna website.
#'
#' @param email.address Email address to send the output of GOanna as a string
#' @param file.to.upload Path to protein FASTA file to upload to GOanna as a string
#' @param expected.value Expected value or evalue for BLAST search as a string
#' @param word.size Word size for the BLAST search as a string
#' @param max.target.sequences Maximum number of target sequences for BLAST search
#' @param percent.identity Percent Identity of the BLAST search as a string
#' @param query.coverage Query coverage of BLAST search as a string
#' @return results = a status of the GOanna webpage request
#' @examples
#' result <- upload.fasta.to.goanna(email.address ="email",
#'                        file.to.upload = "sparrow.mRNA1.fasta",
#'                        expected.value = "10e-20",
#'                        word.size = "3",
#'                        max.target.sequences = "3",
#'                        percent.identity = "20",
#'                        query.coverage = "20")
#' @export
upload.fasta.to.goanna <- function(email.address,
                                   file.to.upload,
                                   expected.value,
                                   word.size,
                                   max.target.sequences,
                                   percent.identity,
                                   query.coverage) {

  url       <-"http://agbase.msstate.edu/cgi-bin/tools/GOanna.cgi"   ## page to spider
  pgsession <-rvest::html_session(url)               ## create session
  pgform    <-rvest::html_form(pgsession)[[1]]       ## pull form from session
  filled_form <- rvest::set_values(pgform,
                            pgform$url <- "",
                            pgform$fields$EMAIL$value <- email.address,
                            pgform$fields$IDLIST$value <- httr::upload_file(file.to.upload),
                            pgform$fields$EXPECT$value <- expected.value,
                            pgform$fields$WORD_SIZE$value <- word.size,
                            pgform$fields$MAX_TARGET_SEQS$value <- max.target.sequences,
                            pgform$fields$PCTID$value <- percent.identity,
                            pgform$fields$QRYCOV$value <- query.coverage,
                            pgform$fields$blastp_query_cov$value <- query.coverage)
  result <- rvest::submit_form(pgsession,filled_form)
  return(result)
}
jelber2/rGO2TR documentation built on Feb. 22, 2024, 12:50 p.m.