williamgilpin / pypdb

A Python API for the RCSB Protein Data Bank (PDB)
MIT License
309 stars 77 forks source link

Access structure pH #49

Closed stepdasha closed 6 months ago

stepdasha commented 2 years ago

Can we access structure's pH with something like pypdb.describe_pdb(pdb_id)? Thank you very much.

williamgilpin commented 2 years ago

Hello, would you mind posting an example query and desired output? If you can share the XML associated with doing a query on the PDB website, that would be super handy, so that I can see if I can figure this out.

stepdasha commented 2 years ago

Hi @williamgilpin . In PDB file there is a line "REMARK 245 PH : 8.00" with ph information of the experiment. I would like to extract this '8.00'information from the pdb file in the same way as pypdb.describe_pdb(pdb_id) extract all other information about the structure and experiment. But I didn't find any command for it so far. I am sorry, I not sure I understand what "share the XML associated with doing a query " mean. Thank you very much

jthornton-0 commented 1 year ago

@williamgilpin I think this can be closed as this is already possible with the existing code, I was playing with pypdb to solve some of the outstanding issues and this issue is easy to accomplish:

[1] >>> from pypdb.pypdb import get_info
[2] >>> pdb_info = get_info('1ae1')
[3] >>> pH = pdb_info["exptl_crystal_grow"][0]["p_h"]
[4] >>> print(pH)
        4.5

or equivalently pH = pdb_info["exptl_crystal_grow"][0]['pdbx_details'][3:] (removing the first 3 characters which are 'ph '). The user could write a custom function to extract it along these lines using a try ... except block for IndexError's if the field is not defined.