R/has_alignments.R

#' Checks if alignments are present
#' @param file a file, as returned by 'wiritttes::read_file(filename)'
#' @return a vector of TRUEs and FALSEs
#' @author Richel Bilderbeek
#' @export
has_alignments <- function(file) {

  n_alignments <- as.numeric(file$parameters$n_alignments[2])

  v <- NULL

  for (sti in 1:2) {
    for (ai in 1:n_alignments) {
      alignment <- NA
      tryCatch(
        alignment <- wiritttes::get_alignment(
          file = file,
          sti = sti,
          ai = ai
        ),
        error = function(msg) {} # nolint
      )
      v <- c(v, ribir::is_alignment(alignment))
    }
  }
  v
}
richelbilderbeek/wiritttea documentation built on May 27, 2019, 8:02 a.m.