@@ -52,6 +52,12 @@ def _build_single_study_info(study, info, study_proc, proc_samples):
52
52
The study to build information for
53
53
info : dict
54
54
Information from Study.get_info
55
+ study_proc : dict of lists
56
+ Dictionary keyed on study_id that lists all processed data associated
57
+ with that study.
58
+ proc_samples : dict of lists
59
+ Dictionary keyed on proc_data_id that lists all samples associated with
60
+ that processed data.
55
61
56
62
Returns
57
63
-------
@@ -76,20 +82,18 @@ def _build_single_study_info(study, info, study_proc, proc_samples):
76
82
del info ["principal_investigator_id" ]
77
83
del info ["email" ]
78
84
# Build the proc data info list for the child row in datatable
79
- info ["proc_data_info" ] = _build_single_proc_data_info (
80
- study , study_proc , proc_samples )
85
+ info ["proc_data_info" ] = [
86
+ _build_single_proc_data_info (pd_id , proc_samples [pd_id ])
87
+ for pd_id in study_proc [study .id ]]
81
88
return info
82
89
83
90
84
- def _build_single_proc_data_info (study , study_proc , proc_samples ):
91
+ def _build_single_proc_data_info (proc_data_id , samples ):
85
92
"""Build the proc data info list for the child row in datatable
86
93
87
-
88
94
Parameters
89
95
----------
90
- study : Study object
91
- The study to build information for
92
- study_proc : dict of lists
96
+ proc_data_id : int
93
97
The processed data attached to he study, in the form
94
98
{study_id: [proc_data_id, proc_data_id, ...], ...}
95
99
proc_samples : dict of lists
@@ -98,24 +102,20 @@ def _build_single_proc_data_info(study, study_proc, proc_samples):
98
102
99
103
Returns
100
104
-------
101
- dict of dicts
102
- The information for the processed data, in the form
103
- {proc_data_id: {info: value, ...}, ...}
105
+ dict
106
+ The information for the processed data, in the form {info: value, ...}
104
107
"""
105
- proc_data_info = []
106
- for pid in study_proc [study .id ]:
107
- proc_data = ProcessedData (pid )
108
- proc_info = proc_data .processing_info
109
- proc_info ['pid' ] = pid
110
- proc_info ['data_type' ] = proc_data .data_type ()
111
- proc_info ['samples' ] = sorted (proc_samples [pid ])
112
- proc_info ['processed_date' ] = str (proc_info ['processed_date' ])
113
- proc_data_info .append (proc_info )
114
- return proc_data_info
108
+ proc_data = ProcessedData (proc_data_id )
109
+ proc_info = proc_data .processing_info
110
+ proc_info ['pid' ] = proc_data_id
111
+ proc_info ['data_type' ] = proc_data .data_type ()
112
+ proc_info ['samples' ] = sorted (samples )
113
+ proc_info ['processed_date' ] = str (proc_info ['processed_date' ])
114
+ return proc_info
115
115
116
116
117
117
def _build_study_info (user , study_proc = None , proc_samples = None ):
118
- """builds list of dicts for studies table, with all html formatted
118
+ """Builds list of dicts for studies table, with all HTML formatted
119
119
120
120
Parameters
121
121
----------
@@ -171,11 +171,11 @@ def _build_study_info(user, study_proc=None, proc_samples=None):
171
171
study = Study (info ['study_id' ])
172
172
# Build the processed data info for the study if none passed
173
173
if build_samples :
174
- proc_data = study .processed_data ()
175
- proc_samples = {}
176
- study_proc = {study .id : proc_data }
177
- for pid in proc_data :
178
- proc_samples [pid ] = ProcessedData (pid ).samples
174
+ proc_data = study .processed_data ()
175
+ proc_samples = {}
176
+ study_proc = {study .id : proc_data }
177
+ for pid in proc_data :
178
+ proc_samples [pid ] = ProcessedData (pid ).samples
179
179
180
180
study_info = _build_single_study_info (study , info , study_proc ,
181
181
proc_samples )
0 commit comments