add_property: Add or Merge Properties for RCSB PDB Data Fetching

View source: R/add_property.R

add_propertyR Documentation

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)

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.

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.

Note

It is important to ensure that the subproperties are correctly formatted as character vectors. The function does not modify the format of the subproperties.

See Also

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

Examples

# 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)


rPDBapi documentation built on Sept. 11, 2024, 6:37 p.m.