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
d05725f5
Commit
d05725f5
authored
9 years ago
by
Michele Stravs
Browse files
Options
Downloads
Patches
Plain Diff
Fix in findMz.formula so it works correctly for "special" cases like findMz.formula("", "mH")
parent
94380d9d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/formulaCalculator.R
+12
-0
12 additions, 0 deletions
R/formulaCalculator.R
R/leCsvAccess.R
+42
-17
42 additions, 17 deletions
R/leCsvAccess.R
with
54 additions
and
17 deletions
R/formulaCalculator.R
+
12
−
0
View file @
d05725f5
...
...
@@ -342,3 +342,15 @@ ppm <- function(mass, dppm, l=FALSE, p=FALSE)
.emass
<-
0.0005485799
## pmass <- 1.007276565
## hmass <- 1.007825
split.formula.posneg
<-
function
(
f
,
as.formula
=
TRUE
,
as.list
=
FALSE
)
{
if
(
!
is.list
(
f
))
f
<-
formulastring.to.list
(
f
)
pos
<-
f
[
which
(
f
>
0
)]
neg
<-
f
[
which
(
f
<
0
)]
if
(
as.formula
&
!
as.list
)
return
(
list
(
pos
=
list.to.formula
(
pos
),
neg
=
list.to.formula
(
neg
)))
else
return
(
list
(
pos
=
pos
,
neg
=
neg
))
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
R/leCsvAccess.R
+
42
−
17
View file @
d05725f5
...
...
@@ -336,25 +336,50 @@ getMolecule <- function(smiles)
#' @examples findMz.formula("C6H6")
#' @seealso \code{\link{findMz}}
#' @export
findMz.formula
<-
function
(
formula
,
mode
=
"pH"
,
ppm
=
10
,
deltaMz
=
0
)
findMz.formula
<-
function
(
formula
,
mode
=
"pH"
,
ppm
=
10
,
deltaMz
=
0
)
{
if
(
!
any
(
mode
%in%
c
(
"pH"
,
"pNa"
,
"pM"
,
"pNH4"
,
"mH"
,
"mFA"
,
"mM"
,
""
)))
stop
(
paste
(
"The ionization mode"
,
mode
,
"is unknown."
))
mzopt
<-
list
(
addition
=
""
,
charge
=
0
)
if
(
mode
==
"pH"
)
mzopt
<-
list
(
addition
=
"H"
,
charge
=
1
)
if
(
mode
==
"pNa"
)
mzopt
<-
list
(
addition
=
"Na"
,
charge
=
1
)
if
(
mode
==
"pM"
)
mzopt
<-
list
(
addition
=
""
,
charge
=
1
)
if
(
mode
==
"pNH4"
)
mzopt
<-
list
(
addition
=
"NH4"
,
charge
=
-1
)
if
(
mode
==
"mH"
)
mzopt
<-
list
(
addition
=
"H-1"
,
charge
=
-1
)
if
(
mode
==
"mFA"
)
mzopt
<-
list
(
addition
=
"C1O2"
,
charge
=
-1
)
if
(
mode
==
"mM"
)
mzopt
<-
list
(
addition
=
""
,
charge
=
-1
)
if
(
mode
==
""
)
mzopt
<-
list
(
addition
=
""
,
charge
=
0
)
if
(
!
any
(
mode
%in%
c
(
"pH"
,
"pNa"
,
"pM"
,
"pNH4"
,
"mH"
,
"mFA"
,
"mM"
,
""
)))
stop
(
paste
(
"The ionization mode"
,
mode
,
"is unknown."
))
mzopt
<-
list
(
addition
=
""
,
charge
=
0
)
if
(
mode
==
"pH"
)
mzopt
<-
list
(
addition
=
"H"
,
charge
=
1
)
if
(
mode
==
"pNa"
)
mzopt
<-
list
(
addition
=
"Na"
,
charge
=
1
)
if
(
mode
==
"pM"
)
mzopt
<-
list
(
addition
=
""
,
charge
=
1
)
if
(
mode
==
"pNH4"
)
mzopt
<-
list
(
addition
=
"NH4"
,
charge
=
-1
)
if
(
mode
==
"mH"
)
mzopt
<-
list
(
addition
=
"H-1"
,
charge
=
-1
)
if
(
mode
==
"mFA"
)
mzopt
<-
list
(
addition
=
"C1O2"
,
charge
=
-1
)
if
(
mode
==
"mM"
)
mzopt
<-
list
(
addition
=
""
,
charge
=
-1
)
if
(
mode
==
""
)
mzopt
<-
list
(
addition
=
""
,
charge
=
0
)
formula
<-
add.formula
(
formula
,
mzopt
$
addition
)
formula
<-
get.formula
(
formula
,
charge
=
mzopt
$
charge
)
m
<-
formula
@
mass
delta
<-
ppm
(
m
,
ppm
,
l
=
TRUE
)
return
(
list
(
mzMin
=
delta
[[
2
]]
-
deltaMz
,
mzMax
=
delta
[[
1
]]
+
deltaMz
,
mzCenter
=
m
))
# Since in special cases we want to use this with negative and zero number of atoms, we account for this case
# by splitting up the formula into positive and negative atom counts (this eliminates the zeroes.)
formula.split
<-
split.formula.posneg
(
formula
)
m
<-
0
if
(
formula.split
$
pos
!=
""
)
{
formula.pos
<-
get.formula
(
formula.split
$
pos
,
charge
=
mzopt
$
charge
)
m
=
m
+
formula.pos
@
mass
}
if
(
formula.split
$
neg
!=
""
)
{
formula.neg
<-
get.formula
(
formula.split
$
neg
,
charge
=
-
mzopt
$
charge
)
m
=
m
-
formula.neg
@
mass
}
if
((
nchar
(
formula.split
$
pos
)
==
0
)
&
(
nchar
(
formula.split
$
neg
)
==
0
))
{
m
<-
get.formula
(
"H"
,
charge
=
mzopt
$
charge
)
@
mass
-
get.formula
(
"H"
,
charge
=
0
)
@
mass
}
delta
<-
ppm
(
m
,
ppm
,
l
=
TRUE
)
return
(
list
(
mzMin
=
delta
[[
2
]]
-
deltaMz
,
mzMax
=
delta
[[
1
]]
+
deltaMz
,
mzCenter
=
m
))
}
#' Find compound information
...
...
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