### REST API Request Examples for RCSB PDB Data Source: https://data.rcsb.org/docs/index Demonstrates how to construct HTTP GET requests to access specific data resources via the RCSB PDB REST API. It highlights the structure of endpoints for entries, polymer entities, and polymer entity instances, including PDB IDs and other identifiers as path parameters. ```http https://data.rcsb.org/rest/v1/core/entry/4HHB https://data.rcsb.org/rest/v1/core/polymer_entity/4HHB/1 https://data.rcsb.org/rest/v1/core/polymer_entity_instance/4HHB/A ``` -------------------------------- ### GraphQL Successful Response Example Source: https://data.rcsb.org/docs/index Illustrates the JSON format of a successful response from the GraphQL server. It contains a 'data' object with the queried information. ```json { "data": { "entry": { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } } } ``` -------------------------------- ### GraphQL: Query Entry Experimental Method with Variables Source: https://context7.com/context7/data_rcsb/llms.txt This example demonstrates how to query the experimental method for a specific entry using variables in a GraphQL request. It utilizes cURL to send a POST request to the RCSB GraphQL endpoint. ```bash curl -X POST https://data.rcsb.org/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "query ExptlMethod($id: String!) { entry(entry_id: $id) { exptl { method } } }", "variables": {"id": "4HHB"} }' ``` -------------------------------- ### GraphQL: Query Polymer Instance Annotations Source: https://context7.com/context7/data_rcsb/llms.txt This example shows how to query structural domain assignments, classifications, and positional features for specified polymer instances using GraphQL. It uses cURL for the POST request. ```bash curl -X POST https://data.rcsb.org/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "query { polymer_entity_instances(instance_ids: [\"4HHB.A\", \"12CA.A\"]) { rcsb_id rcsb_polymer_instance_annotation { annotation_id name type } } }" }' ``` -------------------------------- ### GraphQL API GET Request with Query and Variables Source: https://data.rcsb.org/docs/index Illustrates a more advanced GraphQL query to the RCSB PDB API using HTTP GET. This example demonstrates passing query variables (like entry_id) as a URL-encoded 'variables' parameter, alongside the main query. ```graphql query exptl_method($id: String!) { entry(entry_id:$id) { exptl { method } } } { "id": "4HHB" } ``` -------------------------------- ### GraphQL POST Request Body Example Source: https://data.rcsb.org/docs/index Demonstrates the structure of a valid JSON-encoded body for a GraphQL POST request. It includes the required 'query' field and an optional 'variables' field for dynamic queries. ```json { "query": "query($id: String!){entry(entry_id:$id){exptl{method}}}", "variables": {"id": "4HHB"} } ``` -------------------------------- ### GraphQL: Hierarchical Traversal from Polymer Entity to Entry Source: https://context7.com/context7/data_rcsb/llms.txt This example shows how to perform a hierarchical traversal in GraphQL, querying polymer entity details and then traversing up to the entry level to retrieve experimental methods. It uses cURL for the POST request. ```bash curl -X POST https://data.rcsb.org/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "query { polymer_entity(entry_id: \"4HHB\", entity_id: \"1\") { rcsb_entity_source_organism { ncbi_scientific_name } entry { exptl { method } } } }" }' ``` -------------------------------- ### Query Entry and Polymer Data with rcsb-api (Python) Source: https://context7.com/context7/data_rcsb/llms.txt This Python snippet utilizes the `rcsb-api` package to query entry data and polymer entities. It shows how to install the package, query basic entry information (like experimental method), and retrieve details for multiple polymer entities across different entries, including organism scientific names. It also demonstrates field selection for more specific data retrieval. ```python # Install: pip install rcsb-api from rcsbapi.data import Schema, DataQuery # Query entry data query = DataQuery( input_type=Schema.ENTRY, input_ids={"entry_id": "4HHB"} ) result = query.exec() print(result["exptl"][0]["method"]) # Query multiple polymer entities query = DataQuery( input_type=Schema.POLYMER_ENTITY, input_ids={ "entity_id": "1", "entry_id": ["4HHB", "12CA", "3PQR"] } ) results = query.exec() for entity in results: organism = entity["rcsb_entity_source_organism"][0] print(f"{entity['rcsb_id']}: {organism['ncbi_scientific_name']}") # Query with field selection query = DataQuery( input_type=Schema.ENTRY, input_ids={"entry_id": ["1STP", "2JEF"]}, return_data_list=[ "struct.title", "exptl.method", "rcsb_primary_citation.pdbx_database_id_DOI" ] ) results = query.exec() ``` -------------------------------- ### Fetch Organism Name and Experimental Method for a Polymer Entity Source: https://data.rcsb.org/docs/index Demonstrates how to traverse edges in GraphQL to fetch data from different levels of the hierarchy. This example retrieves the scientific name of the source organism for a polymer entity and the experimental method used at the entry level. ```APIDOC ## POST /graphql ### Description Fetches the source organism's scientific name for a polymer entity and the experimental method of its associated entry. ### Method POST ### Endpoint /graphql ### Parameters #### Query Parameters - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query={ polymer_entity(entry_id: \"4HHB\", entity_id:\"1\") { rcsb_entity_source_organism { ncbi_scientific_name } entry { exptl { method } } } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **polymer_entity** (object) - Information about the polymer entity. - **rcsb_entity_source_organism** (object) - Source organism details. - **ncbi_scientific_name** (string) - The scientific name of the organism. - **entry** (object) - Information about the associated entry. - **exptl** (array) - List of experimental details. - **method** (string) - The experimental method used. #### Response Example ```json { "data": { "polymer_entity": { "rcsb_entity_source_organism": { "ncbi_scientific_name": "Homo sapiens" }, "entry": { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } } } } ``` ``` -------------------------------- ### GraphQL: Query Sequence Positional Features for Polymer Instance Source: https://context7.com/context7/data_rcsb/llms.txt This example demonstrates querying annotated regions such as binding sites, active sites, and secondary structures with their sequence coordinates for a given polymer instance. It uses cURL for the POST request. ```bash curl -X POST https://data.rcsb.org/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "query { polymer_entity_instances(instance_ids: [\"1NDO.A\"]) { rcsb_id rcsb_polymer_instance_feature { type feature_positions { beg_seq_id end_seq_id } } } }" }' ``` -------------------------------- ### Query Integrative Structure Metadata via cURL Source: https://context7.com/context7/data_rcsb/llms.txt This example demonstrates querying metadata for integrative structures, including entry information and input dataset details, using cURL and GraphQL. It retrieves the RCSB ID, multi-scale and ensemble flags, and information about linked databases and datasets for a given entry. ```bash curl -X POST https://data.rcsb.org/graphql \ -H "Content-Type: application/json" \ -d '{ \ "query": "query { entries(entry_ids: [\"8ZZ3\"]) { rcsb_id rcsb_entry_info { ihm_multi_scale_flag ihm_ensemble_flag } rcsb_ihm_dataset_source_db_reference { db_name accession_code } rcsb_ihm_dataset_list { name type count } } }" \ }' ``` -------------------------------- ### Query Chemical Components by ID Source: https://data.rcsb.org/docs/index Query the chemical component dictionary for specific items using a list of CCD IDs. This example retrieves the RCSB ID, name, formula, and formula weight for the specified components. ```graphql query={ chem_comps(comp_ids:["NAG", "EBW"]) { rcsb_id chem_comp { type formula_weight name formula } rcsb_chem_comp_info { initial_release_date } } } ``` -------------------------------- ### GraphQL Error Response Example Source: https://data.rcsb.org/docs/index Shows a typical GraphQL error message returned when a query fails, such as requesting an undefined field. The 'errors' array details the validation issues. ```json { "data": null, "errors": [ { "message": "Validation error of type FieldUndefined: Field 'foo' in type 'Exptl' is undefined @ 'entry/exptl/foo'", "locations": [ { "line": 4, "column": 7, "sourceName": null } ], "description": "Field 'foo' in type 'Exptl' is undefined", "validationErrorType": "FieldUndefined", "queryPath": [ "entry", "exptl", "foo" ], "errorType": "ValidationError", "path": null, "extensions": null } ] } ``` -------------------------------- ### GraphQL: Query Polymer Entities with Taxonomy and Cluster Data Source: https://context7.com/context7/data_rcsb/llms.txt This example demonstrates querying multiple polymer entities to retrieve their taxonomy information and sequence cluster membership. It uses cURL to send a POST request with a JSON payload. ```bash curl -X POST https://data.rcsb.org/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "query { polymer_entities(entity_ids: [\"2CPK_1\", \"3WHM_1\", \"2D5Z_1\"]) { rcsb_id rcsb_entity_source_organism { ncbi_taxonomy_id ncbi_scientific_name } rcsb_cluster_membership { cluster_id identity } } }" }' ``` -------------------------------- ### REST API: Fetch Entry Data Source: https://context7.com/context7/data_rcsb/llms.txt Retrieves complete structure information for a PDB entry using an HTTP GET request. Returns comprehensive JSON data including experimental methods, structural hierarchy, and metadata. ```APIDOC ## GET /rest/v1/core/entry/{entry_id} ### Description Retrieve complete structure information for a PDB entry. ### Method GET ### Endpoint `/rest/v1/core/entry/{entry_id}` ### Parameters #### Path Parameters - **entry_id** (string) - Required - The PDB entry identifier. ### Request Example ```bash curl https://data.rcsb.org/rest/v1/core/entry/4HHB ``` ### Response #### Success Response (200) - **rcsb_entry_container_identifiers** (object) - Identifiers for the entry. - **struct** (object) - Structural information including title. - **exptl** (array) - List of experimental methods used. - **rcsb_accession_info** (object) - Accession information including release date. #### Response Example ```json { "rcsb_entry_container_identifiers": { "entry_id": "4HHB", "polymer_entity_ids": ["1", "2"], "nonpolymer_entity_ids": ["3", "4"] }, "struct": { "title": "THE CRYSTAL STRUCTURE OF HUMAN DEOXYHAEMOGLOBIN AT 1.74 ANGSTROMS RESOLUTION" }, "exptl": [ { "method": "X-RAY DIFFRACTION" } ], "rcsb_accession_info": { "initial_release_date": "1984-03-07T00:00:00Z" } } ``` ``` -------------------------------- ### Query Integrative Structures Data Source: https://data.rcsb.org/docs/index Query for integrative structures to obtain information on model composition, input datasets, and their source databases. This example retrieves details for multiple entry IDs. ```graphql query={ entries(entry_ids: ["8ZZ3", "8ZZ4", "9A2F"]) { rcsb_id rcsb_entry_info { ihm_multi_scale_flag ihm_multi_state_flag ihm_ordered_state_flag ihm_ensemble_flag } rcsb_ihm_dataset_source_db_reference { db_name accession_code } rcsb_ihm_dataset_list { name type count } } } ``` -------------------------------- ### RCSB Entry Container Identifiers Example (JSON) Source: https://data.rcsb.org/docs/index This JSON snippet demonstrates the structure of the `rcsb_entry_container_identifiers` object, which links an entry ID to its associated polymer, branched, and non-polymer entity IDs. This is a common pattern for organizing related data within the RCSB PDB schema. ```json { "rcsb_entry_container_identifiers": { "entry_id": "3PQR", "polymer_entity_ids": ["1", "2"], "branched_entity_ids": ["3", "4"], "non_polymer_entity_ids": ["5", "6", "7", "8", "9", "10"] } } ``` -------------------------------- ### Fetch PDB Entry Data via REST API Source: https://context7.com/context7/data_rcsb/llms.txt Retrieves complete structural information for a given PDB entry using an HTTP GET request to the REST API. The response is in JSON format and includes identifiers, title, and experimental methods. This is useful for obtaining a summary of a specific PDB entry. ```bash # Fetch entry data for hemoglobin structure curl https://data.rcsb.org/rest/v1/core/entry/4HHB # Response (partial): { "rcsb_entry_container_identifiers": { "entry_id": "4HHB", "polymer_entity_ids": ["1", "2"], "nonpolymer_entity_ids": ["3", "4"] }, "struct": { "title": "THE CRYSTAL STRUCTURE OF HUMAN DEOXYHAEMOGLOBIN AT 1.74 ANGSTROMS RESOLUTION" }, "exptl": [ { "method": "X-RAY DIFFRACTION" } ], "rcsb_accession_info": { "initial_release_date": "1984-03-07T00:00:00Z" } } ``` -------------------------------- ### Fetch Experimental Method for Multiple Entries Source: https://data.rcsb.org/docs/index Demonstrates how to fetch the experimental method name for multiple PDB entries using a GraphQL query. ```APIDOC ## POST /graphql ### Description Fetches the experimental method for a list of PDB entries. ### Method POST ### Endpoint /graphql ### Parameters #### Query Parameters - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query={ entries(entry_ids: [\"4HHB\", \"12CA\", \"3PQR\"]) { exptl { method } } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **entries** (array) - List of entry objects. - **exptl** (array) - List of experimental details. - **method** (string) - The experimental method used. #### Response Example ```json { "data": { "entries": [ { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] }, { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] }, { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } ] } } ``` ``` -------------------------------- ### Fetch Experimental Method for Multiple PDB Entries (GraphQL) Source: https://data.rcsb.org/docs/index This GraphQL query retrieves the experimental method name for a list of PDB entry IDs. It demonstrates the basic structure of a root query for entries and accessing nested fields like 'exptl' and 'method'. ```graphql query={ entries(entry_ids: ["4HHB", "12CA", "3PQR"]) { exptl { method } } } ``` -------------------------------- ### GraphQL API GET Request with Query Parameter Source: https://data.rcsb.org/docs/index Shows how to make a GraphQL query to the RCSB PDB API using an HTTP GET request. The GraphQL query is embedded directly within the URL as a URL-encoded 'query' parameter. ```http https://data.rcsb.org/graphql?query={entry(entry_id:"4HHB"){exptl{method}}} ``` -------------------------------- ### Query PDB Entry Experimental Method via GraphQL Source: https://context7.com/context7/data_rcsb/llms.txt Executes a basic GraphQL query to fetch the experimental method for a specific PDB entry. This demonstrates how to use the GraphQL endpoint for targeted data retrieval, specifying the exact fields required. ```bash # GET request: Query experimental method for entry 4HHB curl -G https://data.rcsb.org/graphql \ --data-urlencode 'query={entry(entry_id:"4HHB"){exptl{method}}}' # Response: { "data": { "entry": { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } } } ``` -------------------------------- ### REST-based API Endpoints Source: https://data.rcsb.org/docs/index Access PDB data using HTTP GET requests to various endpoints. Compound identifiers are passed as path parameters. ```APIDOC ## REST-based API ### Description The REST-based API supports the HTTP GET method to access the PDB data through a set of endpoints (or URLs). ### Method GET ### Endpoint `https://data.rcsb.org/rest/v1/core/{resource_type}/{identifier}` ### Parameters #### Path Parameters - **resource_type** (string) - Required - The type of resource to query (e.g., `entry`, `polymer_entity`, `polymer_entity_instance`, `chemical_component`). - **identifier** (string) - Required - The identifier for the resource. This can be a PDB ID, entity ID, or chain ID depending on the `resource_type`. ### Request Example `GET https://data.rcsb.org/rest/v1/core/entry/4HHB` `GET https://data.rcsb.org/rest/v1/core/polymer_entity/4HHB/1` `GET https://data.rcsb.org/rest/v1/core/polymer_entity_instance/4HHB/A` ### Response #### Success Response (200) - **(object)** - JSON object containing the requested data. #### Response Example ```json { "id": "4HHB", "title": "HEMOGLOBIN", "structure_id": "4HHB", "..other_fields": "..." } ``` #### Error Response (404) - **(object)** - Indicates that the data was not found or the endpoint is invalid. #### Error Response Example ```json { "message": "Not Found" } ``` ``` -------------------------------- ### GraphQL: Basic Entry Query Source: https://context7.com/context7/data_rcsb/llms.txt Execute declarative queries to fetch exactly the fields needed using the GraphQL endpoint. ```APIDOC ## POST /graphql ### Description Execute declarative GraphQL queries to fetch specific data fields. ### Method GET or POST ### Endpoint `https://data.rcsb.org/graphql` ### Parameters #### Query Parameters (for GET requests) - **query** (string) - Required - The GraphQL query string. #### Request Body (for POST requests) - **query** (string) - Required - The GraphQL query string. ### Request Example (GET) ```bash curl -G https://data.rcsb.org/graphql \ --data-urlencode 'query={entry(entry_id:"4HHB"){exptl{method}}}' ``` ### Response #### Success Response (200) - **data** (object) - Contains the results of the GraphQL query. #### Response Example (GET) ```json { "data": { "entry": { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } } } ``` ``` -------------------------------- ### GraphQL-based API Source: https://data.rcsb.org/docs/index Interact with the PDB data using GraphQL queries directed at a single endpoint. Supports GET and POST methods with query parameters or variables. ```APIDOC ## GraphQL-based API ### Description The GraphQL API allows for flexible data querying through a single endpoint. Queries can be sent via HTTP GET or POST requests. ### Method GET, POST ### Endpoint `https://data.rcsb.org/graphql` ### Parameters #### Query Parameters (for GET requests) - **query** (string) - Required - The GraphQL query string. - **variables** (string) - Optional - A URL-encoded JSON string containing query variables. ### Request Example (GET with query string) `GET https://data.rcsb.org/graphql?query={entry(entry_id:"4HHB"){exptl{method}}}` ### Request Example (GET with query and variables) `GET https://data.rcsb.org/graphql?query=query%20exptl_method($id:%20String!)%20%7B%0A%20%20entry(entry_id:%24id)%20%7B%0A%20%20%20%20exptl%20%7B%0A%20%20%20%20%20%20method%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D&variables=%7B%22id%22:%20%224HHB%22%7D` ### Request Example (POST) ```json { "query": "query exptl_method($id: String!) { entry(entry_id:$id) { exptl { method } } }", "variables": { "id": "4HHB" } } ``` ### Response #### Success Response (200) - **(object)** - JSON object containing the results of the GraphQL query. #### Response Example ```json { "data": { "entry": { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } } } ``` ``` -------------------------------- ### Computed Structure Models API Source: https://data.rcsb.org/docs/index Retrieve a list of global Model Quality Assessment metrics for computed structure models, such as AlphaFold predictions. Example shows metrics for Hemoglobin subunit beta. ```APIDOC ## Computed Structure Models ### Description This example shows how to get a list of global Model Quality Assessment metrics for AlphaFold structure of Hemoglobin subunit beta. ### Method POST ### Endpoint /graphql ### Parameters #### Request Body - **query** (string) - Required - GraphQL query string. ### Request Example ```json { "query": "query={ entries(entry_ids: [\"AF_AFP68871F1\"]) { rcsb_ma_qa_metric_global { ma_qa_metric_global { type value } } } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **entries** (array) - List of entries. - **rcsb_ma_qa_metric_global** (object) - Global Model Quality Assessment metrics. - **ma_qa_metric_global** (array) - List of quality metrics. - **type** (string) - Type of the metric. - **value** (float) - Value of the metric. #### Response Example ```json { "data": { "entries": [ { "rcsb_ma_qa_metric_global": { "ma_qa_metric_global": [ { "type": "iptm", "value": 0.923 }, { "type": "plddt", "value": 91.1 } ] } } ] } } ``` ``` -------------------------------- ### Polymer Entity Instances - Domain Assignments Source: https://data.rcsb.org/docs/index Fetch domain assignment information for polymer entity instances. ```APIDOC ## GET /graphql ### Description Fetches domain assignment information for polymer entity instances. ### Method POST ### Endpoint /graphql ### Parameters #### Query Parameters - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query {\n polymer_entity_instances(instance_ids: [\"4HHB.A\", \"12CA.A\", \"3PQR.A\"]) {\n rcsb_id\n rcsb_polymer_instance_annotation {\n annotation_id\n name\n type\n }\n }\n}" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **polymer_entity_instances** (array) - List of polymer entity instance objects. - **rcsb_id** (string) - The RCSB PDB identifier for the polymer entity instance. - **rcsb_polymer_instance_annotation** (array) - List of annotation objects. - **annotation_id** (string) - The ID of the annotation. - **name** (string) - The name of the annotation. - **type** (string) - The type of the annotation (e.g., domain assignment). #### Response Example ```json { "data": { "polymer_entity_instances": [ { "rcsb_id": "4HHB.A", "rcsb_polymer_instance_annotation": [ { "annotation_id": "1", "name": "Globin", "type": "DOMAIN" } ] } ] } } ``` ``` -------------------------------- ### Query Computed Structure Model Metrics Source: https://data.rcsb.org/docs/index Retrieve a list of global Model Quality Assessment (MQA) metrics for a computed structure model, such as an AlphaFold model. This example focuses on AlphaFold structure of Hemoglobin subunit beta. ```graphql query={ entries(entry_ids: ["AF_AFP68871F1"]) { rcsb_ma_qa_metric_global { ma_qa_metric_global { type value } } } } ``` -------------------------------- ### GraphQL: Query with Variables Source: https://context7.com/context7/data_rcsb/llms.txt Demonstrates how to perform parameterized GraphQL queries with variables for cleaner and more secure data retrieval from the RCSB API. ```APIDOC ## POST /graphql ### Description Use parameterized queries with variables for cleaner, reusable query patterns and improved security. ### Method POST ### Endpoint https://data.rcsb.org/graphql ### Parameters #### Request Body - **query** (string) - Required - The GraphQL query string. - **variables** (object) - Optional - A JSON object containing variables for the query. ### Request Example ```json { "query": "query exptlMethod($id: String!) { entry(entry_id: $id) { exptl { method } } }", "variables": {"id": "4HHB"} } ``` ### Response #### Success Response (200) - **data** (object) - The data returned by the query. #### Response Example ```json { "data": { "entry": { "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } } } ``` ``` -------------------------------- ### Entries - Basic Information Source: https://data.rcsb.org/docs/index Fetch basic information about PDB entries, including their RCSB ID, structure title, and experimental method. ```APIDOC ## GET /graphql ### Description Fetches basic information about PDB entries, including title and experimental method. ### Method POST ### Endpoint /graphql ### Parameters #### Query Parameters - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query {\n entries(entry_ids: [\"1STP\", \"2JEF\", \"1CDG\"]) {\n rcsb_id\n struct {\n title\n }\n exptl {\n method\n }\n }\n}" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **entries** (array) - List of PDB entry objects. - **rcsb_id** (string) - The RCSB PDB identifier. - **struct** (object) - Structure details. - **title** (string) - The title of the structure. - **exptl** (array) - List of experimental methods used. - **method** (string) - The experimental method. #### Response Example ```json { "data": { "entries": [ { "rcsb_id": "1STP", "struct": { "title": "STRUCTURE OF YEAST TRNA(PHE)" }, "exptl": [ { "method": "X-RAY DIFFRACTION" } ] } ] } } ``` ``` -------------------------------- ### Fetch Polymer Instance Domain Assignments (GraphQL) Source: https://data.rcsb.org/docs/index Queries for domain assignments associated with polymer entity instances. This includes annotation ID, name, and type, providing insights into the structural domains present in polymer instances. ```graphql query={ polymer_entity_instances(instance_ids: ["4HHB.A", "12CA.A", "3PQR.A"]) { rcsb_id rcsb_polymer_instance_annotation { annotation_id name type } } } ``` -------------------------------- ### GraphQL: Integrative Structures Source: https://context7.com/context7/data_rcsb/llms.txt Query hybrid models built from multiple experimental techniques, including crosslinking, SAS, and cryo-EM data. ```APIDOC ## POST /graphql ### Description Queries integrative structure metadata and input datasets for specified entry IDs. ### Method POST ### Endpoint https://data.rcsb.org/graphql ### Parameters #### Request Body - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query { entries(entry_ids: [\"8ZZ3\"]) { rcsb_id rcsb_entry_info { ihm_multi_scale_flag ihm_ensemble_flag } rcsb_ihm_dataset_source_db_reference { db_name accession_code } rcsb_ihm_dataset_list { name type count } } }" } ``` ### Response #### Success Response (200) - **data.entries[]** (object) - Information about the entry. - **rcsb_id** (string) - The RCSB PDB entry ID. - **rcsb_entry_info** (object) - Entry-specific information. - **ihm_multi_scale_flag** (string) - Indicates if the entry uses multi-scale modeling. - **ihm_ensemble_flag** (string) - Indicates if the entry is an ensemble. - **rcsb_ihm_dataset_source_db_reference[]** (object) - References to source databases. - **db_name** (string) - Name of the source database. - **accession_code** (string) - Accession code in the source database. - **rcsb_ihm_dataset_list[]** (object) - List of datasets used in the integrative model. - **name** (string) - Name of the dataset. - **type** (string) - Type of the dataset. - **count** (integer) - Number of items in the dataset. #### Response Example ```json { "data": { "entries": [ { "rcsb_id": "8ZZ3", "rcsb_entry_info": { "ihm_multi_scale_flag": "YES", "ihm_ensemble_flag": "YES" }, "rcsb_ihm_dataset_source_db_reference": [ { "db_name": "PDB", "accession_code": "1ABC" } ], "rcsb_ihm_dataset_list": [ { "name": "Crosslinking restraints", "type": "CX-MS data", "count": 150 } ] } ] } } ``` ``` -------------------------------- ### Fetch Assembly Information for Multiple Assemblies Source: https://data.rcsb.org/docs/index Shows how to retrieve information about biological assemblies, including entry ID, assembly ID, and polymer entity instance count, for a given set of assembly IDs. ```APIDOC ## POST /graphql ### Description Fetches information for a list of biological assemblies. ### Method POST ### Endpoint /graphql ### Parameters #### Query Parameters - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query={ assemblies(assembly_ids: [\"4HHB-1\", \"12CA-1\", \"3PQR-1\"]) { rsb_assembly_info { entry_id assembly_id polymer_entity_instance_count } } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **assemblies** (array) - List of assembly objects. - **rcsb_assembly_info** (object) - Assembly information. - **entry_id** (string) - The entry identifier. - **assembly_id** (string) - The assembly identifier. - **polymer_entity_instance_count** (integer) - The number of polymer entity instances in the assembly. #### Response Example ```json { "data": { "assemblies": [ { "rcsb_assembly_info": { "entry_id": "4HHB", "assembly_id": "1", "polymer_entity_instance_count": 4 } }, { "rcsb_assembly_info": { "entry_id": "12CA", "assembly_id": "1", "polymer_entity_instance_count": 2 } }, { "rcsb_assembly_info": { "entry_id": "3PQR", "assembly_id": "1", "polymer_entity_instance_count": 5 } } ] } } ``` ``` -------------------------------- ### Archive-Wide Querying Pattern Source: https://context7.com/context7/data_rcsb/llms.txt Demonstrates a pattern for querying all PDB structures by combining the Holdings API with GraphQL pagination for batch processing. ```APIDOC ## Archive-Wide Querying Pattern ### Description This pattern outlines how to efficiently query all PDB structures by fetching all entry IDs using the Holdings API and then processing them in batches via GraphQL. ### Steps 1. **Get all current PDB IDs**: Use the Holdings API to retrieve a list of all current PDB entry IDs. 2. **Batch IDs into chunks**: Divide the list of entry IDs into manageable batches (e.g., 100 IDs per batch). 3. **Query each batch**: Send a GraphQL POST request for each batch to retrieve desired data. ### Example Code (Python) ```python import requests import json # Step 1: Get all current PDB IDs holdings_url = "https://data.rcsb.org/rest/v1/holdings/current/entry_ids" response = requests.get(holdings_url) all_pdb_ids = response.json() # Returns array like ["1ABC", "2XYZ", ...] # Step 2: Batch IDs into chunks of 100 batch_size = 100 batches = [all_pdb_ids[i:i+batch_size] for i in range(0, len(all_pdb_ids), batch_size)] # Step 3: Query each batch graphql_url = "https://data.rcsb.org/graphql" results = [] for batch in batches: query = { "query": """ query($ids: [String!]!) { entries(entry_ids: $ids) { rcsb_id exptl { method } } } """, "variables": {"ids": batch} } response = requests.post(graphql_url, json=query) data = response.json() if "data" in data and data["data"]: results.extend(data["data"]["entries"]) # Rate limiting (if needed) # time.sleep(0.1) print(f"Processed {len(results)} structures") ``` ``` -------------------------------- ### Query Multiple PDB Entries via GraphQL Source: https://context7.com/context7/data_rcsb/llms.txt Demonstrates fetching data for multiple PDB entries in a single request using a POST request to the GraphQL endpoint. This allows for batch queries, retrieving identifiers, titles, and experimental methods for an array of entry IDs. ```bash # POST request: Query title and experimental method for multiple entries curl -X POST https://data.rcsb.org/graphql \ -H "Content-Type: application/json" \ -d '{ "query": "query { entries(entry_ids: [\"4HHB\", \"12CA\", \"3PQR\"]) { rcsb_id struct { title } exptl { method } } }" }' ``` -------------------------------- ### Python: Using rcsb-api Package Source: https://context7.com/context7/data_rcsb/llms.txt Utilizes the official Python client for high-level interfaces for data retrieval, including search and automatic error handling. ```APIDOC ## Python rcsb-api Package ### Description Provides a Python client for querying RCSB PDB data, supporting entry data, polymer entities, and custom field selections. ### Installation ```bash pip install rcsb-api ``` ### Usage #### Query entry data ```python from rcsbapi.data import Schema, DataQuery query = DataQuery( input_type=Schema.ENTRY, input_ids={"entry_id": "4HHB"} ) result = query.exec() print(result["exptl"][0]["method"]) ``` #### Query multiple polymer entities ```python from rcsbapi.data import Schema, DataQuery query = DataQuery( input_type=Schema.POLYMER_ENTITY, input_ids={ "entity_id": "1", "entry_id": ["4HHB", "12CA", "3PQR"] } ) results = query.exec() for entity in results: organism = entity["rcsb_entity_source_organism"][0] print(f"{entity['rcsb_id']}: {organism['ncbi_scientific_name']}") ``` #### Query with field selection ```python from rcsbapi.data import Schema, DataQuery query = DataQuery( input_type=Schema.ENTRY, input_ids={"entry_id": ["1STP", "2JEF"]}, return_data_list=[ "struct.title", "exptl.method", "rcsb_primary_citation.pdbx_database_id_DOI" ] ) results = query.exec() ``` ``` -------------------------------- ### GraphQL: Assembly Information Source: https://context7.com/context7/data_rcsb/llms.txt Query biological assembly data including composition, symmetry, and coordinate transformations for macromolecular complexes using the assembly GraphQL endpoint. ```APIDOC ## GraphQL: Assembly Information ### Description Query biological assembly data including composition, symmetry, and coordinate transformations for macromolecular complexes. ### Method POST ### Endpoint https://data.rcsb.org/graphql ### Parameters #### Query Parameters None #### Request Body - **query** (string) - Required - The GraphQL query string to fetch assembly information. ### Request Example ```json { "query": "query { assemblies(assembly_ids: [\"4HHB-1\", \"12CA-1\"]) { rcsb_assembly_info { entry_id assembly_id polymer_entity_instance_count } } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **assemblies** (array) - List of assembly objects. - **rcsb_assembly_info** (object) - Assembly information. - **entry_id** (string) - The entry ID of the assembly. - **assembly_id** (string) - The ID of the assembly. - **polymer_entity_instance_count** (integer) - The number of polymer entity instances in the assembly. #### Response Example ```json { "data": { "assemblies": [ { "rcsb_assembly_info": { "entry_id": "4HHB", "assembly_id": "1", "polymer_entity_instance_count": 4 } }, { "rcsb_assembly_info": { "entry_id": "12CA", "assembly_id": "1", "polymer_entity_instance_count": 1 } } ] } } ``` ``` -------------------------------- ### Fetch Assembly Info for Multiple Assemblies (GraphQL) Source: https://data.rcsb.org/docs/index This GraphQL query fetches information about biological assemblies, including entry ID, assembly ID, and polymer entity instance count, for a given list of assembly IDs. It showcases how to query assembly-specific data using compound identifiers. ```graphql query={ assemblies(assembly_ids: ["4HHB-1", "12CA-1", "3PQR-1"]) { rcsb_assembly_info { entry_id assembly_id polymer_entity_instance_count } } } ``` -------------------------------- ### GraphQL: Chemical Components Source: https://context7.com/context7/data_rcsb/llms.txt Query the chemical component dictionary for ligands, cofactors, and monomers with chemical properties and formulas using the chemical components GraphQL endpoint. ```APIDOC ## GraphQL: Chemical Components ### Description Query the chemical component dictionary for ligands, cofactors, and monomers with chemical properties and formulas. ### Method POST ### Endpoint https://data.rcsb.org/graphql ### Parameters #### Query Parameters None #### Request Body - **query** (string) - Required - The GraphQL query string to fetch chemical component data. ### Request Example ```json { "query": "query { chem_comps(comp_ids: [\"NAG\", \"ATP\"]) { rcsb_id chem_comp { type formula_weight name formula } rcsb_chem_comp_info { initial_release_date } } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **chem_comps** (array) - List of chemical component objects. - **rcsb_id** (string) - The RCSB ID of the chemical component. - **chem_comp** (object) - Chemical component details. - **type** (string) - The type of chemical component. - **formula_weight** (number) - The formula weight. - **name** (string) - The name of the component. - **formula** (string) - The chemical formula. - **rcsb_chem_comp_info** (object) - Chemical component information. - **initial_release_date** (string) - The initial release date. #### Response Example ```json { "data": { "chem_comps": [ { "rcsb_id": "NAG", "chem_comp": { "type": "D-saccharide", "formula_weight": 221.208, "name": "N-ACETYL-D-GLUCOSAMINE", "formula": "C8 H15 N O6" }, "rcsb_chem_comp_info": { "initial_release_date": "1999-07-08T00:00:00Z" } } ] } } ``` ```