-
Notifications
You must be signed in to change notification settings - Fork 11
/
.Rapp.history
120 lines (120 loc) · 8.96 KB
/
.Rapp.history
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Feel free to contact Vasco Elbrecht if you run into issues (twitter: @luckylionde). Enjoy!#
#
# set the path to the PrimerMinder folder you just downloaded#
setwd("~/Desktop/PrimerMiner-master 5")#
#
# install the PrimerMiner package icl dependencies#
install.packages("PrimerMiner", repos = NULL, type="source", dependencies=T)#
#
# load the package into R#
library("PrimerMiner")#
#
# quick guide inside R, further documentation in the Github Wiki#
# https://github.com/VascoElbrecht/PrimerMiner/wiki#
browseVignettes("PrimerMiner")
setwd("~/Desktop/PrimerMiner-0.11 2/Sample_Data")
library("PrimerMiner")
browseVignettes("PrimerMiner")
batch_download("taxa_cichs.csv", "config.txt")
# Feel free to contact Vasco Elbrecht if you run into issues (twitter: @luckylionde). Enjoy!#
#
# set the path to the PrimerMinder folder you just downloaded#
setwd("~/Desktop/PrimerMiner-0.11 2/Sample_Data")#
#
# install the PrimerMiner package icl dependencies#
#install.packages(c("bo
library("PrimerMiner")
setwd("Sample_Data")
batch_download("taxa_cichs.csv", "config.txt")
batch_download("taxa_small.csv", "config.txt")
?download.file
folder=NULL
minlength=2001
maxlength=80000
custom_query=NULL
setwd=NULL
setwd("~/Desktop/primerminer_test")
taxon <- "Perlidae"
if(!is.null(setwd)){logfile <- paste(setwd, "/log.txt", sep="")} else {logfile <- "log.txt"}
setwd
cat(paste(Sys.time(), " - Downloading Miochondrial Genomes from GenBank\n\n"), file=logfile, sep="", append=T)
if (is.null(custom_query)){cat(paste("Search query: REPLACE_WITH_TAXA", "[Organism] AND mitochondrion[filter] AND genome AND ", minlength, ":", maxlength ,"[Sequence Length]\n\n", sep=""), file=logfile, sep="", append=T)} else {cat(paste("Search query: REPLACE_WITH_TAXA", custom_query, "\n\n", sep=""), file=logfile, sep="", append=T)}#
#
folder_path <- ""#
if(!is.null(folder)){dir.create(folder, showWarnings=F)#
folder_path <- paste(folder, "/", sep="")#
cat(paste("#mito_data: Folder ",folder, "\n", sep=""), file=logfile, sep="", append=T)#
} else {cat(paste("#mito_data: ", "\n", sep=""), file=logfile, sep="", append=T)}#
cat("Taxon\tSequences\tdownl_time\n", file=logfile, sep="", append=T)
folder
for (k in 1:length(taxon)){#
time <- Sys.time() # get time#
# download IDs#
if (is.null(custom_query)){#
searchQ <- paste(taxon[k],"[Organism] AND mitochondrion[filter] AND genome AND ", minlength, ":", maxlength ,"[Sequence Length]", sep="")#
} else {searchQ <- paste(taxon, custom_query, sep="")}#
#
search_results <- entrez_search(db="nuccore", term=searchQ, retmax=9999999)#
#
# save genbank file!#
if(length(search_results$ids)!=0){#
cat(file=paste(folder_path, taxon[k], "_mito.gb", sep="")) # overwrite old files#
for (i in 1:length(search_results$ids)){#
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")#
}#
}#
#
time <- Sys.time() - time#
message(paste("Downloaded ", length(search_results$ids)," mitogenomes for ", taxon[k], " in ", format(time, digits=2), ".", sep=""))#
cat(paste(taxon[k],"\t", length(search_results$ids), "\t", format(time, digits=2), "\n", sep=""), file=logfile, sep="", append=T)#
#
}#
cat(paste("#mito_data_end", "\n\n", sep=""), file=logfile, sep="", append=T)
search_results$ids
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")
?download.file
temp <- download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")
temp
temp <- download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), mode="a", quiet=T, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="at", quiet=T, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="at", quiet=T, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="at", quiet=T, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="at", quiet=T, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=F, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=F, method="curl")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")
paste(folder_path, taxon[k], "_mito.gb", sep="")
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile="temp.txt", mode="a", quiet=T, method="curl")
readLines("temp.txt")
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T)
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T)
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T)
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T)
file.remove("temp.txt")
file.remove("temp.txt")
temp <- file.remove("temp.txt", )
file.remove("temp.txt", showWarnings=F)
temp <- file.remove("temp.txt")
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T)
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile="temp.txt", mode="a", quiet=T, method="curl")
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T)
temp <- file.remove("temp.txt")
glumandaoderso <- file.remove("temp.txt")
for (i in 1:length(search_results$ids)){#
#download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")#
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile="temp.txt", mode="a", quiet=T, method="curl")#
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T)#
}#
glumandaoderso <- file.remove("temp.txt")
for (i in 1:length(search_results$ids)){#
#download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile=paste(folder_path, taxon[k], "_mito.gb", sep=""), mode="a", quiet=T, method="curl")#
download.file(paste("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=", search_results$ids[i], "&rettype=gb&retmode=text", sep=""), destfile="temp.txt", mode="a", quiet=T, method="curl")#
cat(readLines("temp.txt"), file=paste(folder_path, taxon[k], "_mito.gb", sep=""), append=T, sep="\n")#
}
# Feel free to contact Vasco Elbrecht if you run into issues (twitter: @luckylionde). Enjoy!#
#
# set the path to the PrimerMinder folder you just downloaded#
setwd("~/Documents/UNI_und_VORLESUNGEN/GitHub/PrimerMiner")
install.packages("PrimerMiner", repos = NULL, type="source", dependencies=T)