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

Confusing HierarchyElement.__str__() #1924

Open
mattwthompson opened this issue Aug 5, 2024 · 0 comments
Open

Confusing HierarchyElement.__str__() #1924

mattwthompson opened this issue Aug 5, 2024 · 0 comments

Comments

@mattwthompson
Copy link
Member

I'm trying to investigate whether I or the toolkit is losing track of my residue information when I'm doing a conversion, and I've found that I've been led astray by the __repr__. It's called here; self.identifier not being set seems concerning, but they're there when I ask for them. Any ideas what I'm doing wrong here?

In [1]: from openff.toolkit import Molecule

In [2]: water = Molecule.from_smiles("O")

In [3]: water.add_hierarchy_scheme(("residue_name", "residue_number"), "residues")
Out[3]: HierarchyScheme with uniqueness_criteria '('residue_name', 'residue_number')', iterator_name 'residues', and 1 elements

In [4]: residue = water.residues[-1]

In [5]: str(residue)
Out[5]: "HierarchyElement ('None', 'None') of iterator 'residues' containing 3 atom(s)"

In [6]: residue.residue_name = "FOO"

In [7]: residue.residue_number = '7'

In [11]: water.residues[0].residue_name
Out[11]: 'FOO'

In [12]: str(residue)
Out[12]: "HierarchyElement ('None', 'None') of iterator 'residues' containing 3 atom(s)"

In [13]: residue.residue_number
Out[13]: '7'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant