Skip to content

Commit

Permalink
fix: fixed file paths for LHS download (issue 1075)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliif authored and alanbchristie committed Jan 5, 2024
1 parent 38e3dde commit 1e9917a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
29 changes: 13 additions & 16 deletions viewer/download_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
# the protein code subdirectory of the aligned directory
# (as for the target upload).
_ZIP_FILEPATHS = {
'pdb_info': ('aligned'),
'bound_info': ('aligned'),
'apo_file': ('aligned'),
'bound_file': ('aligned'),
'cif_info': ('aligned'),
'mtz_info': ('aligned'),
'map_info': ('aligned'),
# 'sigmaa_info': ('aligned'),
# 'diff_info': ('aligned'),
'event_info': ('aligned'),
# 'trans_matrix_info': ('aligned'),
# 'map_info': ('aligned'),
'xmap_2fofc_file': ('aligned'),
'xmap_fofc_file': ('aligned'),
'event_file': ('aligned'),
'sdf_info': ('aligned'),
'single_sdf_file': (''),
'metadata_info': (''),
Expand All @@ -49,14 +48,13 @@
# NB you may need to add a version number to this at some point...
zip_template = {
'proteins': {
'pdb_info': {}, # from experiment
'apo_file': {}, # from experiment
'bound_file': {}, # x
'cif_info': {}, # from experiment
'mtz_info': {}, # from experiment
'event_file': {}, # x
# 'diff_info': {}, # next 3, not collected anymore
# 'sigmaa_info': {},
# 'trans_matrix_info': {}
'xmap_fofc_file': {}, # renamed from xmap_fofc_file and xmap_2fofc_file
'xmap_2fofc_file': {},
},
'molecules': {
'sdf_files': {},
Expand Down Expand Up @@ -228,7 +226,7 @@ def _add_file_to_zip_aligned(ziparchive, code, filepath):
filepath = str(Path(settings.MEDIA_ROOT).joinpath(filepath))

if Path(filepath).is_file():
archive_path = str(Path('aligned').joinpath(code).joinpath(filepath))
archive_path = str(Path(*Path(filepath).parts[7:]))
if _is_mol_or_sdf(filepath):
# It's a MOL or SD file.
# Read and (potentially) adjust the file
Expand Down Expand Up @@ -651,11 +649,13 @@ def get_download_params(request):
protein_params, other_params
"""
protein_param_flags = [
'pdb_info',
'apo_file',
'bound_file',
'cif_info',
'mtz_info',
'event_file',
'xmap_2fofc_file',
'xmap_fofc_file',
]

other_param_flags = ['sdf_info', 'single_sdf_file', 'metadata_info', 'smiles_info']
Expand Down Expand Up @@ -797,11 +797,8 @@ def check_download_links(request, target, site_observations):
zip_contents = _create_structures_dict(
target, site_observations, protein_params, other_params
)

_create_structures_zip(target, zip_contents, file_url, original_search, host)

logger.debug('zip_contents: %s', zip_contents)

download_link = DownloadLinks()
download_link.file_url = file_url
if request.user.is_authenticated:
Expand Down
5 changes: 2 additions & 3 deletions viewer/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,12 +832,11 @@ class DownloadStructuresSerializer(serializers.Serializer):
bound_file = serializers.BooleanField(default=False)
cif_info = serializers.BooleanField(default=False)
mtz_info = serializers.BooleanField(default=False)
# diff_info = serializers.BooleanField(default=False)
xmap_fofc_file = serializers.BooleanField(default=False)
event_file = serializers.BooleanField(default=False)
# sigmaa_info = serializers.BooleanField(default=False)
xmap_2fofc_file = serializers.BooleanField(default=False)
sdf_info = serializers.BooleanField(default=False)
single_sdf_file = serializers.BooleanField(default=False)
# trans_matrix_info = serializers.BooleanField(default=False)
metadata_info = serializers.BooleanField(default=False)
smiles_info = serializers.BooleanField(default=False)
static_link = serializers.BooleanField(default=False)
Expand Down

0 comments on commit 1e9917a

Please sign in to comment.