-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_gb_file.R
More file actions
32 lines (30 loc) · 1.21 KB
/
read_gb_file.R
File metadata and controls
32 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#' Fetch GB files online
#'
#' Fetching GB file from GenBank database by GenInfo Identifier (GI) or
#' accession number and writeing it to a file named "GI.gb" in current work
#' directory.
#' @param GI GenInfo Identifier(GI) for interested genome file.
#' @param read A logical value. If it is \code{TRUE}, the function will read
#' the fetched GB file into current R session environment.
#' @return If \code{read} is set as \code{TRUE}. The function return a large
#' character vector which contains the content of GB file for input \code{GI}
#' from GeneBank.
#' @export
fetch.gb<- function(GI, read=TRUE){
#the GI can be also accession number
p<- reutils::efetch(GI, "nucleotide", "gb", complexity = 1)
#write(reutils::content(p, "text"), file = paste(GI, ".gb", sep=""))
p <- strsplit(reutils::content(p), "\n")[[1]]
return(p)
}
#' Read the local GB file
#'
#' Reading the GB file in the working directory producing the RGB format file
#' needed for the functions of the package
#' @param file The path to the GB file which is in GeneBank format
#' @return a large character vector returned by function
#' \code{\link{fetch.gb}} or \code{\link{read.gb}}
#' @export
read.gb <- function(file){
return(readLines(file))
}