# /Users/serdarbalciold/AutoJournalWatch/run-GetPMID-writeLines-publish.R
options(repos = c("https://cran.microsoft.com/snapshot/2020-05-01"))
# Daily cron Journal Watch ----
# load library ----
print(paste0("Load Library Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/loadLibrary.R")
print(paste0("Load Library Ended at: ", Sys.time()))
# check time and then run ----
previousrun <-
if (file.exists("~/AutoJournalWatch/lastrun.log")) {
readLines("~/AutoJournalWatch/lastrun.log")
} else{
Sys.time() - as.difftime(13, units = "hours")
}
if (as.POSIXlt(previousrun) + as.difftime(12, units = "hours") < Sys.time()) {
# read previous data ----
load("~/JournalWatchPBPath/.RData")
# read feeds
# print(paste0("Read Feeds Started at: ", Sys.time()))
# source(file = "~/AutoJournalWatch/R/readFeeds.R")
# print(paste0("Read Feeds Ended at: ", Sys.time()))
# append csv files
# print(paste0("append csv files Started at: ", Sys.time()))
# source(file = "~/AutoJournalWatch/R/appendcsv.R")
# print(paste0("append csv files Ended at: ", Sys.time()))
Sys.sleep(6)
# Get PMID list from e-utilities ----
# search topic ----
print(paste0("define topics Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/topic.R")
print(paste0("define topics Ended at: ", Sys.time()))
# journal list ----
print(paste0("Read Journal List Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/journals.R")
print(paste0("Read Journal List Ended at: ", Sys.time()))
# searchQuery ----
print(paste0("Read searchQuery Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/searchQuery.R")
print(paste0("Read searchQuery Started at: ", Sys.time()))
# date range ----
# source("~/AutoJournalWatch/R/dateRange.R")
# generate search formula ----
print(paste0("Read searchFormula Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/searchFormula.R")
print(paste0("Read searchFormula Ended at: ", Sys.time()))
Sys.sleep(6)
# generate search formula ----
# print(paste0("Read searchFormulaDocker Started at: ", Sys.time()))
# source("~/AutoJournalWatch/R/searchFormulaDocker.R")
# print(paste0("Read searchFormulaDocker Ended at: ", Sys.time()))
# write sh file ----
print(paste0("Read searchFormula Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/generateSH.R")
print(paste0("Read searchFormula Started at: ", Sys.time()))
Sys.sleep(6)
# run sh file: eutilities get PMID save temporary list ----
print(paste0("run SH File Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/runSH.R")
print(paste0("run SH File Ended at: ", Sys.time()))
Sys.sleep(6)
# combine temporary list with existing list ----
print(paste0("read and Combine Files Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/readCombineFiles.R")
print(paste0("read and Combine Files Ended at: ", Sys.time()))
# write files ----
print(paste0("write files Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/writeFiles.R")
print(paste0("write files Ended at: ", Sys.time()))
# remove temporary files ----
print(paste0("remove temporary files Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/removeTemporaryFiles.R")
print(paste0("remove temporary files Ended at: ", Sys.time()))
Sys.sleep(6)
# read combined PMID list ----
print(paste0("read combined PMID list Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/readCombinedFiles.R")
print(paste0("read combined PMID list Ended at: ", Sys.time()))
Sys.sleep(6)
# write code to Rmd ----
print(paste0("write code to Rmd Started at: ", Sys.time()))
suppressPackageStartupMessages( {
if (!require("magicfor")) {install.packages("magicfor")}
})
suppressPackageStartupMessages(library("magicfor"))
source("~/AutoJournalWatch/R/rmdGenerationFunction_pancreas.R")
source("~/AutoJournalWatch/R/rmdGenerationFunction_gallbladder.R")
source("~/AutoJournalWatch/R/rmdGenerationFunction_bileducts.R")
source("~/AutoJournalWatch/R/rmdGenerationFunction_ampulla.R")
print(paste0("write code to Rmd Ended at: ", Sys.time()))
Sys.sleep(6)
# write code to Rmd
print(paste0("write code to new Rmd Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/rmdGenerationFunction_new_pancreas.R")
source("~/AutoJournalWatch/R/rmdGenerationFunction_new_gallbladder.R")
source("~/AutoJournalWatch/R/rmdGenerationFunction_new_bileducts.R")
source("~/AutoJournalWatch/R/rmdGenerationFunction_new_ampulla.R")
print(paste0("write code to new Rmd Ended at: ", Sys.time()))
# copy and rename files ----
print(paste0("copy and rename files Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/copyRenameFiles.R")
print(paste0("copy and rename files Ended at: ", Sys.time()))
Sys.sleep(1)
# Generate email ----
# print(paste0("Generate email Started at: ", Sys.time()))
# source("~/AutoJournalWatch/R/generateEmail.R")
# print(paste0("Generate email Ended at: ", Sys.time()))
# Generate wordpress post ----
print(paste0("Generate wordpress Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/generateWP.R")
print(paste0("Generate wordpress Ended at: ", Sys.time()))
# Update Git and Email ----
# Git Update AutoJournalWatch ----
print(paste0("Git Update AutoJournalWatch Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/gitUpdateAutoJW.R")
print(paste0("Git Update AutoJournalWatch Ended at: ", Sys.time()))
Sys.sleep(10)
# Send email
# print(paste0("Send email Started at: ", Sys.time()))
# source("~/AutoJournalWatch/R/email_new_articles.R")
# print(paste0("Send email Ended at: ", Sys.time()))
# Send wordpress ----
print(paste0("Send wordpress Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/WP_new_articles.R")
print(paste0("Send wordpress Ended at: ", Sys.time()))
# render RecentPBPathJW Rmd Files ----
print(paste0("Render RecentPBPathJW.Rmd Files Started at: ", Sys.time()))
suppressPackageStartupMessages( {
if (!require("here")) {install.packages("here")}
})
suppressPackageStartupMessages(library("here"))
source("~/AutoJournalWatch/R/renderRmdFiles.R")
print(paste0("Render Rmd Files Ended at: ", Sys.time()))
Sys.sleep(60)
# Git Update PBPath JournalWatch ----
print(paste0("Git Update PBPath JournalWatch Started at: ", Sys.time()))
source("~/AutoJournalWatch/R/gitUpdatePBPathJW.R")
print(paste0("Git Update PBPath JournalWatch Ended at: ", Sys.time()))
Sys.sleep(1)
# Save Execution Time ----
write(x = as.character(Sys.time()), file = "~/AutoJournalWatch/lastrun.log")
# save data image ----
save.image(file = "~/JournalWatchPBPath/.RData")
} else {
print(paste0("Already searched within previous day. If want to run the code delete AutoJournalWatch/lastrun.log file.", Sys.time()))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.