#' @param istable Used in writing txt file to check if the file is table or not.
#' @examples
#' collection <- Collection$new(arv, collectionUUID)
- #' writeFile <- collection$writeFile("myoutput.csv", file, istable = NULL) # csv
- #' writeFile <- collection$writeFile("myoutput.fasta", file, istable = NULL) # fasta
- #' writeFile <- collection$writeFile("myoutputtable.txt", file, istable = "yes") # txt table
- #' writeFile <- collection$writeFile("myoutputtext.txt", file, istable = "no") # txt text
- #' writeFile <- collection$writeFile("myoutputbinary.dat", file) # binary
- #' writeFile <- collection$writeFile("myoutputxlsx.xlsx", file) # xlsx
- writeFile = function(name, file, istable = NULL, seqName = NULL)
- {
- # prepare file and connection
- arvFile <- collection$create(name)[[1]]
- arvFile <- collection$get(name)
- arvConnection <- arvFile$connection("w")
- # get file format
- FileName <- arvFile$getName()
- FileName <- tolower(FileName)
- FileFormat <- gsub(".*\\.", "", FileName)
+ #' writeFile <- collection$writeFile(name = "myoutput.csv", file = file, fileFormat = "csv", istable = NULL, collectionUUID = collectionUUID) # csv
+ #' writeFile <- collection$writeFile(name = "myoutput.tsv", file = file, fileFormat = "tsv", istable = NULL, collectionUUID = collectionUUID) # tsv
+ #' writeFile <- collection$writeFile(name = "myoutput.fasta", file = file, fileFormat = "fasta", istable = NULL, collectionUUID = collectionUUID) # fasta
+ #' writeFile <- collection$writeFile(name = "myoutputtable.txt", file = file, fileFormat = "txt", istable = "yes", collectionUUID = collectionUUID) # txt table
+ #' writeFile <- collection$writeFile(name = "myoutputtext.txt", file = file, fileFormat = "txt", istable = "no", collectionUUID = collectionUUID) # txt text
+ #' writeFile <- collection$writeFile(name = "myoutputbinary.dat", file = file, fileFormat = "dat", collectionUUID = collectionUUID) # binary
+ #' writeFile <- collection$writeFile(name = "myoutputxlsx.xlsx", file = file, fileFormat = "xlsx", collectionUUID = collectionUUID) # xlsx
+ writeFile = function(name, file, collectionUUID, fileFormat, istable = NULL, seqName = NULL) {
# set enviroment
ARVADOS_API_TOKEN <- Sys.getenv("ARVADOS_API_TOKEN")
"AWS_DEFAULT_REGION" = "collections",
"AWS_S3_ENDPOINT" = gsub("api[.]", "", ARVADOS_API_HOST))
- if (FileFormat == "txt") {
+ # save file
+ if (fileFormat == "txt") {
if (istable == "yes") {
- aws.s3::s3write_using(file, FUN = write.table, object = name, bucket = my_collection)
+ aws.s3::s3write_using(file, FUN = write.table, object = name, bucket = collectionUUID)
} else if (istable == "no") {
- aws.s3::s3write_using(file, FUN = writeChar, object = name, bucket = my_collection)
+ aws.s3::s3write_using(file, FUN = writeChar, object = name, bucket = collectionUUID)
} else {
stop(paste("Specify parametr istable"))
}
- } else if (FileFormat == "csv") {
- aws.s3::s3write_using(file, FUN = write.csv, object = name, bucket = my_collection)
- } else if (FileFormat == "fasta") {
- aws.s3::s3write_using(file, FUN = seqinr::write.fasta, name = seqName, object = name, bucket = my_collection)
- } else if (FileFormat == "xlsx") {
- aws.s3::s3write_using(file, FUN = openxlsx::write.xlsx, object = name, bucket = my_collection)
- } else if (FileFormat == "dat" || FileFormat == "bin") {
- aws.s3::s3write_using(file, FUN = writeBin, object = name, bucket = my_collection)
+ } else if (fileFormat == "csv") {
+ aws.s3::s3write_using(file, FUN = write.csv, object = name, bucket = collectionUUID)
+ } else if (fileFormat == "tsv") {
+ aws.s3::s3write_using(file, FUN = write.table, row.names = FALSE, sep = "\t", object = name, bucket = collectionUUID)
+ } else if (fileFormat == "fasta") {
+ aws.s3::s3write_using(file, FUN = seqinr::write.fasta, name = seqName, object = name, bucket = collectionUUID)
+ } else if (fileFormat == "xlsx") {
+ aws.s3::s3write_using(file, FUN = openxlsx::write.xlsx, object = name, bucket = collectionUUID)
+ } else if (fileFormat == "dat" || fileFormat == "bin") {
+ aws.s3::s3write_using(file, FUN = writeBin, object = name, bucket = collectionUUID)
} else {
stop(parse(('File format not supported, use arvadosFile$connection() and customise it')))
}
## ------------------------------------------------\r
\r
collection <- Collection$new(arv, collectionUUID)\r
-writeFile <- collection$writeFile("myoutput.csv", file, istable = NULL) # csv\r
-writeFile <- collection$writeFile("myoutput.fasta", file, istable = NULL) # fasta\r
-writeFile <- collection$writeFile("myoutputtable.txt", file, istable = "yes") # txt table\r
-writeFile <- collection$writeFile("myoutputtext.txt", file, istable = "no") # txt text\r
-writeFile <- collection$writeFile("myoutputbinary.dat", file) # binary\r
-writeFile <- collection$writeFile("myoutputxlsx.xlsx", file) # xlsx\r
+writeFile <- collection$writeFile(name = "myoutput.csv", file = file, fileFormat = "csv", istable = NULL, collectionUUID = collectionUUID) # csv\r
+writeFile <- collection$writeFile(name = "myoutput.tsv", file = file, fileFormat = "tsv", istable = NULL, collectionUUID = collectionUUID) # tsv\r
+writeFile <- collection$writeFile(name = "myoutput.fasta", file = file, fileFormat = "fasta", istable = NULL, collectionUUID = collectionUUID) # fasta\r
+writeFile <- collection$writeFile(name = "myoutputtable.txt", file = file, fileFormat = "txt", istable = "yes", collectionUUID = collectionUUID) # txt table\r
+writeFile <- collection$writeFile(name = "myoutputtext.txt", file = file, fileFormat = "txt", istable = "no", collectionUUID = collectionUUID) # txt text\r
+writeFile <- collection$writeFile(name = "myoutputbinary.dat", file = file, fileFormat = "dat", collectionUUID = collectionUUID) # binary\r
+writeFile <- collection$writeFile(name = "myoutputxlsx.xlsx", file = file, fileFormat = "xlsx", collectionUUID = collectionUUID) # xlsx\r
\r
## ------------------------------------------------\r
## Method `Collection$create`\r
\subsection{Method \code{writeFile()}}{\r
Write file content\r
\subsection{Usage}{\r
-\if{html}{\out{<div class="r">}}\preformatted{Collection$writeFile(name, file, istable = NULL, seqName = NULL)}\if{html}{\out{</div>}}\r
+\if{html}{\out{<div class="r">}}\preformatted{Collection$writeFile(\r
+ name,\r
+ file,\r
+ collectionUUID,\r
+ fileFormat,\r
+ istable = NULL,\r
+ seqName = NULL\r
+)}\if{html}{\out{</div>}}\r
}\r
\r
\subsection{Arguments}{\r
\subsection{Examples}{\r
\if{html}{\out{<div class="r example copy">}}\r
\preformatted{collection <- Collection$new(arv, collectionUUID)\r
-writeFile <- collection$writeFile("myoutput.csv", file, istable = NULL) # csv\r
-writeFile <- collection$writeFile("myoutput.fasta", file, istable = NULL) # fasta\r
-writeFile <- collection$writeFile("myoutputtable.txt", file, istable = "yes") # txt table\r
-writeFile <- collection$writeFile("myoutputtext.txt", file, istable = "no") # txt text\r
-writeFile <- collection$writeFile("myoutputbinary.dat", file) # binary\r
-writeFile <- collection$writeFile("myoutputxlsx.xlsx", file) # xlsx\r
+writeFile <- collection$writeFile(name = "myoutput.csv", file = file, fileFormat = "csv", istable = NULL, collectionUUID = collectionUUID) # csv\r
+writeFile <- collection$writeFile(name = "myoutput.tsv", file = file, fileFormat = "tsv", istable = NULL, collectionUUID = collectionUUID) # tsv\r
+writeFile <- collection$writeFile(name = "myoutput.fasta", file = file, fileFormat = "fasta", istable = NULL, collectionUUID = collectionUUID) # fasta\r
+writeFile <- collection$writeFile(name = "myoutputtable.txt", file = file, fileFormat = "txt", istable = "yes", collectionUUID = collectionUUID) # txt table\r
+writeFile <- collection$writeFile(name = "myoutputtext.txt", file = file, fileFormat = "txt", istable = "no", collectionUUID = collectionUUID) # txt text\r
+writeFile <- collection$writeFile(name = "myoutputbinary.dat", file = file, fileFormat = "dat", collectionUUID = collectionUUID) # binary\r
+writeFile <- collection$writeFile(name = "myoutputxlsx.xlsx", file = file, fileFormat = "xlsx", collectionUUID = collectionUUID) # xlsx\r
}\r
\if{html}{\out{</div>}}\r
\r