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

Broken JSON export for molprobity angle restraints #1021

Open
aozalevsky opened this issue Oct 7, 2024 · 6 comments
Open

Broken JSON export for molprobity angle restraints #1021

aozalevsky opened this issue Oct 7, 2024 · 6 comments

Comments

@aozalevsky
Copy link

restraints.angles.as_JSON() throws error. Steps to reproduce:

Apptainer> molprobity.molprobity probe=False coot=False prefix=1hao_mp pickle=True 1hao.cif
Apptainer> mmtbx.python 
Python 3.7.16 | packaged by conda-forge | (default, Dec 13 2022, 23:24:55) 
[GCC 11.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> with open('1hao_mp.pkl', 'rb') as f:
...     data = pickle.load(f)
... 
>>> data.restraints.angles.as_JSON()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/molprobity/modules/cctbx_project/mmtbx/validation/restraints.py", line 362, in as_JSON
    flat_results.append(json.loads(result.as_JSON()))
  File "/opt/molprobity/modules/cctbx_project/mmtbx/validation/restraints.py", line 56, in as_JSON
    slots_as_dict["xyz"] = slots_as_dict["xyz"].elems
AttributeError: 'tuple' object has no attribute 'elems'

Molprobity Internal Version (from core.php): 4.5.2
molprobity_version_number (from pickled output): (4, 1)

@vbchen
Copy link
Contributor

vbchen commented Oct 9, 2024

I have checked in a tentative fix for this bug. Give it a try and let me know if you still have an issue.

@aozalevsky
Copy link
Author

aozalevsky commented Oct 9, 2024

@vbchen, the fix seems to work. i've tested it on several entries. thanks!

However, in the process, I encountered another JSON export issue, now with bonds:
https://www.wwpdb.org/pdb?id=9a78 (this is a PDB-Dev entry, but since it's an atomic model with fully populated _atom_site table, Molprobity works just fine with such files)

If there are no outliers, the code throws an exception:

>>> data.restraints.bonds.n_total_by_model 
{'': 9949}
>>> data.restraints.bonds.n_outliers_by_model
{}
>>> data.restraints.bonds.as_JSON()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/molprobity/modules/cctbx_project/mmtbx/validation/restraints.py", line 370, in as_JSON
    summary_results[model_id] = { "num_outliers" : self.n_outliers_by_model[model_id],
KeyError: ''
>>> 

while chiralities export in a similar situation works fine:

>>> data.restraints.chiralities.n_total_by_model
{'': 1568}
>>> data.restraints.chiralities.n_outliers_by_model
{'': 0}
>>> data.restraints.chiralities.as_JSON()
'{\n  "validation_type": "chirality",\n  "flat_results": [],\n  "hierarchical_results": {},\n  "summary_results": {\n    "": {\n      "num_outliers": 0,\n      "num_total": 1568,\n      "num_handedness_outliers": 0,\n      "num_chiral_centers": 1326,\n      "num_tetrahedral_outliers": 0,\n      "num_pseudochiral_outliers": 0\n    }\n  }\n}'
>>> 

should I create a new issue, or can we continue with this one?

@vbchen
Copy link
Contributor

vbchen commented Oct 10, 2024

Hmm, OK, I'll look into it. I appreciate you bringing these issues to my attention, the JSON export features are fairly new so it's good for them to get tested in real world situations.

@aozalevsky
Copy link
Author

thank you! i'm very interested in the json output and happy to test/provide feedback. we use molprobity as part of the PDB-Dev validation pipeline (to assess the quality of atomic models), and i'd be happy to switch to json outputs and get rid of some legacy code for capturing and parsing text molprobity output that we are using right now.

and sorry for only reporting issues without providing pull-requests. i'd love to contribute, but not familiar enough with the codebase.

@vbchen
Copy link
Contributor

vbchen commented Oct 18, 2024

I have checked in fixes for the issues you found with files with no bond/angle outliers.

I wanted to let you know that we've noticed some inconsistencies with the json outputs between the different validation scripts, so we'll be going through and fixing some of those issues. Let me know if you have any issues or opinions on how they should be formatted or if there's any missing information.

@aozalevsky
Copy link
Author

Thank you, @vbchen. I'll do some tests over the weekend and will let you know.

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

2 participants