R/sqlToMaldiquant.R

Defines functions spectrumMatrixToMALDIqaunt

Documented in spectrumMatrixToMALDIqaunt

#' SQL to MALDIquant
#'
#' @param input matrix/list of martrices , col 1 = masses, col 2 = intensities
#'
#' @return NA
#' @export
#'
spectrumMatrixToMALDIqaunt <- function(input){
  
  
  if (class(input) == "list") {
    
    input <- lapply(input, 
                    function(x){
                      MALDIquant::createMassSpectrum(mass = x[ , 1],
                                                     intensity = x[ , 2])
                    })
    
    
  } else if (class(input) == "matrix") {
    
    input <- MALDIquant::createMassSpectrum(mass = input[ , 1],
                                            intensity = input[ , 2])
    input <- list(input)
    
  }
  
  
  
  # Make sure to return input as a MassSpectrumList
  if(MALDIquant::isMassSpectrumList(input)){
    return(input) 
  } else{
    stop("Error in spectrumMatrixToMALDIqaunt: Not a MALDIquant spec list")
    
  }
}
chasemc/tempRepo documentation built on April 8, 2019, 10:22 p.m.