Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RMassBank_by_MaliRemorker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Environmental Cheminformatics
RMassBank_by_MaliRemorker
Commits
3af1cc56
Commit
3af1cc56
authored
11 years ago
by
ermueller
Browse files
Options
Downloads
Patches
Plain Diff
RMassBank now fully functional
parent
f8e6b12b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
R/createMassBank.R
+4
-2
4 additions, 2 deletions
R/createMassBank.R
R/leMsMs.r
+2
-2
2 additions, 2 deletions
R/leMsMs.r
R/leMsmsRaw.R
+11
-3
11 additions, 3 deletions
R/leMsmsRaw.R
R/webAccess.R
+19
-19
19 additions, 19 deletions
R/webAccess.R
with
36 additions
and
26 deletions
R/createMassBank.R
+
4
−
2
View file @
3af1cc56
...
...
@@ -383,6 +383,7 @@ gatherData <- function(id)
{
# Split the "InChiKey=" part off the key
inchikey_split
<-
strsplit
(
inchikey
,
"="
,
fixed
=
TRUE
)[[
1
]][[
2
]]
print
(
inchikey_split
)
# Actually retrieve data from CTS (see the webaccess scripts)
infos
<-
getCtsRecord
(
inchikey_split
)
# Check if the name was found. If yes, OK. Otherwise, search again using
...
...
@@ -451,7 +452,7 @@ gatherData <- function(id)
# Eliminate duplicate names from our list of 3
names
<-
as.list
(
unique
(
c
(
topN
ame
N
,
storedName
,
iupacName
)))
names
<-
as.list
(
unique
(
c
(
dbn
ame
,
storedName
,
iupacName
)))
# Start to fill the MassBank record.
...
...
@@ -477,6 +478,7 @@ gatherData <- function(id)
mbdata
[[
"COMMENT"
]][[
"ID"
]]
=
id
# here compound info starts
mbdata
[[
'CH$NAME'
]]
<-
names
print
(
mbdata
[[
'CH$NAME'
]])
# Currently we use a fixed value for Compound Class, since there is no useful
# convention of what should go there and what shouldn't, and the field is not used
# in search queries.
...
...
@@ -503,7 +505,7 @@ gatherData <- function(id)
mbdata
[[
'AC$INSTRUMENT'
]]
<-
getOption
(
"RMassBank"
)
$
annotations
$
instrument
mbdata
[[
'AC$INSTRUMENT_TYPE'
]]
<-
getOption
(
"RMassBank"
)
$
annotations
$
instrument_type
print
(
mbdata
)
print
(
mbdata
)
return
(
mbdata
)
}
# function gather.mbdata
...
...
This diff is collapsed.
Click to expand it.
R/leMsMs.r
+
2
−
2
View file @
3af1cc56
...
...
@@ -105,7 +105,7 @@ msmsWorkflow <- function(w, mode="pH", steps=c(1:8), confirmMode = FALSE, newRec
if
(
readMethod
==
"xcms"
){
splitfn
<-
strsplit
(
w
@
files
,
'_'
)
cpdIDs
<-
sapply
(
splitfn
,
function
(
splitted
){
as.numeric
(
return
(
splitted
[
2
]))})
cpdIDs
<-
sapply
(
splitfn
,
function
(
splitted
){
as.numeric
(
return
(
splitted
[
length
(
splitted
)
-1
]))})
files
<-
list
()
wfiles
<-
vector
()
for
(
i
in
1
:
length
(
unique
(
cpdIDs
)))
{
...
...
@@ -175,7 +175,7 @@ msmsWorkflow <- function(w, mode="pH", steps=c(1:8), confirmMode = FALSE, newRec
if
(
3
%in%
steps
)
{
message
(
"msmsWorkflow: Step 3. Aggregate all spectra"
)
w
@
aggregatedSpecs
<-
aggregateSpectra
(
w
@
analyzedSpecs
)
w
@
aggregatedSpecs
<-
aggregateSpectra
(
w
@
analyzedSpecs
,
addIncomplete
=
TRUE
)
}
# Step 4: recalibrate all m/z values in raw spectra
if
(
4
%in%
steps
)
...
...
This diff is collapsed.
Click to expand it.
R/leMsmsRaw.R
+
11
−
3
View file @
3af1cc56
...
...
@@ -223,7 +223,7 @@ findMsMsHR.direct <- function(msRaw, cpdID, mode = "pH", confirmMode = 0, useRtL
#' psp <- findMsMsHRperxcms.direct(fileList,2184)
#' }
#' @export
findMsMsHRperxcms.direct
<-
function
(
fileName
,
cpdID
,
mode
=
"pH"
,
findPeaksArgs
,
plots
=
FALSE
)
{
findMsMsHRperxcms.direct
<-
function
(
fileName
,
cpdID
,
mode
=
"pH"
,
findPeaksArgs
=
NULL
,
plots
=
FALSE
)
{
require
(
CAMERA
)
require
(
xcms
)
...
...
@@ -244,7 +244,7 @@ findMsMsHRperxcms.direct <- function(fileName, cpdID, mode="pH", findPeaksArgs,
## MSMS
##
xrmsms
<-
xcmsRaw
(
fileName
,
includeMSn
=
TRUE
)
print
(
"File read"
)
## Where is the wanted isolation ?
precursorrange
<-
range
(
which
(
xrmsms
@
msnPrecursorMz
==
parentMass
))
## TODO: add ppm one day
...
...
@@ -259,6 +259,7 @@ findMsMsHRperxcms.direct <- function(fileName, cpdID, mode="pH", findPeaksArgs,
anmsms
<-
list
()
psp
<-
list
()
spectra
<-
list
()
whichmissing
<-
vector
()
for
(
i
in
1
:
length
(
xrs
)){
peaks
(
xsmsms
[[
i
]])
<-
do.call
(
findPeaks
,
c
(
findPeaksArgs
,
object
=
xrs
[[
i
]]))
...
...
@@ -283,7 +284,14 @@ findMsMsHRperxcms.direct <- function(fileName, cpdID, mode="pH", findPeaksArgs,
if
((
plots
==
TRUE
)
&&
(
length
(
psp
[[
i
]])
>
0
)){
plotPsSpectrum
(
anmsms
[[
i
]],
psp
[[
i
]],
log
=
TRUE
,
mzrange
=
c
(
0
,
findMz
(
cpdID
)[[
3
]]),
maxlabel
=
10
)
}
if
(
length
(
psp
[[
i
]])
!=
0
){
spectra
[[
i
]]
<-
getpspectra
(
anmsms
[[
i
]],
psp
[[
i
]])
}
else
{
whichmissing
<-
c
(
whichmissing
,
i
)}
}
if
(
length
(
spectra
)
!=
0
){
for
(
i
in
whichmissing
){
spectra
[[
i
]]
<-
matrix
(
0
,
2
,
7
)
}
}
return
(
spectra
)
}
...
...
@@ -413,7 +421,7 @@ toRMB <- function(msmsXCMSspecs = NA, cpdID = NA, mode="pH", MS1spec = NA){
header
[
12
]
<-
max
(
spec
[,
1
])
header
[
13
]
<-
1
header
[
14
]
<-
findMz
(
cpdID
)[[
3
]]
header
[
15
]
<-
-
1
##Will be changed for different charges
header
[
15
]
<-
1
##Will be changed for different charges
header
[
16
]
<-
0
##There sadly isnt any precursor intensity to find in the msms-scans. Workaround? msmsXCMS@files[1]
header
[
17
:
20
]
<-
0
##Will be changed if merge is wanted
return
(
header
)
...
...
This diff is collapsed.
Click to expand it.
R/webAccess.R
+
19
−
19
View file @
3af1cc56
...
...
@@ -138,26 +138,26 @@ getCtsRecord <- function(key, from = "inchikey",
to
=
c
(
"cas"
,
"hmdb"
,
"kegg"
,
"sid"
,
"chebi"
,
"inchi"
,
"lipidmap"
,
"smiles"
,
"cid"
,
"inchikey"
,
"mass"
,
"formula"
,
"iupac"
,
"names"
))
{
require
(
devtools
)
#
require(devtools)
require
(
RJSONIO
)
#install_github(repo = "CTSgetR", username = "dgrapov")
require
(
CTSgetR
)
#
require(CTSgetR)
# checks
if
(
from
%in%
c
(
""
,
"None"
,
"Unknown"
,
"Not available"
))
return
(
NA
)
if
(
from
%in%
c
(
""
,
"None"
,
"Unknown"
,
"Not available"
))
{
return
(
NA
)
}
ChemSpID
<-
CTSgetR
(
key
,
from
=
"InChIKey"
,
to
=
"ChemSpider"
,
parallel
=
FALSE
)
CTS.options
<-
CTS.options
()[
2
:
10
]
CTS.options
# see options
id
<-
ChemSpID
childrenProc
<-
sapply
(
1
:
length
(
CTS.options
),
function
(
i
)
{
cat
(
CTS.options
[
i
],
"\n"
)
CTSgetR
(
id
=
id
,
to
=
CTS.options
[
i
],
from
=
"ChemSpider"
)
})
print
(
childrenProc
)
#
ChemSpID<-CTSgetR(key,from="InChIKey",to="ChemSpider",parallel=FALSE)
#
CTS.options<-CTS.options()[2:10]
#
CTS.options # see options
#
id<-ChemSpID
#
childrenProc<-sapply(1:length(CTS.options), function(i)
#
{
#
cat(CTS.options[i],"\n")
#
CTSgetR(id=id,to=CTS.options[i],from="ChemSpider")
#
})
#
print(childrenProc)
require
(
RJSON
)
#
require(RJSON)
urlInchi
<-
paste
(
"http://cts.fiehnlab.ucdavis.edu/service/compound/"
,
key
,
sep
=
''
)
JSONstring
<-
getURL
(
urlInchi
)
Content
<-
fromJSON
(
JSONstring
,
method
=
"C"
,
unexpected.escape
=
"error"
)
...
...
@@ -195,10 +195,10 @@ getCtsRecord <- function(key, from = "inchikey",
#}
# Check and fix CAS (eliminate the 12-34-5CHEBI and NIKKAJI stuff)
if
(
!
is.null
(
childrenProc
$
CAS
))
{
childrenProc
$
CAS
<-
childrenProc
$
CAS
[
which
(
grepl
(
"^[-0-9]+$"
,
childrenProc
$
CAS
))]
}
#
if(!is.null(childrenProc$CAS))
#
{
#
childrenProc$CAS <- childrenProc$CAS[which(grepl("^[-0-9]+$", childrenProc$CAS))]
#
}
print
(
Content
)
return
(
Content
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment