R/read.topolink.output.R

Defines functions read.topolink.output

Documented in read.topolink.output

#' Reads a collection of topolink log files given a log list file and a path to the log collection
#'
#' @param loglistLocation The path to a text file containing the names of the log files. can be generated by 'ls *.log > loglist.txt' on the appropriate directory.
#' @param topolinkLogsDirectory The path to the directory containing the topolink logs.
#' @return A list of parsed topolink logs

read.topolink.output <- function(loglistLocation,
                                 topolinkLogsDirectory){

  ######
  #
  # This script relies on logs obtained by TopoLink Software. TopoLink is open-source software.
  # Whenever you use TopoLink software, please cite:
  #
  # Ferrari, Allan & Martínez, Leandro & Cesar Gozzo, Fabio. (2017).
  # TopoLink: A software to validate structural models using chemical crosslinking constraints.
  # Nature Protocol Exchange. 10.1038/protex.2017.035.
  #
  # Obtain TopoLink software at http://leandro.iqm.unicamp.br/topolink/home.shtml
  #
  ######

  logList <- readLines(loglistLocation)
  logTableList <- list()

  progressBar <- txtProgressBar(min = 0, max = length(logList), style = 3)

  for (i in 1:length(logList)){

    logPath <- paste0(topolinkLogsDirectory, logList[i])
    logTableList[[logList[i]]] <- readLines(logPath)
    filterVector <- grep(pattern = 'LINK:', x = logTableList[[logList[i]]])
    logTableList[[logList[i]]] <- logTableList[[logList[i]]][filterVector]

    logTableList[[logList[i]]] <- read.table(text = logTableList[[logList[i]]],
                                             header = FALSE)

    setTxtProgressBar(progressBar, i)

    }
  names(logTableList) = logList
  return(logTableList)
}
Hugemiler/ZedXL documentation built on Oct. 6, 2019, 11:14 p.m.