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

OpenBabelReader and Tests #16

Merged
merged 4 commits into from
Sep 11, 2024
Merged

Conversation

lunamorrow
Copy link
Collaborator

In reference to #5. This is a draft of the code with the initial functionality starting to be roughly scaffolded out for feedback.

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@pep8speaks
Copy link

pep8speaks commented Jul 31, 2024

Hello @lunamorrow! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 52:13: E128 continuation line under-indented for visual indent
Line 53:13: E128 continuation line under-indented for visual indent
Line 59:80: E501 line too long (81 > 79 characters)

Line 17:61: W292 no newline at end of file

Line 19:1: E302 expected 2 blank lines, found 1
Line 35:13: E128 continuation line under-indented for visual indent
Line 36:13: E128 continuation line under-indented for visual indent

Comment last updated at 2024-08-06 01:37:45 UTC

Copy link
Collaborator

@exs-cbouy exs-cbouy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a test for mols without any coordinates making sure that they are all nan?

mda_openbabel_converter/OpenBabel.py Outdated Show resolved Hide resolved
mda_openbabel_converter/tests/test_openbabel_reader.py Outdated Show resolved Hide resolved
mda_openbabel_converter/tests/test_openbabel_reader.py Outdated Show resolved Hide resolved
mda_openbabel_converter/tests/test_openbabel_reader.py Outdated Show resolved Hide resolved
@exs-cbouy
Copy link
Collaborator

Nice work Luna!
cat-thumbs-up

@xhgchen
Copy link
Member

xhgchen commented Aug 5, 2024

Great work! Loving the progress :)

@lunamorrow
Copy link
Collaborator Author

lunamorrow commented Aug 6, 2024

Could you also add a test for mols without any coordinates making sure that they are all nan?

@exs-cbouy It looks like null position in OpenBabel is stored as a (0, 0, 0) vector. I don't want to report that as a position when its not, so I'm thinking that I can check that if the whole molecules position vectors are (0, 0, 0) that there is no position info and to set it to nan (or not even set it) and issue a warning. That will prevent molecules with an atom at a valid (0, 0, 0) position from being flagged. Thoughts?

Edit: I've got it, just had to change my conditions for empty coordinates. Pushing changes now.

mda_openbabel_converter/OpenBabel.py Show resolved Hide resolved
Comment on lines 50 to 54
coordinates = np.array([
[(coords := atom.GetVector()).GetX(),
coords.GetY(),
coords.GetZ()] for atom in OBMolAtomIter(filename)],
dtype=np.float32)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could potentially be as simple as (haven't tried it though):

Suggested change
coordinates = np.array([
[(coords := atom.GetVector()).GetX(),
coords.GetY(),
coords.GetZ()] for atom in OBMolAtomIter(filename)],
dtype=np.float32)
coordinates = np.array(filename.GetConformers(), dtype=np.float32)

Also we overlooked that the current implementation is missing one dimension for the number of conformers

Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lunamorrow lunamorrow marked this pull request as ready for review September 11, 2024 01:50
@lunamorrow lunamorrow merged commit f35c093 into MDAnalysis:main Sep 11, 2024
19 of 20 checks passed
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

Successfully merging this pull request may close these issues.

5 participants