def test_run_output_dir_not_existing(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), "output_dir_not_existing", 'new_output_folder' ] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), "output_dir_not_existing", 'old_output_folder' ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => ISAC or Beautifier run output directory does not exist. Please check the directory path and restart the program.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_substack_basename_empty_string(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), 'NEW_OUTPUT', "--substack_basename= " ] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), 'OLD_OUTPUT', "--substack_basename= " ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => Substack basename cannot be empty string or only white spaces.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_bdb_not_existing(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'isac_substack', 'bdb:' + "Bad_path_toDB", path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), 'new_output_folder' ] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_pipe.py"), 'isac_substack', 'bdb:' + "Bad_path_toDB", path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), 'old_output_folder' ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => Input BDB image stack file does not exist. Please check the file path and restart the program.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_default_ordered_class_averagesHDF_not_found(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), "/", 'new_output_folder' ] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), "/", 'new_output_folder' ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => ISAC or Beautifier run output directory does not contain the default ISAC class average stack file (/ordered_class_averages.hdf). Please check the directory path or specify ISAC class average stack file, then restart the program.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_output_dir_existing(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), ' /' ] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), ' /' ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => Output directory exists. Please change the name and restart the program.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_run_tutorial(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.new_output_folder, '--pixel_size=1.14', '--mol_mass=1400', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--invert_handedness' ] testargs_old = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.old_output_folder, '--pixel_size=1.14', '--mol_mass=1400', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--invert_handedness' ] with patch.object(sys, 'argv', testargs_new): fu.main() with patch.object(sys, 'argv', testargs_old): oldfu.main() old_value = get_im(path.join(self.old_output_folder, self.filename)) new_value = get_im(path.join(self.new_output_folder, self.filename)) self.assertTrue( array_equal(old_value.get_3dview(), new_value.get_3dview())) self.assertTrue( allclose( new_value.get_3dview().flatten().tolist()[4884850:4885000], [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 45.657344818115234, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 45.90496063232422, 46.82423400878906, 46.874420166015625, 46.04456329345703, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0 ], atol=0.1)) remove_dir(self.new_output_folder) remove_dir(self.old_output_folder)
def test_run(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), self.new_output_folder ] #," --isac_class_avgs_path ='/home/lusnig/Downloads/LucaTest_beaut/best.hdf'"] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), self.old_output_folder ] with patch.object(sys, 'argv', testargs_new): fu.main() with patch.object(sys, 'argv', testargs_old): oldfu.main()
def test_no_molMass_and_densityThresholdError(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.new_output_folder, '--pixel_size=1.14', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--invert_handedness' ] testargs_old = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.old_output_folder, '--pixel_size=1.14', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--invert_handedness' ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => Molecular mass [kDa] or density_threshold is required. Please set a pasitive value larger than 0.0 to --mol_mass option or --use_density_threshold option.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_run(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'angular_distribution', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "11_MERIDIEN", "final_params_028.txt"), self.new_output_folder, '--symmetry=c5', '--pixel_size=1.14', '--box_size=352' ] testargs_old = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'angular_distribution', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "11_MERIDIEN", "final_params_028.txt"), self.old_output_folder, '--symmetry=c5', '--pixel_size=1.14', '--box_size=352' ] with patch.object(sys, 'argv', testargs_new): fu.main() with patch.object(sys, 'argv', testargs_old): oldfu.main() remove_dir(self.new_output_folder) remove_dir(self.old_output_folder)
def test_invali_lowPass_filter_resolutionError(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.new_output_folder, '--mol_mass=1400', '--pixel_size=0.5', '--fl=0.2', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--invert_handedness' ] testargs_old = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.old_output_folder, '--mol_mass=1400', '--fl=0.2', '--pixel_size=0.5', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--invert_handedness' ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => Invalid low-pass filter resolution 0.2[A] for 3D volume. Please set a value larger than or equal to Nyquist resolution 1.0[A].' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_specified_ordered_class_averagesHDF_not_found(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), 'NEW_OUTPUT', "--isac_class_avgs_path=" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "invalidDB.hdf") ] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_pipe.py"), 'isac_substack', "bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_PARTICLES#stack"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), 'old_outpuT', "--isac_class_avgs_path=" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "invalidDB.hdf") ] with patch.object(sys, 'argv', testargs_new): with self.assertRaises(SystemExit): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): with self.assertRaises(SystemExit): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => The specifed ISAC class average stack file does not exist. Please check the file path and restart the program.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1])
def test_run_molMass_and_threashold_ignoring_values(self): testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.new_output_folder, '--pixel_size=1.14', '--mol_mass=1400', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--use_density_threshold=0.1', '--invert_handedness' ] testargs_old = [ path.join(ABSOLUTE_BIN_PATH, "sp_pipe.py"), 'moon_eliminator', path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "07_RVIPER", "average_volume_001.hdf"), self.old_output_folder, '--pixel_size=1.14', '--mol_mass=1400', "--resample_ratio=" + path.join( ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "04_ISAC"), '--box_size=352', '--use_density_threshold=0.1', '--invert_handedness' ] with patch.object(sys, 'argv', testargs_new): old_stdout = sys.stdout print_new = StringIO() sys.stdout = print_new fu.main() with patch.object(sys, 'argv', testargs_old): print_old = StringIO() sys.stdout = print_old oldfu.main() sys.stdout = old_stdout old_value = get_im(path.join(self.old_output_folder, self.filename)) new_value = get_im(path.join(self.new_output_folder, self.filename)) self.assertTrue( array_equal(old_value.get_3dview(), new_value.get_3dview())) self.assertEqual( print_new.getvalue().split('\n')[5].split("ERROR")[1], ' => You provided values for both --mol_mass and --use_density_threshold. --mol_mass is used and --use_density_threshold ignored.' ) self.assertEqual(print_new.getvalue().split('\n')[5].split("ERROR")[1], print_old.getvalue().split('\n')[5].split("ERROR")[1]) self.assertTrue( allclose( new_value.get_3dview().flatten().tolist()[4884850:4885000], [ 13.436051368713379, 16.304325103759766, 19.431846618652344, 22.773143768310547, 26.281518936157227, 29.846433639526367, 33.33924865722656, 36.65176010131836, 39.61358642578125, 42.10240936279297, 44.03025436401367, 45.198368072509766, 45.6573486328125, 45.332122802734375, 44.2328987121582, 42.458248138427734, 39.976200103759766, 36.98574447631836, 33.579429626464844, 29.869462966918945, 26.018442153930664, 22.143997192382812, 18.370195388793945, 14.833773612976074, 11.611379623413086, 8.771808624267578, 6.44216775894165, 4.582822799682617, 3.266218423843384, 2.4977657794952393, 2.247335910797119, 2.614610195159912, 3.500377893447876, 4.934632301330566, 6.914317607879639, 9.367624282836914, 12.337867736816406, 15.699345588684082, 19.383285522460938, 23.31256675720215, 27.345870971679688, 31.34865379333496, 35.194488525390625, 38.70415496826172, 41.74859619140625, 44.22425842285156, 45.90496063232422, 46.82423400878906, 46.874420166015625, 46.04456329345703, 44.42490005493164, 41.9677619934082, 38.900634765625, 35.33403396606445, 31.41274642944336, 27.333709716796875, 23.237581253051758, 19.26754379272461, 15.562416076660156, 12.18584156036377, 9.18964672088623, 6.660860061645508, 4.532906532287598, 2.8384335041046143, 1.5370008945465088, 0.5794053077697754, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.1746208667755127, 0.19713549315929413, 0.16420751810073853, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0 ], atol=0.1)) remove_dir(self.new_output_folder) remove_dir(self.old_output_folder)