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

Fix to xyz/2D loading and atom reordering in ARCSpecies #96

Merged
merged 1 commit into from
Mar 19, 2019
Merged

Conversation

mliu49
Copy link
Collaborator

@mliu49 mliu49 commented Mar 18, 2019

Before

In __init__:

  • If self.mol was None, then a molecule would be generated from the xyz coordinates but not saved to self, and self.mol_list would also not be set.

In mol_from_xyz:

  • It seemed like the intention was to maintain consistent atom IDs between self.mol and self.mol_list, which was not the case, since the atom orders changed due to resonance structure generation.

After

  • Simplified __init__ code to call mol_from_xyz for all non-TS species
  • Handling for whether or not self.mol exists moved to mol_from_xyz
  • Fixed atom id copying when generating resonance structures
  • Added unit test for atom ids from mol_to_xyz

Reviewer Notes

Please double check that my interpretation of mol_from_xyz is correct. If you had tests for that method, it might be good to run them/add them to unit tests.

@codecov
Copy link

codecov bot commented Mar 18, 2019

Codecov Report

Merging #96 into master will decrease coverage by 0.28%.
The diff coverage is 70%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #96      +/-   ##
==========================================
- Coverage   41.48%   41.19%   -0.29%     
==========================================
  Files          22       22              
  Lines        5048     5042       -6     
  Branches     1304     1303       -1     
==========================================
- Hits         2094     2077      -17     
- Misses       2619     2632      +13     
+ Partials      335      333       -2
Impacted Files Coverage Δ
arc/species/species.py 58.45% <70%> (-1.49%) ⬇️
arc/reaction.py 42.12% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3baeab5...ace6220. Read the comment docs.

Copy link
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Looking great, thanks for this fix!
I added some minor comments and an idea for a test

self.assertTrue(mol.atomIDValid())
self.assertTrue(res.atomIDValid())

print(mol.toAdjacencyList())
Copy link
Member

Choose a reason for hiding this comment

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

Were the print statements left here on purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, they're left over from debugging. I'll remove them.

_, self.mol = molecules_from_xyz(xyz)
for i, atom in enumerate(self.mol.atoms):
atom.id = id_mol.atoms[i].id
# The generate_resonance_structures methods changes atom order
Copy link
Member

Choose a reason for hiding this comment

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

This is my typo originally. Can you change methods to method in this comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


self.assertTrue(mol.isIsomorphic(res))
self.assertTrue(mol.isIdentical(res))

Copy link
Member

Choose a reason for hiding this comment

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

Can you add another test for a species with more than one entry in mol_list?
For example, HSO3 has two resonance structures, you can use it's xyz:

S      -0.12383700    0.10918200   -0.21334200
O       0.97332200   -0.98800100    0.31790100
O      -1.41608500   -0.43976300    0.14487300
O       0.32370100    1.42850400    0.21585900
H       1.84477700   -0.57224200    0.35517700

Could we check that S and H have the same ID and are in the same order in self.mol and in all entries of self.mol_list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

if self.mol is not None:
# self.mol should have come from another source, e.g. SMILES or yml
original_mol = self.mol
self.mol = molecules_from_xyz(xyz)[1]
Copy link
Member

@alongd alongd Mar 19, 2019

Choose a reason for hiding this comment

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

We have a problem here (in the original code, not introduced by this PR) that when we override self.mol we might change the multiplicity. For example, molecules_from_xyz() will return multiplicity 3 for birads, but self.mol could originally be singlet. Then the ESS calculation will be affected. I'm trying to solve these issues on the master branch, it also affects isomorphism checks after optimization. If you get this in first, you won't have to rebase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've had that issue, but it will usually fail the isomorphism comparison with the 2D structure. Have you found a way to fix the molecule generated from the XYZ to match the expected multiplicity?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I'll fix that after merging this branch

Clean up code in __init__ and ensure self.mol_list is updated
Fix atom id copying when generating resonance structures
Add unit test for atom ids from mol_to_xyz
Copy link
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@alongd alongd merged commit 1ff052f into master Mar 19, 2019
@alongd alongd deleted the xyz_2d branch March 19, 2019 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants