Learn R Programming

rPDBapi (version 2.1.1)

add_property: Add or Merge Properties for RCSB PDB Data Fetching

Description

This function facilitates the management of properties and subproperties required for data retrieval from the Protein Data Bank (PDB). It accepts a list of properties where each key represents a property category (e.g., 'cell', 'exptl'), and the corresponding value is a character vector of subproperties (e.g., 'volume', 'method'). The function ensures that if a property already exists, its subproperties are merged without duplication, guaranteeing that each subproperty remains unique.

Usage

add_property(property)

Value

A modified list that consolidates the input properties. If a property already exists in the input list, its subproperties are merged, removing any duplicates.

Arguments

property

A list where each element corresponds to a property category. The names of the list elements are the properties, and their values are character vectors containing the subproperties. Each subproperty should be provided as a character vector. The full list of available properties and their descriptions can be found at https://data.rcsb.org/#data-schema.

For example, a `property` list might look like:

cell

A character vector of subproperties like "length_a", "length_b", "length_c".

exptl

A character vector of subproperties like "method".

Details

The `add_property` function is particularly useful when users need to dynamically build or update a list of properties required for complex queries in the PDB. By automatically handling duplicate entries, this function streamlines the process of constructing property lists, which can then be used in subsequent data retrieval operations.

The function operates as follows:

  1. Checks if the input `property` is a list. If not, it throws an error.

  2. Iterates through each property in the list, ensuring that subproperties are unique and in character vector format.

  3. If a property already exists in the list, it merges the subproperties while eliminating duplicates.

See Also

fetch_data, query_search for related functions that utilize properties in querying the PDB.

Examples

Run this code
# Example usage:
properties <- list(cell = c("length_a", "length_b", "length_c"), exptl = c("method"))
# Add new properties or merge existing ones
updated_properties <- add_property(properties)
print(updated_properties)

Run the code above in your browser using DataLab