get_properties {PubChemR} | R Documentation |
Retrieve Compound Properties from PubChem
Description
This function sends a request to PubChem to retrieve compound properties based on the specified parameters.
Usage
get_properties(
properties = NULL,
identifier,
namespace = "cid",
searchtype = NULL,
options = NULL,
propertyMatch = list(.ignore.case = FALSE, type = "contain")
)
property_map(
x,
type = c("match", "contain", "start", "end", "all"),
.ignore.case = TRUE,
...
)
Arguments
properties |
A character vector specifying the properties to be retrieved. It is ignored if all available properties are requested from PubChem. See examples. |
identifier |
A vector of positive integers (e.g., CID, SID, AID) or identifier strings (e.g., source, InChIKey, formula). In some cases, only a single identifier string is allowed (e.g., name, SMILES, xref; InChI, SDF by POST only). |
namespace |
Specifies the namespace for the query. For the 'compound' domain, possible values include 'cid', 'name', 'smiles', 'inchi', 'sdf', 'inchikey', 'formula', 'substructure', 'superstructure', 'similarity', 'identity', 'xref', 'listkey', 'fastidentity', 'fastsimilarity_2d', 'fastsimilarity_3d', 'fastsubstructure', 'fastsuperstructure', and 'fastformula'. For other domains, the possible namespaces are domain-specific. |
searchtype |
Specifies the type of search to be performed. For structure searches, possible values are combinations of 'substructure', 'superstructure', 'similarity', 'identity' with 'smiles', 'inchi', 'sdf', 'cid'. For fast searches, possible values are combinations of 'fastidentity', 'fastsimilarity_2d', 'fastsimilarity_3d', 'fastsubstructure', 'fastsuperstructure' with 'smiles', 'smarts', 'inchi', 'sdf', 'cid', or 'fastformula'. |
options |
Additional arguments passed to |
propertyMatch |
A list containing the arguments passed to the property_map function. See examples of the |
x |
A character vector of compound properties. The property_map function will search for each property provided here within the available properties. The search can be customized using the |
type |
Defines how to search within the available properties. The default is "match". See Notes for details. |
.ignore.case |
A logical value. If TRUE, the pattern match ignores case letters. This argument is ignored if |
... |
Other arguments. Currently, these have no effect on the function's return. |
Value
An object of class "PubChemInstanceList" containing all the properties of the requested compounds.
Note
Property Map:
property_map()
is not used to request properties directly from the PubChem database. This function is intended to list the available compound properties that can be requested from PubChem. It has flexible options to search properties from the available property list of the PubChem database. The output of property_map is used as the property
input in the get_properties function. This function may be practically used to request specific properties across a range of compounds. See examples for usage.
Examples
# Isomeric SMILES of the compounds
props <- get_properties(
properties = c("MolecularWeight", "MolecularFormula", "InChI"),
identifier = c("aspirin", "ibuprofen", "caffeine"),
namespace = "name"
)
# Properties for a selected compound
instance(props, "aspirin")
retrieve(props, .which = "aspirin", .slot = NULL)
retrieve(instance(props, "aspirin"), .slot = NULL)
# Combine properties of all compounds into a single data frame (or list)
retrieve(props, .combine.all = TRUE)
# Return selected properties
retrieve(props, .combine.all = TRUE,
.slot = c("MolecularWeight", "MolecularFormula"))
# Return properties for the compounds in a range of CIDs
props <- get_properties(
properties = c("mass", "molecular"),
identifier = 2244:2255,
namespace = "cid",
propertyMatch = list(
type = "contain"
)
)
retrieve(props, .combine.all = TRUE, .to.data.frame = TRUE)
# Return all available properties of the requested compounds
props <- get_properties(
properties = NULL,
identifier = 2244:2245,
namespace = "cid",
propertyMatch = list(
type = "all"
)
)
retrieve(props, .combine.all = TRUE)
#### EXAMPLES FOR property_map() ####
# List all available properties:
property_map(type = "all")
# Exact match:
property_map("InChI", type = "match")
property_map("InChi", type = "match",
.ignore.case = TRUE) # Returns no match. Ignores '.ignore.case'
# Match at the start/end:
property_map("molecular", type = "start", .ignore.case = TRUE)
property_map("mass", type = "end", .ignore.case = TRUE)
# Partial match with multiple search patterns:
property_map(c("molecular", "mass", "inchi"),
type = "contain", .ignore.case = TRUE)