|
35 | 35 | 'bound_file': ('aligned'),
|
36 | 36 | 'cif_info': ('aligned'),
|
37 | 37 | 'mtz_info': ('aligned'),
|
38 |
| - # 'map_info': ('aligned'), |
| 38 | + 'map_info': ('aligned'), |
39 | 39 | 'sigmaa_file': ('aligned'),
|
40 | 40 | 'diff_file': ('aligned'),
|
41 | 41 | 'event_file': ('aligned'),
|
|
56 | 56 | 'bound_file': {}, # x
|
57 | 57 | 'cif_info': {}, # from experiment
|
58 | 58 | 'mtz_info': {}, # from experiment
|
| 59 | + 'map_info': {}, # from experiment |
59 | 60 | 'event_file': {}, # x
|
60 |
| - 'diff_file': {}, # renamed from diff_file and sigmaa_file |
| 61 | + 'diff_file': {}, |
61 | 62 | 'sigmaa_file': {},
|
62 | 63 | },
|
63 | 64 | 'molecules': {
|
@@ -229,6 +230,7 @@ def _add_file_to_zip_aligned(ziparchive, code, filepath):
|
229 | 230 | filepath = str(Path(settings.MEDIA_ROOT).joinpath(filepath))
|
230 | 231 |
|
231 | 232 | if Path(filepath).is_file():
|
| 233 | + # strip off the leading parts of path |
232 | 234 | archive_path = str(Path(*Path(filepath).parts[7:]))
|
233 | 235 | if _is_mol_or_sdf(filepath):
|
234 | 236 | # It's a MOL or SD file.
|
@@ -285,9 +287,13 @@ def _protein_files_zip(zip_contents, ziparchive, error_file):
|
285 | 287 | continue
|
286 | 288 |
|
287 | 289 | for prot, prot_file in files.items():
|
288 |
| - if not _add_file_to_zip_aligned(ziparchive, prot.split(":")[0], prot_file): |
289 |
| - error_file.write(f'{param},{prot},{prot_file}\n') |
290 |
| - prot_errors += 1 |
| 290 | + # if it's a list of files (map_info) instead of single file |
| 291 | + if not isinstance(prot_file, list): |
| 292 | + prot_file = [prot_file] |
| 293 | + for f in prot_file: |
| 294 | + if not _add_file_to_zip_aligned(ziparchive, prot.split(":")[0], f): |
| 295 | + error_file.write(f'{param},{prot},{f}\n') |
| 296 | + prot_errors += 1 |
291 | 297 |
|
292 | 298 | return prot_errors
|
293 | 299 |
|
@@ -606,10 +612,14 @@ def _create_structures_dict(target, site_obvs, protein_params, other_params):
|
606 | 612 | # getting the param from experiment. more data are
|
607 | 613 | # coming from there, that's why this is in try
|
608 | 614 | # block
|
609 |
| - # getattr retrieves FieldFile object, hance the .name |
610 |
| - zip_contents['proteins'][param][so.code] = getattr( |
611 |
| - so.experiment, param |
612 |
| - ).name |
| 615 | + model_attr = getattr(so.experiment, param) |
| 616 | + # getattr retrieves FieldFile object, hence the .name |
| 617 | + if isinstance(model_attr, list): |
| 618 | + # except map_files, this returns a list of files |
| 619 | + zip_contents['proteins'][param][so.code] = model_attr |
| 620 | + else: |
| 621 | + zip_contents['proteins'][param][so.code] = model_attr.name |
| 622 | + |
613 | 623 | except AttributeError:
|
614 | 624 | # on the off chance that the data are in site_observation model
|
615 | 625 | zip_contents['proteins'][param][so.code] = getattr(so, param).name
|
@@ -686,6 +696,7 @@ def get_download_params(request):
|
686 | 696 | 'bound_file',
|
687 | 697 | 'cif_info',
|
688 | 698 | 'mtz_info',
|
| 699 | + 'map_info', |
689 | 700 | 'event_file',
|
690 | 701 | 'sigmaa_file',
|
691 | 702 | 'diff_file',
|
|
0 commit comments