PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

Unknown | 87 lines | 81 code | 6 blank | 0 comment | 0 complexity | bb19dcd3141e52442c7669768c3c317e MD5 | raw file
  1. \name{matches}
  2. \alias{match}
  3. \alias{matches}
  4. \alias{smarts}
  5. \alias{substructure}
  6. \alias{is.subgraph}
  7. \alias{get.mcs}
  8. \alias{mcs}
  9. \title{
  10. Perform Substructure Searching & MCS Detection
  11. }
  12. \description{
  13. These functions perform substructure searches of a query, specified
  14. in SMILES or SMARTS forms, over one or more target molecules and maximum
  15. common substructure searches for pairs of molecules.
  16. }
  17. \usage{
  18. matches(query, target, return.matches=FALSE)
  19. is.subgraph(query, target)
  20. get.mcs(mol1, mol2, as.molecule = TRUE)
  21. }
  22. \arguments{
  23. \item{query}{A SMILES or SMARTS string}
  24. \item{target}{A single IAtomContainer object or a list of IAtomContainer objects}
  25. \item{mol1}{An IAtomContainer}
  26. \item{mol2}{An IAtomContainer}
  27. \item{return.matches}{If \code{TRUE} the lists of atom indices that correspond to the matching substructure are returned}
  28. \item{as.molecule}{If \code{TRUE} the MCS is returned as a new \code{IAtomContainer}
  29. object. Otherwise a atom index maping between the two molecules is returned as a 2D
  30. array of integers}
  31. }
  32. \details{
  33. For the case of \code{is.subgraph}, the query molecule must be a single
  34. \code{IAtomContainer} or a valid SMILES string. Note that this method can be
  35. significantly faster than \code{matches}, but is limited by the fact that SMARTS
  36. patterns cannot be specified. This uses the "TurboSubStructure" SMSD method and so
  37. only searches for the first substructure match.
  38. For MCS detection, the default SMSD algorithm is employed and the best scoring MCS is
  39. returned by default. Furthermore, one can obtain the resultant MCS either as an \code{
  40. IAtomContainer} in which the atoms and bonds are clones of the corresponding matching
  41. atoms and bonds in one of the molecule. Or else as a 2D array of dimensions Nx2 of
  42. atom index mappings. Here N is the size of the MCS and the first column represents the
  43. atom index from the first molecule and the second column the atom index from the second
  44. molecule.
  45. Note that since the CDK SMARTS matcher internally will perform aromaticity perception and
  46. atom typing, the target molecules need not have these operations done on them
  47. beforehand for \code{matches} method. However, if \code{is.subgraph} or \code{get.mcs}
  48. is being used, the molecules should have aromaticity detected and atom typing performed
  49. explicitly.
  50. If the atom indices of the matching substructures (in the target molecule) are desired, use the
  51. \code{matches} function directly.
  52. }
  53. \examples{
  54. smiles <- c('CCC', 'c1ccccc1', 'C(C)(C=O)C(CCNC)C1CC1C(=O)')
  55. mols <- sapply(smiles, parse.smiles)
  56. query <- '[#6]=O'
  57. doesMatch <- matches(query, mols)
  58. ## get mappings
  59. mappings <- matches("CCC", mols, TRUE)
  60. }
  61. \value{
  62. For \code{matches} with \code{return.matches = FALSE}, a boolean vector where each element is \code{TRUE} or \code{FALSE} depending on whether
  63. the corresponding element in targets contains the query or not. If \code{return.matches = TRUE}, the return value
  64. is a list of lists. The number of elements of the top level list equals the number of matches. Each element is a list of two elements, named
  65. "match" and "mapping". The first element is \code{TRUE} if the query matched the target. If so, the second element is a list of numeric
  66. vectors, giving the atom indices (0-indexed) of the target atoms that matched the query. If there was no match for this target molecule, this
  67. element will be \code{NULL}
  68. For \code{is.subgraph}, a boolean vector, where each element is TRUE or
  69. FALSE depending on whether the corresponding element in targets contains the query or not.
  70. For \code{get.mcs} an \code{IAtomContainer} object or a 2D array of atom index mappings
  71. between the two molecules.
  72. }
  73. \keyword{programming}
  74. \seealso{
  75. \code{\link{load.molecules}},
  76. \code{\link{get.smiles}},
  77. \code{\link{do.aromaticity}},
  78. \code{\link{do.typing}},
  79. \code{\link{do.isotopes}}
  80. }
  81. \author{Rajarshi Guha (\email{})}