ihmwg / python-ihm

Python package for handling IHM mmCIF and BinaryCIF files
MIT License
14 stars 7 forks source link

Add auth_seq_id to atom dumper #61

Closed rvhonorato closed 2 years ago

rvhonorato commented 2 years ago

This is a PR closes #60. Since the addition of _atom_site.auth_seq_id adds a line to the .cif file of the examples, I patched them too.

If this was not an issue in the first place please fell free to close this PR.

codecov-commenter commented 2 years ago

Codecov Report

Merging #61 (257a731) into main (fb9199d) will increase coverage by 0.01%. The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #61      +/-   ##
==========================================
+ Coverage   99.81%   99.82%   +0.01%     
==========================================
  Files          28       28              
  Lines        6861     6729     -132     
  Branches     1028     1029       +1     
==========================================
- Hits         6848     6717     -131     
+ Misses         11        9       -2     
- Partials        2        3       +1     
Impacted Files Coverage Δ
ihm/dumper.py 99.87% <33.33%> (-0.13%) :arrow_down:
src/ihm_format.c 98.51% <0.00%> (+0.16%) :arrow_up:

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 fb9199d...257a731. Read the comment docs.

rvhonorato commented 2 years ago
1. This line is too long (`flake8` limits lines to 80 chars).

Sorry I pushed the wrong version, this was just to test, just updated it.

2. Would be much cleaner and simpler to use `auth_seq_id=atom.residue.auth_seq_id` here as `auth_seq_id` is a per-residue property.

Thanks for the suggestion, this one raises an attribute error, is the syntax correct?

Traceback (most recent call last):
  File "/Users/rodrigo/repos/python-ihm/examples/simple-docking.py", line 146, in <module>
    ihm.dumper.write(fh, [system])
  File "/Users/rodrigo/repos/python-ihm/ihm/dumper.py", line 3166, in write
    d.dump(system, writer)
  File "/Users/rodrigo/repos/python-ihm/ihm/dumper.py", line 1419, in dump
    seen_types = self.dump_atoms(system, writer)
  File "/Users/rodrigo/repos/python-ihm/ihm/dumper.py", line 1488, in dump_atoms
    auth_seq_id=atom.residue.auth_seq_id,
AttributeError: 'Atom' object has no attribute 'residue'
benmwebb commented 2 years ago

AttributeError: 'Atom' object has no attribute 'residue'

Oh, you're right. Let's merge what you have so far (it should work in most cases) and I'll fix this later.