Skip to content

Commit

Permalink
Add details for mmCIF external files.
Browse files Browse the repository at this point in the history
Populate the newly-created _ihm_external_files.details field
with human-readable information about each externally-linked
file. Relates ihmwg/IHMCIF#22.
  • Loading branch information
benmwebb committed Mar 23, 2017
1 parent f5fd469 commit 1a62c14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions pyext/src/mmcif.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,12 @@ def map_repo(r):

def dump_locations(self, writer):
with writer.loop("_ihm_external_files",
["id", "reference_id", "file_path"]) as l:
["id", "reference_id", "file_path", "details"]) as l:
for loc in self._location_by_id:
repo = loc.repo or self._local_files
l.write(id=loc.id, reference_id=repo.id,
file_path=repo._get_full_path(loc.path))
file_path=repo._get_full_path(loc.path),
details=loc.details or _CifWriter.omitted)


class _DatasetDumper(_Dumper):
Expand Down
14 changes: 8 additions & 6 deletions test/test_mmcif.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ def flush(self):
l = IMP.pmi.metadata.FileLocation(repo=repo2, path='baz')
dump.add(l)
# Repository containing a single file (not an archive)
l = IMP.pmi.metadata.FileLocation(repo=repo3, path='foo.spd')
l = IMP.pmi.metadata.FileLocation(repo=repo3, path='foo.spd',
details='EM micrographs')
dump.add(l)
with IMP.test.temporary_directory() as tmpdir:
bar = os.path.join(tmpdir, 'bar')
Expand Down Expand Up @@ -541,11 +542,12 @@ def flush(self):
_ihm_external_files.id
_ihm_external_files.reference_id
_ihm_external_files.file_path
1 1 bar
2 1 baz
3 2 foo/bar/baz
4 3 foo.spd
5 4 %s
_ihm_external_files.details
1 1 bar .
2 1 baz .
3 2 foo/bar/baz .
4 3 foo.spd 'EM micrographs'
5 4 %s .
#
""" % absbar)

Expand Down

0 comments on commit 1a62c14

Please sign in to comment.