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

Add delete_atoms method and use bonding info for add_hatoms SO107 #178

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from

Conversation

dormrod
Copy link
Contributor

@dormrod dormrod commented Nov 25, 2024

Description

Two small changes to Molecule:

  • delete_atoms: add a method to delete multiple atoms in a single call. This uses "partial success" so that all passed atoms will attempted to be deleted, even if one of them fails.

  • add_hatoms: use a .in file to amsprep instead of a .xyz so bonding information is respected when adding h-atoms. Also perform a guess bonds on the output, if there were bonds on the original molecule.

mol/molecule.py Outdated
@@ -3354,6 +3374,8 @@ def add_hatoms(self) -> "Molecule":
)
p.communicate()
retmol = self.__class__(f_out.name)
if any(self.bonds):
retmol.guess_bonds()

Choose a reason for hiding this comment

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

I do not understand why we should guess bonds by default. I would remove this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously the behaviour was that if you do add_hatoms to a molecule that already has bonds, the result will have no bonds at all, as it recreates a molecule from an xyz. This change means that if the previous molecule has bonds, it will guess them. But I can remove it if you think it is unexpected here.

Choose a reason for hiding this comment

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

ah true it makes sense.

Copy link
Contributor Author

@dormrod dormrod Dec 11, 2024

Choose a reason for hiding this comment

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

I have found a way to get the bonding information out of amsprep, so have used this instead of guess bonds

@dormrod dormrod force-pushed the DavidOrmrodMorley/molecule_add_hatoms_fix branch 2 times, most recently from f83dda7 to 995b199 Compare December 11, 2024 15:17
@dormrod dormrod requested a review from GiulioIlBen December 12, 2024 13:02
@dormrod dormrod force-pushed the DavidOrmrodMorley/molecule_add_hatoms_fix branch from 995b199 to 384a7dd Compare December 16, 2024 14:37
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.

2 participants