Learn R Programming

PubChemR (version 2.1.4)

get_sdf: Retrieve/Save SDF Data from PubChem

Description

This function sends a request to PubChem to retrieve data in SDF format based on the specified parameters. It then saves the retrieved data as an SDF file in the current working directory (or into the system-specific temporary folder).

Usage

get_sdf(
  identifier,
  namespace = "cid",
  domain = "compound",
  operation = NULL,
  searchtype = NULL,
  path = NULL,
  file_name = NULL,
  options = NULL
)

Value

The function saves the retrieved data as an SDF file in the current working directory and prints a message indicating the file's location.

Arguments

identifier

A vector of compound identifiers, either numeric or character. The type of identifier depends on the namespace parameter. **Note**: identifier must be provided; it cannot be NULL.

namespace

A character string specifying the namespace of the identifier.

Possible values include:

- cid: PubChem Compound Identifier (default)

- name: Chemical name

- smiles: SMILES string

- inchi: InChI string

- inchikey: InChIKey

- formula: Molecular formula

- Other namespaces as specified in the API documentation.

For more details, see the Input section of the PUG REST API.

domain

A character string specifying the domain of the query.

Possible values include:

- compound (default)

- Other domains as specified in the API documentation.

operation

A character string specifying the operation to perform. For SDF retrieval, the operation is typically NULL or record. If NULL (default), the basic compound record is retrieved. For more details, see the Operations section of the PUG REST API.

searchtype

An optional character string specifying the search type.

Possible values include:

- substructure

- superstructure

- similarity

- identity

- Other search types as specified in the API documentation.

If NULL (default), no search type is specified.

For more details, see the Input section of the PUG REST API.

path

A character string specifying the directory path where the SDF file will be saved. If NULL (default), the file is saved in a temporary directory.

file_name

A character string specifying the name of the SDF file (without file extension). If NULL (default), a file name is generated based on the identifier and timestamp.

options

A list of additional options for the request. Available options depend on the specific request and the API. If NULL (default), no additional options are included. For more details, see the Structure Search Operations section of the PUG REST API.

Details

The PubChem PUG REST API allows users to retrieve compound data in various formats, including SDF. This function constructs the appropriate API call and saves the SDF data to a file. For more detailed information, please refer to the PubChem PUG REST API documentation.

Examples

Run this code
get_sdf(
  identifier = "aspirin",
  namespace = "name",
  path = NULL
)

Run the code above in your browser using DataLab