Closed meowcat closed 7 years ago
I figured out it's probably a problem arising because rcdk doesn't use the same Cdk version as Metfrag...
In fact I got the Fragmenter with peaks constructor + generateFragmentsInMemory to work when I loaded the metfrag cdk lib before rcdk (but then I can't actually use the rcdk functions anymore, have to make my molecule by hand, and can't display the fragments.)
Hi,
I hacked MetFrag so it runs rudimentarily with the 1.4.something cdk version from rcdklibs (I can get the fragmenter to work from R; there are possibly many more changes which need to be done but I have no idea.) If you're interested, I can push it to some fork of your repo...
Minimal R example:
mf.path <- "C:/Daten/Sourcecode/metfrag/c-ruttkies/MetFrag/bin"
library(rJava)
#rcdk "rcdk" "C:/Daten/R/R-3.0.0" "3.2.0.2" NA
#rcdklibs "rcdklibs" "C:/Daten/R/R-3.0.0" "1.5.0.3" NA
library(rcdk)
.jaddClassPath(mf.path)
#.jaddClassPath(mf.lib.path)
# make a Fragmenter
fobj <- new( J("de/ipbhalle/metfrag/fragmenter/Fragmenter"), F, T, F)
# load a molecule: Venlafaxine
m <- parse.smiles("CN(C)CC(C1=C=C(C=C1)OC)C2(CCCCC2)O")
m <- m[[1]]
# preprocess as MetFrag would
J("org/openscience/cdk/tools/manipulator/AtomContainerManipulator")$percieveAtomTypesAndConfigureAtoms(m)
convert.implicit.to.explicit(m)
# Even if this is not actually a Vector<Peak> it works. Maybe it's because Java
# generics are implemented strangely or because it's an empty vector - rJava doesn't have
# a way to specify signatures of Java generic classes.
# Omitting to set a peaklist results in NullPointerException during generateFragmentsInMemory
v <- new(J("java/util/Vector"))
fobj$setPeakList(v)
frags <- fobj$generateFragmentsInMemory(m, F, as.integer(3))
frags <- as.list(frags)
view.molecule.2d(frags)
Hi,
sorry for the delay. I was not really monitoring the progress of this repo the last time. We currently want to start developing the package further and to include your ideas. Nice hacks you pasted here. It is planned to extract the fragments of individual candidate molecules directly. After reading your code I think this is also in your own interest.
Best regards, Christoph
Hi,
I was toying around in R and Steffen notified me that there actually is a MetFragR package. I had an idea specific to transformation product identification and hoped that I could use some MetFrag features from it - specifically the Fragmenter.
I already tried with R and rJava calls, but up to now haven't had success... It would be really cool if I could use features like this directly.
The .jrcall() calls usually work fine with Java generics, I have used them before with success.
A piece of code to show what I wanted to do: