PageRenderTime 173ms CodeModel.GetById 144ms app.highlight 17ms RepoModel.GetById 6ms app.codeStats 1ms

/rcdk/R/rcdk.R

http://github.com/rajarshi/cdkr
R | 517 lines | 257 code | 50 blank | 210 comment | 44 complexity | 209093b9c83566475080d702efd82b4e MD5 | raw file
  1.packageName <- "rcdk"
  2
  3#' Get the default chemical object builder.
  4#' 
  5#' The CDK employs a builder design pattern to construct
  6#' instances of new chemical objects (e.g., atoms, bonds, parsers
  7#' and so on). Many methods require an instance of a builder 
  8#' object to function. While most functions in this package handle
  9#' this internally, it is useful to be able to get an instance of
 10#' a builder object when directly working with the CDK API via
 11#' `rJava`.
 12#' 
 13#' This method returns an instance of the \href{http://cdk.github.io/cdk/2.2/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder}. 
 14#' Note that this is a static object that is created at package load time, 
 15#' and the same instance is returned whenever this function is called.
 16#' 
 17#' @return An instance of \href{http://cdk.github.io/cdk/2.3/docs/api/org/openscience/cdk/silent/SilentChemObjectBuilder.html}{SilentChemObjectBuilder}
 18#' @export
 19#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
 20get.chem.object.builder <- function() {
 21  return(get("dcob", envir = .rcdk.GlobalEnv))
 22}
 23
 24.check.class <- function(obj, klass) {
 25  !is.null(attr(obj, 'jclass')) && attr(obj, "jclass") == klass
 26}
 27
 28.trim.whitespace <- function(x) {
 29  x <- gsub('^[[:space:]]+', '', x)
 30  gsub('[[:space:]]+$', '',x)
 31}
 32
 33.javalist.to.rlist <- function(l) {
 34  size <- .jcall(l, "I", "size")
 35  if (size == 0) return(list())
 36  rl <- list()
 37  for (i in 1:size)
 38    rl[[i]] <- .jcall(l, "Ljava/lang/Object;", "get", as.integer(i-1))
 39  return(rl)
 40}
 41
 42#'
 43#' @import fingerprint
 44#' @import methods
 45#' @import rJava
 46#' @import png
 47#' @import iterators
 48#' @import itertools
 49#' @import rcdklibs
 50#'
 51.onLoad <- function(lib, pkg) {
 52  dlp<-Sys.getenv("DYLD_LIBRARY_PATH")
 53  if (dlp!="") { # for Mac OS X we need to remove X11 from lib-path
 54    Sys.setenv("DYLD_LIBRARY_PATH"=sub("/usr/X11R6/lib","",dlp))
 55  }
 56
 57  jar.rcdk <- paste(lib,pkg,"cont","rcdk.jar",sep=.Platform$file.sep)
 58  jar.png <- paste(lib,pkg,"cont","com.objectplanet.image.PngEncoder.jar",sep=.Platform$file.sep)
 59  .jinit(classpath=c(jar.rcdk,jar.png))
 60  
 61  # check Java Version 
 62  jv <- .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
 63  if(substr(jv, 1L, 2L) == "1.") {
 64    jvn <- as.numeric(paste0(strsplit(jv, "[.]")[[1L]][1:2], collapse = "."))
 65    if(jvn < 1.8) stop("Java >= 8 is needed for this package but not available")
 66  }
 67
 68  ## generate some Java objects which get reused, so as to avoid repeated .jnew()
 69  nRule <- .jnew("org/openscience/cdk/formula/rules/NitrogenRule");
 70  rdbeRule <- .jnew("org/openscience/cdk/formula/rules/RDBERule");
 71  assign(".rcdk.GlobalEnv", new.env(parent = emptyenv()), envir = topenv())
 72  assign("nRule", nRule, envir = .rcdk.GlobalEnv)
 73  assign("rdbeRule", rdbeRule, envir = .rcdk.GlobalEnv)
 74  assign("dcob", .jcall("org/openscience/cdk/silent/SilentChemObjectBuilder",
 75                        "Lorg/openscience/cdk/interfaces/IChemObjectBuilder;",
 76                        "getInstance"), envir = .rcdk.GlobalEnv)
 77  assign("mfManipulator", .jnew("org/openscience/cdk/tools/manipulator/MolecularFormulaManipulator"), envir = .rcdk.GlobalEnv)
 78  
 79  # Extract the bond order enums so we can return them without going through
 80  # Java each time we want one
 81  assign("BOND_ORDER_SINGLE", J("org.openscience.cdk.interfaces.IBond")$Order$SINGLE,
 82         envir = .rcdk.GlobalEnv)
 83  assign("BOND_ORDER_DOUBLE", J("org.openscience.cdk.interfaces.IBond")$Order$DOUBLE,
 84         envir = .rcdk.GlobalEnv)
 85  assign("BOND_ORDER_TRIPLE", J("org.openscience.cdk.interfaces.IBond")$Order$TRIPLE,
 86         envir = .rcdk.GlobalEnv)
 87  assign("BOND_ORDER_UNSET", J("org.openscience.cdk.interfaces.IBond")$Order$UNSET,
 88         envir = .rcdk.GlobalEnv)
 89  assign("BOND_ORDER_QUADRUPLE", J("org.openscience.cdk.interfaces.IBond")$Order$QUADRUPLE,
 90         envir = .rcdk.GlobalEnv)
 91  assign("BOND_ORDER_QUINTUPLE", J("org.openscience.cdk.interfaces.IBond")$Order$QUINTUPLE,
 92         envir = .rcdk.GlobalEnv)
 93  assign("BOND_ORDER_SEXTUPLE", J("org.openscience.cdk.interfaces.IBond")$Order$SEXTUPLE,
 94         envir = .rcdk.GlobalEnv)
 95}
 96
 97#' Get the current CDK version used in the package.
 98#' 
 99#' @return Returns a character containing the version of the CDK used in this package
