Libraries:
knitr::opts_chunk$set(echo = TRUE)
Libraries = c("readr")
# Install if not present
for(p in Libraries){
if(!require(p, character.only = TRUE))
install.packages(p)
library(p, character.only = TRUE)
}
start_time <- Sys.time() # Start timer
prot_list <- list.files(pattern = ".txt$")
test_file_name <- "seven_class_500_test_harness_BETA.lst"
for (i in 1:length(prot_list)) {
line_count <- length(readLines(prot_list[i]))
print(prot_list[i])
for (j in 1:500) {
choose_index <- floor(runif(1, min = 1, max = line_count))
#print(paste(choose_index, ",", sep = ""))
one_line <- read_lines(prot_list[i], skip = choose_index, n_max = 1L)
write_lines(one_line, path = test_file_name, sep = "\n", append = TRUE)
}
}
## [1] "protein_class_Ctrl.txt"
## [1] "protein_class_Ery.txt"
## [1] "protein_class_Hcy.txt"
## [1] "protein_class_Hgb.txt"
## [1] "protein_class_Hhe.txt"
## [1] "protein_class_Lgb.txt"
## [1] "protein_class_Mgb.txt"
end_time <- Sys.time() # End timer
end_time - start_time # Display time
## Time difference of 8.338564 secs
Machine Settings:
Sys.info()[c(1:3,5)]
## sysname
## "Linux"
## release
## "4.15.0-46-generic"
## version
## "#49~16.04.1-Ubuntu SMP Tue Feb 12 17:45:24 UTC 2019"
## machine
## "x86_64"
sessionInfo()
## R version 3.4.4 (2018-03-15)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Linux Mint 18.3
##
## Matrix products: default
## BLAS: /usr/lib/libblas/libblas.so.3.6.0
## LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] readr_1.3.1
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.0 crayon_1.3.4 digest_0.6.18 R6_2.3.0
## [5] magrittr_1.5 evaluate_0.12 pillar_1.3.1 rlang_0.3.0.1
## [9] stringi_1.2.4 rmarkdown_1.11 tools_3.4.4 stringr_1.3.1
## [13] hms_0.4.2 xfun_0.4 yaml_2.2.0 compiler_3.4.4
## [17] pkgconfig_2.0.2 htmltools_0.3.6 knitr_1.21 tibble_1.4.2
EOF