-
Notifications
You must be signed in to change notification settings - Fork 33
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 xyz writer #46
Add xyz writer #46
Conversation
tmp_name = site.element.symbol | ||
elif len(site.name) <= 2: | ||
tmp_name = site.name | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the case when a name is >2? Wouldnt we want to support that as well?
Even though its not an element anymore, i could see a case where your sites are not atomistic representations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This column in XYZ files is supposed to be element. We need better element guessing, but I don't think there are good rules for handling non-elements in this format. For now I guess we can just let the entire name be stored, but it may be problematic down the line - we'll see.
topology/formats/xyz.py
Outdated
def write_xyz(top, filename): | ||
with open(filename, 'w') as out_file: | ||
out_file.write('{:d}\n'.format(top.n_sites)) | ||
out_file.write('{} {} written by topology\n'.format(top.name, filename)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
date would be nice to have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further down the line, we might want to do some validation of the element
|
||
self._element = element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer doing this in a separate PR bulking up the element class
I added a simple datetime printer, the result looks like this:
|
Since XYZ files store next to nothing (no residue information, box, bonds, angles, dihedrals) I was able to just enumerate through the sites and avoid the complications Ray is having in #28.
I added an element setter and getter, which may or may or may not affect other behavior but seems like something we should have already done.
The logic in assigning a name could be improved, I just check to see if there's an element stored in the site and if not, I try to assign a "name" according to the first characters of the site's name, and if those fail I just call it
X
.