2121torch .manual_seed (43 )
2222
2323
24+ @pytest .fixture
25+ def openhdx_zip_file () -> bytes :
26+ with open (input_dir / "HDX_D9096080.zip" , "rb" ) as f :
27+ binary = f .read ()
28+ return binary
29+
30+
2431@pytest .fixture
2532def ppix_spec () -> dict :
2633 return yaml .safe_load (Path (input_dir / "PpiX_states.yaml" ).read_text ())
@@ -66,7 +73,7 @@ def test_load_single_file():
6673 input_control .exp_state = "SecB WT apo"
6774 timepoints = list (np .array ([0.167 , 0.5 , 1.0 , 5.0 , 10.0 , 100.000008 ]) * 60 )
6875 assert input_control .exp_exposures == timepoints
69- input_control ._add_single_dataset_spec ()
76+ input_control ._add_measurement ()
7077 input_control ._action_load_datasets ()
7178
7279 assert "SecB WT apo" in src .hdxm_objects
@@ -79,15 +86,13 @@ def test_load_single_file():
7986 assert np .nanmean (hdxm .rfu_residues ) == pytest .approx (0.6335831166442542 )
8087
8188
82- def test_batch_input ( secb_file_dict ):
89+ def test_zip_input ( openhdx_zip_file : bytes ):
8390 ctrl , tmpl = main_app ()
8491
8592 input_control = ctrl .control_panels ["PeptideFileInputControl" ]
86- input_control .input_mode = "Batch"
87- input_control .widgets ["input_files" ].filename = list (secb_file_dict .keys ())
88- input_control .input_files = list (secb_file_dict .values ())
89-
90- input_control .batch_file = Path (input_dir / "data_states.yaml" ).read_bytes ()
93+ input_control .input_mode = "openHDX zip"
94+ input_control .widgets ["zip_file" ].filename = "HDX_D9096080.zip"
95+ input_control .zip_file = openhdx_zip_file
9196
9297 input_control ._action_load_datasets ()
9398
@@ -115,12 +120,12 @@ def test_web_fitting():
115120
116121 input_control .exp_state = "SecB WT apo"
117122 input_control .measurement_name = "testname_123"
118- input_control ._add_single_dataset_spec ()
123+ input_control ._add_measurement ()
119124
120125 input_control .exp_file = "ecSecB_dimer.csv"
121126 input_control .exp_state = "SecB his dimer apo"
122127 input_control .measurement_name = "SecB his dimer apo" # todo catch error duplicate name
123- input_control ._add_single_dataset_spec ()
128+ input_control ._add_measurement ()
124129
125130 input_control ._action_load_datasets ()
126131
@@ -138,15 +143,17 @@ def test_web_fitting():
138143@pytest .mark .skipif (
139144 not sys .platform .startswith ("win" ), reason = "output slightly different on other platforms"
140145)
141- def test_web_load (secb_spec , secb_file_dict ):
146+ def test_web_load (openhdx_zip_file : bytes ):
142147 ctrl , tmpl = main_app ()
143148
144- file_input = ctrl .control_panels ["PeptideFileInputControl" ]
145- states = ["SecB_tetramer" , "SecB_dimer" ]
146- load_state (file_input , secb_spec , data_dir = input_dir , states = states )
149+ input_control = ctrl .control_panels ["PeptideFileInputControl" ]
150+ input_control .input_mode = "openHDX zip"
151+ input_control .widgets ["zip_file" ].filename = "HDX_D9096080.zip"
152+ input_control .zip_file = openhdx_zip_file
147153
148- file_input ._action_load_datasets ()
149- assert len (file_input .src .hdxm_objects ) == 2
154+ input_control ._action_load_datasets ()
155+
156+ assert len (input_control .src .hdxm_objects ) == 2
150157
151158 file_export = ctrl .control_panels ["FileExportControl" ]
152159
@@ -170,45 +177,8 @@ def test_web_load(secb_spec, secb_file_dict):
170177 df_ref = csv_to_dataframe (output_dir / "main_web" / "rfu_colors.csv" )
171178 pd .testing .assert_frame_equal (df_test , df_ref )
172179
173- # Download HDX spec file
174- sio_hdx_spec = file_export .hdx_spec_callback ()
175-
176- del ctrl
177- del file_export
178- del file_input
179-
180- # load a new instance of the main app, reload previous data through batch input
181- new_ctrl , tmpl = main_app ()
182- input_control = new_ctrl .control_panels ["PeptideFileInputControl" ]
183-
184- sio_hdx_spec .seek (0 )
185- input_control .input_mode = "Batch"
186- input_control .widgets ["input_files" ].filename = list (secb_file_dict .keys ())
187- input_control .input_files = list (secb_file_dict .values ())
188-
189- input_control .batch_file = sio_hdx_spec .read ().encode ("utf-8" )
190- input_control ._action_load_datasets ()
191-
192- file_export = new_ctrl .control_panels ["FileExportControl" ]
193-
194- # check rfu table output
195- file_export .table = "rfu"
196- sio = file_export .table_export_callback ()
197- df_test = csv_to_dataframe (sio )
198- df_ref = csv_to_dataframe (output_dir / "main_web" / "rfu.csv" )
199- pd .testing .assert_frame_equal (df_test , df_ref )
200-
201- # check table output
202- file_export .table = "peptides"
203- sio = file_export .table_export_callback ()
204- df_test = csv_to_dataframe (sio )
205- df_ref = csv_to_dataframe (output_dir / "main_web" / "peptides.csv" )
206- pd .testing .assert_frame_equal (df_test , df_ref )
207-
208180
209- @pytest .mark .skipif (
210- not sys .platform .startswith ("win" ), reason = "output slightly different on other platforms"
211- )
181+ @pytest .mark .skip ("outdated, uses hdxms-datasets v0.1.5 input format" )
212182def test_rfu (ppix_spec , ppix_file_dict ):
213183 """Test the RFU app"""
214184 ctrl , tmpl = rfu_app ()
0 commit comments