@@ -68,16 +68,44 @@ def _get_sensorgram_datacube(sensorgram_data: pd.DataFrame) -> DataCube:
6868
6969
7070def _get_device_control_custom_info (data : Data ) -> DictType :
71- custom_ifo : dict [str , Any ] = {
71+ application_template_details = data .application_template_details
72+
73+ custom_info : dict [str , Any ] = {
7274 "number of flow cells" : data .chip_data .number_of_flow_cells ,
7375 "number of spots" : data .chip_data .number_of_spots ,
7476 "buffer volume" : quantity_or_none (
7577 TQuantityValueMilliliter , data .run_metadata .buffer_volume
7678 ),
7779 }
7880 if detection_setting := data .run_metadata .detection_setting :
79- custom_ifo .update ({detection_setting .key : detection_setting .value })
80- return custom_ifo
81+ custom_info .update ({detection_setting .key : detection_setting .value })
82+
83+ detection_info = application_template_details .get_nested ("detection" )
84+ custom_info .update (
85+ detection_info .get (key = {"FlowCellSingle" , "FlowCellDual" , "FlowCellMulti" })
86+ )
87+
88+ temp_info = application_template_details .get_nested ("RackTemperature" )
89+ custom_info .update (
90+ temp_info .get_keys_as_dict (
91+ {
92+ "minimum operating temperature" : (float , "min" , None ),
93+ "maximum operating temperature" : (float , "max" , None ),
94+ }
95+ )
96+ )
97+
98+ system_preparations = application_template_details .get_nested ("system_preparations" )
99+ custom_info .update (
100+ system_preparations .get_keys_as_dict (
101+ {
102+ "analysis temperature" : (float , "AnalTemp" , None ),
103+ "prime" : (bool , "Prime" , None ),
104+ "normalize" : (bool , "Normalize" , None ),
105+ }
106+ )
107+ )
108+ return custom_info
81109
82110
83111def create_metadata (data : Data , named_file_contents : NamedFileContents ) -> Metadata :
@@ -103,15 +131,19 @@ def create_metadata(data: Data, named_file_contents: NamedFileContents) -> Metad
103131 lot_number = chip_data .lot_number ,
104132 sensor_chip_identifier = chip_data .sensor_chip_identifier ,
105133 device_document = [
106- DeviceDocument (device .type_ , device .identifier )
134+ DeviceDocument (device .type_ , device .identifier , device . custom_info )
107135 for device in run_metadata .devices
108136 ],
109137 sensor_chip_custom_info = chip_data .custom_info ,
138+ data_system_custom_info = system_information .data_system_custom_info ,
139+ device_system_custom_info = system_information .device_system_custom_info ,
110140 )
111141
112142
113143def create_measurements (
114- measurements_data : list [MeasurementData ], device_control_custom_info : DictType
144+ measurements_data : list [MeasurementData ],
145+ device_control_custom_info : DictType ,
146+ data : Data ,
115147) -> list [Measurement ]:
116148 return [
117149 Measurement (
@@ -129,13 +161,25 @@ def create_measurements(
129161 flow_rate = measurement .flow_rate ,
130162 contact_time = measurement .contact_time ,
131163 dilution = measurement .dilution ,
132- device_control_custom_info = device_control_custom_info ,
164+ device_control_custom_info = dict (
165+ device_control_custom_info
166+ ), # copy to avoid modifying the original
133167 )
134168 ],
135169 sample_custom_info = {
170+ ** data .application_template_details .get_nested (
171+ "racks"
172+ ).get_keys_as_dict (
173+ {
174+ "Rack1" : (str , "_Rack1" , None ),
175+ "Rack2" : (str , "_Rack2" , None ),
176+ "Lock Positions" : (bool , "_LockPositions" , None ),
177+ }
178+ ),
136179 "molecular weight" : quantity_or_none (
137180 TQuantityValueDalton , measurement .molecular_weight
138- )
181+ ),
182+ ** measurement .sample_custom_info ,
139183 },
140184 sensorgram_data_cube = _get_sensorgram_datacube (measurement .sensorgram_data ),
141185 report_point_data = (
@@ -168,7 +212,7 @@ def create_measurement_groups(data: Data) -> list[MeasurementGroup]:
168212 MeasurementGroup (
169213 measurement_time = system_information .measurement_time ,
170214 measurements = create_measurements (
171- measurements_data , device_control_custom_info
215+ measurements_data , device_control_custom_info , data
172216 ),
173217 experiment_type = system_information .experiment_type ,
174218 analytical_method_identifier = system_information .analytical_method_identifier ,
@@ -181,6 +225,10 @@ def create_measurement_groups(data: Data) -> list[MeasurementGroup]:
181225 TQuantityValueHertz ,
182226 try_float_or_none (data .run_metadata .data_collection_rate ),
183227 ),
228+ ** data .application_template_details .get_nested (
229+ "properties"
230+ ).get_keys_as_dict ({"Run Type" : (str , "TypeName" , None )}),
231+ ** system_information .measurement_aggregate_custom_info ,
184232 },
185233 )
186234 for measurements_data in data .sample_data .measurements .values ()
0 commit comments