43
43
'single_sdf_file' : ('' ),
44
44
'metadata_info' : ('' ),
45
45
'smiles_info' : ('' ),
46
+ 'trans_matrix_info' : ('' ),
46
47
'extra_files' : ('extra_files' ),
47
48
'readme' : ('' ),
48
49
}
66
67
'smiles_info' : {},
67
68
},
68
69
'metadata_info' : None ,
70
+ 'trans_matrix_info' : None ,
69
71
}
70
72
71
73
@@ -345,6 +347,35 @@ def _smiles_files_zip(zip_contents, ziparchive, download_path):
345
347
os .remove (smiles_filename )
346
348
347
349
350
+ def _trans_matrix_files_zip (ziparchive , target ):
351
+ """Add transformation matrices to archive.
352
+
353
+ Note that this will always be the latest information - even for
354
+ preserved searches.
355
+ """
356
+ logger .info ('+ Processing trans matrix files' )
357
+
358
+ # grab the last set of files for this target
359
+ experiment_upload = target .experimentupload_set .order_by ('commit_datetime' ).last ()
360
+
361
+ trans_matrix_files = (
362
+ experiment_upload .neighbourhood_transforms ,
363
+ experiment_upload .conformer_site_transforms ,
364
+ experiment_upload .reference_structure_transforms ,
365
+ )
366
+ for tmf in trans_matrix_files :
367
+ if tmf :
368
+ ziparchive .write (
369
+ Path (settings .MEDIA_ROOT ).joinpath (str (tmf )),
370
+ os .path .join (
371
+ _ZIP_FILEPATHS ['trans_matrix_info' ],
372
+ Path (str (tmf )).name ,
373
+ ),
374
+ )
375
+ else :
376
+ logger .info ('File %s does not exist' , Path (str (tmf )).name )
377
+
378
+
348
379
def _extra_files_zip (ziparchive , target ):
349
380
"""If an extra info folder exists at the target root level, then
350
381
copy the contents to the output file as is.
@@ -507,6 +538,7 @@ def _create_structures_zip(target, zip_contents, file_url, original_search, host
507
538
logger .warning ('After _add_file_to_zip() errors=%s' , errors )
508
539
509
540
_extra_files_zip (ziparchive , target )
541
+ _trans_matrix_files_zip (ziparchive , target )
510
542
511
543
_document_file_zip (ziparchive , download_path , original_search , host )
512
544
@@ -613,6 +645,10 @@ def _create_structures_dict(target, site_obvs, protein_params, other_params):
613
645
if other_params ['metadata_info' ] is True :
614
646
zip_contents ['metadata_info' ] = target .metadata .name
615
647
648
+ # Add the metadata file from the target
649
+ if other_params ['trans_matrix_info' ] is True :
650
+ zip_contents ['trans_matrix_info' ] = True
651
+
616
652
return zip_contents
617
653
618
654
@@ -635,7 +671,13 @@ def get_download_params(request):
635
671
'diff_file' ,
636
672
]
637
673
638
- other_param_flags = ['sdf_info' , 'single_sdf_file' , 'metadata_info' , 'smiles_info' ]
674
+ other_param_flags = [
675
+ 'sdf_info' ,
676
+ 'single_sdf_file' ,
677
+ 'metadata_info' ,
678
+ 'smiles_info' ,
679
+ 'trans_matrix_info' ,
680
+ ]
639
681
640
682
# protein_params = {'pdb_info': request.data['pdb_info'],
641
683
# 'bound_info': request.data['bound_info'],
0 commit comments