100#' @export
101#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
102cdk.version <- function() {
103  .jcall("org.openscience.cdk.CDK", "S", "getVersion")
104}
105
106#' Remove explicit hydrogens.
107#' 
108#' Create an copy of the original structure with explicit hydrogens removed. 
109#' Stereochemistry is updated but up and down bonds in a depiction may need 
110#' to be recalculated. This can also be useful for descriptor calculations.
111#' 
112#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
113#' @return A copy of the original molecule, with explicit hydrogens removed
114#' @seealso \code{\link{get.hydrogen.count}}, \code{\link{get.total.hydrogen.count}}
115#' @export
116#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
117remove.hydrogens <- function(mol) {
118  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
119    stop("molecule must be of class IAtomContainer")
120  newmol <- .jcall('org/openscience/cdk/tools/manipulator/AtomContainerManipulator',
121                   'Lorg/openscience/cdk/interfaces/IAtomContainer;',
122                   'removeHydrogens',
123                   mol);
124  newmol
125}
126
127#' Get total number of implicit hydrogens in the molecule.
128#' 
129#' Counts the number of hydrogens on the provided molecule. As this method 
130#' will sum all implicit hydrogens on each atom it is important to ensure 
131#' the molecule has already been configured (and thus each atom has an 
132#' implicit hydrogen count). 
133#' 
134#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
135#' @return An integer representing the total number of implicit hydrogens
136#' @seealso \code{\link{get.hydrogen.count}}, \code{\link{remove.hydrogens}}
137#' @export
138#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
139get.total.hydrogen.count <- function(mol) {
140  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
141    stop("molecule must be of class IAtomContainer")
142  .jcall('org/openscience/cdk/tools/manipulator/AtomContainerManipulator',
143         'I',
144         'getTotalHydrogenCount',
145         mol);
146}
147
148#' get.exact.mass
149#' 
150#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
151#' @export
152get.exact.mass <- function(mol) {
153  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
154    stop("molecule must be of class IAtomContainer")
155  
156  
157  formulaJ <- .jcall('org/openscience/cdk/tools/manipulator/MolecularFormulaManipulator',
158                     "Lorg/openscience/cdk/interfaces/IMolecularFormula;",
159                     "getMolecularFormula",
160                     mol,
161                     use.true.class=FALSE);
162  
163  
164  ret <- .jcall('org/openscience/cdk/tools/manipulator/MolecularFormulaManipulator',
165                'D',
166                'getTotalExactMass',
167                formulaJ,
168                check=FALSE)
169  
170  ex <- .jgetEx(clear=TRUE)
171  
172  
173  if (is.null(ex)) return(ret)
174  else{
175    print(ex)
176    stop("Couldn't get exact mass. Maybe you have not performed aromaticity, atom type or isotope configuration?")
177  }
178}
179  
180
181#' get.natural.mass
182#' 
183#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
184#' @export
185get.natural.mass <- function(mol) {
186  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
187    stop("molecule must be of class IAtomContainer")
188  ret <- .jcall('org/openscience/cdk/tools/manipulator/AtomContainerManipulator',
189                'D',
190                'getNaturalExactMass',
191                mol,
192                check=FALSE)
193  ex <- .jgetEx(clear=TRUE)
194  if (is.null(ex)) return(ret)
195  else{
196    print(ex)
197    stop("Couldn't get natural mass. Maybe you have not performed aromaticity, atom type or isotope configuration?")
198  }  
199}
200
201#' get.total.charge
202#' 
203#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
204#' @export
205get.total.charge <- function(mol) {
206  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
207    stop("molecule must be of class IAtomContainer")
208  
209  ## check to see if we have partial charges
210  atoms <- get.atoms(mol)
211  pcharges <- unlist(lapply(atoms, get.charge))
212
213  ## If any are null, partial charges were not set, so
214  ## just return the total formal charge
215  if (any(is.null(pcharges))) return(get.total.formal.charge(mol))
216  else {
217    .jcall('org/openscience/cdk/tools/manipulator/AtomContainerManipulator',
218           'D',
219           'getTotalCharge',
220           mol);
221  }
222}
223
224#' get.total.formal.charge
225#' 
226#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
227#' @export
228get.total.formal.charge <- function(mol) {
229  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
230    stop("molecule must be of class IAtomContainer")
231  .jcall('org/openscience/cdk/tools/manipulator/AtomContainerManipulator',
232         'I',
233         'getTotalFormalCharge',
234         mol);
235}
236
237#' Convert implicit hydrogens to explicit.
238#' 
239#' In some cases, a molecule may not have any hydrogens (such as when read
240#' in from an MDL MOL file that did not have hydrogens or SMILES with no
241#' explicit hydrogens). In such cases, this method
242#' will add implicit hydrogens and then convert them to explicit ones. The 
243#' newly added H's will not have any 2D or 3D coordinates associated with them.
244#' Ensure that the molecule has been typed beforehand.
245#' 
246#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
247#' @seealso \code{\link{get.hydrogen.count}}, \code{\link{remove.hydrogens}}, \code{\link{do.typing}}
248#' @export
249#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
250convert.implicit.to.explicit <- function(mol) {
251  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
252    stop("molecule must be of class IAtomContainer")
253
254    if (any(is.null(unlist(lapply(get.atoms(mol), .jcall, returnSig = "Ljava/lang/Integer;", method="getImplicitHydrogenCount"))))) {
255    ## add them in
256    dcob <- get.chem.object.builder()
257    hadder <- .jcall("org/openscience/cdk/tools/CDKHydrogenAdder", "Lorg/openscience/cdk/tools/CDKHydrogenAdder;",
258                     "getInstance", dcob)
259    .jcall(hadder, "V", "addImplicitHydrogens", mol)
260  }
261  .jcall('org/openscience/cdk/tools/manipulator/AtomContainerManipulator', 'V', 'convertImplicitToExplicitHydrogens', mol)
262}
263
264
265#' Get the atoms from a molecule or bond.
266#' 
267#' @param object A `jobjRef` representing either a molecule (`IAtomContainer`) or 
268#' bond (`IBond`) object.
269#' @return A list of `jobjRef` representing the `IAtom` objects in the molecule or bond
270#' @seealso \code{\link{get.bonds}}, \code{\link{get.connected.atoms}}
271#' @export
272#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
273get.atoms <- function(object) {
274  if (is.null(attr(object, 'jclass')))
275    stop("object must be of class IAtomContainer or IObject or IBond")
276  
277  if (attr(object, 'jclass') != "org/openscience/cdk/interfaces/IAtomContainer" &&
278      attr(object, 'jclass') != "org/openscience/cdk/interfaces/IObject" &&
279      attr(object, 'jclass') != "org/openscience/cdk/interfaces/IBond")
280    stop("object must be of class IAtomContainer or IObject or IBond")
281
282  natom <- .jcall(object, "I", "getAtomCount")
283  atoms <- list()
284  for (i in 0:(natom-1))
285    atoms[[i+1]] <- .jcall(object, "Lorg/openscience/cdk/interfaces/IAtom;", "getAtom", as.integer(i))
286  atoms
287}
288
289#' Get the bonds in a molecule.
290#' 
291#' @param mol A `jobjRef` representing the molecule (`IAtomContainer`) object.
292#' @return A list of `jobjRef` representing the bonds (`IBond`) objects in the molecule
293#' @seealso \code{\link{get.atoms}}, \code{\link{get.connected.atoms}}
294#' @export
295#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
296get.bonds <- function(mol) {
297  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
298    stop("molecule must be of class IAtomContainer")
299  
300  nbond <- .jcall(mol, "I", "getBondCount")
301  bonds <- list()
302  for (i in 0:(nbond-1))
303    bonds[[i+1]] <- .jcall(mol, "Lorg/openscience/cdk/interfaces/IBond;", "getBond", as.integer(i))
304  bonds
305}
306
307#' do.aromaticity
308#' 
309#' detect aromaticity of an input compound
310#' 
311#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
312#' @export
313do.aromaticity <- function(mol) {
314  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
315    stop("molecule must be of class IAtomContainer")
316  
317  model <- .jcall("org/openscience/cdk/aromaticity/ElectronDonation",
318                  "Lorg/openscience/cdk/aromaticity/ElectronDonation;",
319                  "daylight")
320  cycles.all <- .jcall("org/openscience/cdk/graph/Cycles", 
321                      "Lorg/openscience/cdk/graph/CycleFinder;",
322                      "all")
323  cycles.6 <- .jcall("org.openscience.cdk.graph.Cycles", 
324                    "Lorg/openscience/cdk/graph/CycleFinder;",
325                    "all", as.integer(6))
326  cycles <- .jcall("org.openscience.cdk.graph.Cycles", 
327                  "Lorg/openscience/cdk/graph/CycleFinder;",
328                  "or", cycles.all, cycles.6)
329  aromaticity <- .jnew("org/openscience/cdk.aromaticity/Aromaticity",
330                       model, cycles)
331  .jcall(aromaticity, "Z", "apply", mol)
332}
333
334#' do.typing
335#' 
336#' configure atom typings.
337#' 
338#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
339#' @export
340do.typing <- function(mol) {
341  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
342    stop("molecule must be of class IAtomContainer")
343  
344  .jcall("org.openscience.cdk.tools.manipulator.AtomContainerManipulator",
345         "V", "percieveAtomTypesAndConfigureAtoms", mol)
346}
347
348#' do.isotopes
349#' 
350#' configure isotopes
351#' 
352#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
353#' @export
354do.isotopes <- function(mol) {
355  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
356    stop("molecule must be of class IAtomContainer")
357  ifac <- .jcall('org.openscience.cdk.config.Isotopes',
358                 'Lorg/openscience/cdk/config/Isotopes;',
359                 'getInstance')
360  .jcall(ifac, 'V', 'configureAtoms', mol)
361}
362
363#' Tests whether the molecule is neutral.
364#' 
365#' The test checks whether all atoms in the molecule have a formal charge of 0.
366#' 
367#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
368#' @return `TRUE` if molecule is neutral, `FALSE` otherwise
369#' @aliases charge
370#' @export
371#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
372is.neutral <- function(mol) {
373  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
374    stop("molecule must be of class IAtomContainer")
375  
376  atoms <- get.atoms(mol)
377  fc <- unlist(lapply(atoms, get.formal.charge))
378  return(all(fc == 0))
379}
380
381#' Tests whether the molecule is fully connected.
382#' 
383#' A single molecule will be represented as a 
384#' \href{https://en.wikipedia.org/wiki/Complete_graph}{complete} graph. 
385#' In some cases, such as for molecules in salt form, or after certain 
386#' operations such as bond splits, the molecular graph may contained 
387#' \href{http://mathworld.wolfram.com/DisconnectedGraph.html}{disconnected components}.
388#' This method can be used to tested whether the molecule is complete (i.e. fully
389#' connected).
390#' 
391#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
392#' @return `TRUE` if molecule is complete, `FALSE` otherwise
393#' @seealso \code{\link{get.largest.component}}
394#' @export
395#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
396#' @examples 
397#' m <- parse.smiles("CC.CCCCCC.CCCC")[[1]]
398#' is.connected(m)
399is.connected <- function(mol) {
400  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
401    stop("molecule must be of class IAtomContainer")
402  
403  .jcall("org.openscience.cdk.graph.ConnectivityChecker",
404         "Z", "isConnected", mol)
405}
406
407#' Gets the largest component in a disconnected molecular graph.
408#' 
409#' A molecule may be represented as a 
410#' \href{http://mathworld.wolfram.com/DisconnectedGraph.html}{disconnected graph}, such as
411#' when read in as a salt form. This method will return the larges connected component
412#' or if there is only a single component (i.e., the molecular graph is 
413#' \href{https://en.wikipedia.org/wiki/Complete_graph}{complete} or fully connected), that
414#' component is returned.
415#' 
416#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
417#' @return The largest component as an `IAtomContainer` object or else the input molecule itself
418#' @seealso \code{\link{is.connected}}
419#' @export
420#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
421#' @examples 
422#' m <- parse.smiles("CC.CCCCCC.CCCC")[[1]]
423#' largest <- get.largest.component(m)
424#' length(get.atoms(largest)) == 6
425get.largest.component <- function(mol) {
426  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
427    stop("molecule must be of class IAtomContainer")
428  
429  isConnected <- .jcall("org.openscience.cdk.graph.ConnectivityChecker",
430                        "Z", "isConnected", mol)
431  if (isConnected) return(mol)
432  molSet <- .jcall("org.openscience.cdk.graph.ConnectivityChecker",
433                   "Lorg/openscience/cdk/interfaces/IAtomContainerSet;",
434                   "partitionIntoMolecules", mol)
435  ncomp <- .jcall(molSet, "I", "getAtomContainerCount")
436  max.idx <- -1
437  max.atom.count <- -1
438  for (i in seq_len(ncomp)) {
439    m <- .jcall(molSet, "Lorg/openscience/cdk/interfaces/IAtomContainer;",
440                "getAtomContainer", as.integer(i-1))
441    natom <- .jcall(m, "I", "getAtomCount")
442    if (natom > max.atom.count) {
443      max.idx <- i
444      max.atom.count <- natom
445    }
446  }
447  m <- .jcall(molSet, "Lorg/openscience/cdk/interfaces/IAtomContainer;",
448              "getAtomContainer", as.integer(max.idx-1))
449  .jcast(m, "org/openscience/cdk/interfaces/IAtomContainer")
450}
451
452#' Get the number of atoms in the molecule.
453#' 
454#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
455#' @return An integer representing the number of atoms in the molecule
456#' @export
457#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
458get.atom.count <- function(mol) {
459  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
460    stop("molecule must be of class IAtomContainer")
461  .jcall(mol, "I", "getAtomCount")
462}
463
464#' Get the title of the molecule.
465#' 
466#' Some molecules may not have a title (such as when parsing in a SMILES
467#' with not title).
468#' 
469#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
470#' @return A character string with the title, `NA` is no title is specified
471#' @seealso \code{\link{set.title}}
472#' @export
473#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
474get.title <- function(mol) {
475  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
476    stop("molecule must be of class IAtomContainer")
477  get.property(mol, "cdk:Title")
478}
479
480#' Set the title of the molecule.
481#' 
482#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
483#' @param title The title of the molecule as a character string. This will overwrite
484#' any pre-existing title. The default value is an empty string.
485#' @seealso \code{\link{get.title}}
486#' @export
487#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
488set.title <- function(mol, title = "") {
489  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
490    stop("molecule must be of class IAtomContainer")
491  set.property(mol, "cdk:Title", title)
492}
493
494#' Generate 2D coordinates for a molecule.
495#' 
496#' Some file formats such as SMILES do not support 2D (or 3D) coordinates
497#' for the atoms. Other formats such as SD or MOL have support for coordinates
498#' but may not include them. This method will generate reasonable 2D coordinates 
499#' based purely on connectivity information, overwriting
500#' any existing coordinates if present. 
501#' 
502#' Note that when depicting a molecule (\code{\link{view.molecule.2d}}), 2D coordinates
503#' are generated, but since it does not modify the input molecule, we do not have access
504#' to the generated coordinates.
505#' 
506#' @param mol The molecule to query. Should be a `jobjRef` representing an `IAtomContainer`
507#' @return The input molecule, with 2D coordinates added
508#' @seealso \code{\link{get.point2d}}, \code{\link{view.molecule.2d}}
509#' @export
510#' @author Rajarshi Guha (\email{rajarshi.guha@@gmail.com})
511generate.2d.coordinates <- function(mol) {
512  if (!.check.class(mol, "org/openscience/cdk/interfaces/IAtomContainer"))
513    stop("molecule must be of class IAtomContainer")
514  
515  .jcall('org/guha/rcdk/util/Misc', 'Lorg/openscience/cdk/interfaces/IAtomContainer;',
516         'getMoleculeWithCoordinates', mol)
517}