Skip to content
Snippets Groups Projects
Unverified Commit 085369d5 authored by MaliRemorker's avatar MaliRemorker Committed by GitHub
Browse files

Merge pull request #2 from MaliRemorker/devel

Devel
parents 7a74f64d f2ff1c43
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ assign("listEnv", NULL, envir=.listEnvEnv)
#' \code{listEnv} (which defaults to the global environment) and used by
#' the \code{findMz}, \code{findCAS}, ... functions. The CSV file is required to have at least the following columns, which are used for
#' further processing and must be named correctly (but present in any order): \var{ID, Name, SMILES, RT,
#' CAS}
#' CAS}. If a dataframe is supplied instead of path, this can be loaded in, too.
#'
#' resetList() clears a currently loaded list.
#'
......@@ -18,10 +18,13 @@ assign("listEnv", NULL, envir=.listEnvEnv)
#' @usage loadList(path, listEnv=NULL, check=TRUE)
#'
#' resetList()
#' @param path Path to the CSV list.
#' @param listEnv The environment to load the list into. By default, the namelist is loaded
#' into an environment internally in RMassBank.
#' @param check A parameter that specifies whether the SMILES-Codes in the list should be checked for readability by rcdk.
#' @param path Path to the CSV list. Alternatively, a data.frame of a
#' previously read in compound list.
#' @param listEnv The environment to load the list into. By default,
#' the namelist is loaded into an environment internally in
#' RMassBank.
#' @param check A parameter that specifies whether the SMILES-Codes in
#' the list should be checked for readability by rcdk.
#' @return No return value.
#' @author Michael Stravs
#' @seealso \code{\link{findMz}}
......@@ -34,20 +37,29 @@ assign("listEnv", NULL, envir=.listEnvEnv)
loadList <- function(path, listEnv = NULL, check = TRUE)
{
if(is.null(listEnv))
listEnv <- .listEnvEnv
if(!file.exists(path))
stop("The supplied file does not exist, please supply a correct path")
# Try out if the file is comma- or semicolon-separated
compoundList <- read.csv(path, stringsAsFactors=FALSE, check.names=FALSE)
n <- colnames(compoundList)
if(!("ID" %in% n)){ # If no ID column, it must be semicolon separated
compoundList <- read.csv2(path, stringsAsFactors=FALSE, check.names=FALSE)
listEnv <- .listEnvEnv
compoundList <- if (is.data.frame(path))
{
path
} else {
if(!file.exists(path))
stop("The supplied file does not exist, please supply a correct path")
## Try out if the file is comma- or semicolon-separated.
tmpList <- read.csv(path, stringsAsFactors=FALSE, check.names=FALSE)
n <- colnames(tmpList)
if(!("ID" %in% n)){ # If no ID column, it must be semicolon separated
tmpList <- read.csv2(path, stringsAsFactors=FALSE, check.names=FALSE)
n <- colnames(tmpList)
if(!("ID" %in% n)){ # ...or there must be something wrong with the column names
stop("There is no 'ID' column in the compound list")
}
}
tmpList
}
n <- colnames(compoundList)
if(!("ID" %in% n)){ # ...or there must be something wrong with the column names
stop("There is no 'ID' column in the compound list")
}
}
# Now everything should be fine, at least regarding csv and ssv
......@@ -626,4 +638,4 @@ findMass <- function(cpdID_or_smiles, retrieval="standard", mode = "pH")
mol <- getMolecule(s)
return(get.exact.mass(mol))
}
}
\ No newline at end of file
}
......@@ -495,12 +495,10 @@ msmsRead.parallel <- function(cl,w,filetable = NULL, files = NULL, cpdids = NULL
envir <- environment()
## clusterExport(cl,c("count","envir")) # Have no idea what
## # for are those two.
doone <- function(fn) {
doone <- function(fn,cpdID) {
## Find compound ID
cpdID <- cpdids[count]
retrieval <- findLevel(cpdID,TRUE)
## Set counter up
envir$count <- envir$count + 1
## Retrieve spectrum data
spec <- findMsMsHR(fileName = fn,
......@@ -510,12 +508,13 @@ msmsRead.parallel <- function(cl,w,filetable = NULL, files = NULL, cpdids = NULL
fillPrecursorScan = settings$findMsMsRawSettings$fillPrecursorScan,
rtMargin = settings$rtMargin,
deprofile = settings$deprofile, retrieval=retrieval)
message("File: ",fn,"Compound: ",cpdID,"DONE")
message("File: ",fn," ;Compound ID: ",cpdID,"; Status: DONE")
gc()
return(spec)
}
cllct <- parallel::parLapply(cl,w@files,doone)
parallel::clusterExport(cl,c("readMethod","mode","confirmMode","useRtLimit","settings"),envir=environment())
cllct <- parallel::clusterMap(cl,doone,w@files,cpdids)
w@spectra <- as(cllct,"SimpleList")
names(w@spectra) <- basename(as.character(w@files))
return(w)
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/createMassBank.R
\name{.parseTitleString}
\alias{.parseTitleString}
\title{Parse record title}
\usage{
.parseTitleString(mbrecord)
}
\arguments{
\item{mbrecord}{A MassBank record in list format, as returned from
\code{\link{gatherSpectrum}}.}
}
\value{
A string with the title.
}
\description{
Parses a title for a single MassBank record using the title format
specified in the option titleFormat. Internally used, not exported.
}
\details{
If the option is not set, a standard title format is used (for record definition
version 1 or 2).
}
\examples{
\dontrun{
# used in compileRecord()
title <- .parseTitleString(mbrecord)
}
}
\references{
MassBank record format:
\url{http://www.massbank.jp/manuals/MassBankRecord_en.pdf}
}
\seealso{
\code{\link{compileRecord}}
}
\author{
Michael Stravs, Eawag
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment