Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying RCSB Search via pypdb package has broken #53

Open
JatGreer opened this issue Sep 27, 2024 · 0 comments
Open

Querying RCSB Search via pypdb package has broken #53

JatGreer opened this issue Sep 27, 2024 · 0 comments

Comments

@JatGreer
Copy link

According to discussion on pypdb repo here: williamgilpin/pypdb#67, rcsb may have changed their API and broken the pypdb package.

Error:

Querying RCSB Search using the following parameters:
 {"query": {"type": "terminal", "service": "full_text", "parameters": {"value": "F4HvG8"}}, "request_options": {"return_all_hits": true}, "return_type": "entry"} 

[/home/jg/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:267](https://file+.vscode-resource.vscode-cdn.net/home/jg/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:267): UserWarning: It appears request failed with:{
  "timestamp" : 1727439714991,
  "status" : 415,
  "error" : "Unsupported Media Type",
  "path" : "/rcsbsearch/v2/query"
}
  warnings.warn("It appears request failed with:" + response.text)
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
Cell In[3], [line 1](vscode-notebook-cell:?execution_count=3&line=1)
----> [1](vscode-notebook-cell:?execution_count=3&line=1) available_only_AF = fetcher.check_db(ONLY_ALPHAFOLD)
      [2](vscode-notebook-cell:?execution_count=3&line=2) available_only_pdb = fetcher.check_db(ONLY_PDB)
      [3](vscode-notebook-cell:?execution_count=3&line=3) available_both = fetcher.check_db(BOTH)

File ~/Software/profet/profet/profet.py:40, in Fetcher.check_db(self, uniprot_id)
     [28](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:28) """
     [29](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:29) Checks which database contains the searched ID.
     [30](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:30) 
   (...)
     [36](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:36) 
     [37](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:37) """
     [39](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:39) available_db = []
---> [40](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:40) if self.pdb.check_structure(uniprot_id):
     [41](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:41)     available_db.append("pdb")
     [42](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/profet.py:42) if self.alpha.check_structure(uniprot_id):

File ~/Software/profet/profet/pdb.py:35, in PDB_DB.check_structure(self, uniprot_id)
     [33](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/pdb.py:33) search_operator = text_operators.DefaultOperator(value=uniprot_id)
     [34](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/pdb.py:34) try:
---> [35](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/pdb.py:35)     self.results = perform_search(search_operator, self.return_type)
     [36](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/pdb.py:36)     return True
     [37](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/Software/profet/profet/pdb.py:37) except ValueError:

File ~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:185, in perform_search(search_operator, return_type, request_options, return_with_scores, return_raw_json_dict, verbosity)
    [130](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:130) def perform_search(
    [131](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:131)     search_operator: SearchOperator,
    [132](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:132)     return_type: ReturnType = ReturnType.ENTRY,
   (...)
    [136](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:136)     verbosity: bool = True,
    [137](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:137) ) -> Union[List[str], List[ScoredResult], RawJSONDictResponse]:
    [138](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:138)     """Performs search specified by `search_operator`.
    [139](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:139)     Returns entity strings of type `return_type` that match the resulting hits.
    [140](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:140) 
   (...)
    [182](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:182)     ```
    [183](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:183)     """
--> [185](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:185)     return perform_search_with_graph(query_object=search_operator,
    [186](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:186)                                      return_type=return_type,
    [187](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:187)                                      request_options=request_options,
    [188](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:188)                                      return_with_scores=return_with_scores,
    [189](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:189)                                      return_raw_json_dict=return_raw_json_dict,
    [190](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:190)                                      verbosity=verbosity)

File ~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:268, in perform_search_with_graph(query_object, return_type, request_options, return_with_scores, return_raw_json_dict, verbosity)
    [266](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:266) if not response.ok:
    [267](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:267)     warnings.warn("It appears request failed with:" + response.text)
--> [268](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:268)     response.raise_for_status()
    [270](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:270) # If specified, returns raw JSON response from RCSB as Dict
    [271](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:271) # (rather than entity IDs as a string list)
    [272](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/pypdb/clients/search/search_client.py:272) if return_raw_json_dict:

File ~/miniconda3/envs/profet/lib/python3.10/site-packages/requests/models.py:1024, in Response.raise_for_status(self)
   [1019](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/requests/models.py:1019)     http_error_msg = (
   [1020](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/requests/models.py:1020)         f"{self.status_code} Server Error: {reason} for url: {self.url}"
   [1021](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/requests/models.py:1021)     )
   [1023](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/requests/models.py:1023) if http_error_msg:
-> [1024](https://file+.vscode-resource.vscode-cdn.net/home/jg/Downloads/~/miniconda3/envs/profet/lib/python3.10/site-packages/requests/models.py:1024)     raise HTTPError(http_error_msg, response=self)

HTTPError: 415 Client Error:  for url: https://search.rcsb.org/rcsbsearch/v2/query

Reproduce:

import profet

ONLY_ALPHAFOLD = "F4HvG8"
ONLY_PDB = "7U6Q"
BOTH = "A0A023FDY8"

fetcher = profet.Fetcher()
print('Current default database: ', fetcher.get_default_db())

available_only_AF = fetcher.check_db(ONLY_ALPHAFOLD)
available_only_pdb = fetcher.check_db(ONLY_PDB)
available_both = fetcher.check_db(BOTH)

print('Database available for ', ONLY_ALPHAFOLD, ' is ', available_only_AF)
print('Database available for ', ONLY_PDB, ' is ', available_only_pdb)
print('Databases available for ', BOTH, ' are ', available_both)

PDB = fetcher.get_file(ONLY_PDB)
AF = fetcher.get_file(ONLY_ALPHAFOLD)
from_pdb = fetcher.get_file(BOTH)
from_AF = fetcher.get_file(BOTH, db = 'alphafold')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant