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_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)
def test_run(self): testcommand_new = ( MPI_PATH + " -np " + str(NUM_PROC) + " " + path.join(ABSOLUTE_BIN_PATH, "sp_isac2.py") + " 'bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_Particles#stack'") + " '" + self.new_output_folder + "' " + " --radius=145" + " --CTF") testcommand_old = ( MPI_PATH + " -np " + str(NUM_PROC) + " " + path.join(ABSOLUTE_OLDBIN_PATH, "sp_isac2.py") + " 'bdb:" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "03_Particles#stack'") + " '" + self.old_output_folder + "' " + " --radius=145" + " --CTF") subprocess.run(args=[testcommand_new], shell=True, capture_output=True) subprocess.run(args=[testcommand_old], shell=True, capture_output=True) 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( allclose(old_value.get_2dview(), new_value.get_2dview(), atol=TOLERANCE)) self.assertTrue( allclose(new_value.get_2dview().flatten().tolist()[0:100], [ 0.020844653248786926, 0.022487156093120575, 0.02208145707845688, 0.018550248816609383, 0.018665246665477753, 0.019494876265525818, 0.02418450079858303, 0.027667080983519554, 0.02900763787329197, 0.025944046676158905, 0.031390730291604996, 0.027120821177959442, 0.00910606887191534, -0.0004518263158388436, 0.009620467200875282, 0.025462428107857704, 0.02613203041255474, 0.026837026700377464, 0.019651882350444794, -0.0013422714546322823, -0.004115818999707699, 0.03214756399393082, 0.03178049996495247, 0.011443180963397026, 0.025857364758849144, 0.026638126000761986, 0.03655451536178589, 0.05426323413848877, 0.06268023699522018, 0.03984970971941948, 0.013704168610274792, 0.008193270303308964, 0.005416750907897949, -0.012422064319252968, -0.012422808445990086, 0.014235804788768291, 0.024870628491044044, -0.005099047441035509, -0.009270750917494297, 0.015586614608764648, -0.0036001892294734716, -0.02533501200377941, -0.004470369778573513, 0.02382775768637657, 0.05031612142920494, 0.04690878838300705, 0.02393484115600586, 0.027014095336198807, 0.039149295538663864, 0.03573647513985634, 0.02213861420750618, 0.032027628272771835, 0.03532850742340088, 0.03128813952207565, 0.01826963573694229, 0.028490642085671425, 0.046303264796733856, 0.01782909594476223, -0.00606165686622262, -0.016502195969223976, -0.005856842268258333, 0.019041359424591064, 0.02800695225596428, 0.026184026151895523, 0.023107700049877167, 0.02628708817064762, 0.022019468247890472, 0.019245078787207603, 0.020709989592432976, 0.021585211157798767, 0.02417927235364914, 0.021674703806638718, 0.0199696384370327, 0.021289950236678123, 0.020935336127877235, 0.021501578390598297, 0.022525610402226448, 0.02044103667140007, 0.01824958808720112, 0.023783020675182343, 0.025899477303028107, 0.023173417896032333, 0.0289889145642519, 0.03435958921909332, 0.03157936781644821, 0.03505755960941315, 0.04005855321884155, 0.034827277064323425, 0.022344911471009254, 0.008706190623342991, 0.01249337662011385, 0.019858719781041145, 0.021026115864515305, 0.029216332361102104, 0.010308701545000076, -0.01953706704080105, -0.012493203394114971, 0.022878523916006088, 0.022390954196453094, 0.0009752019541338086 ], atol=TOLERANCE))
def test_cter_pap(self): sp_global_def.BATCH = True self.remove_folders() testargs_new = [ path.join(ABSOLUTE_BIN_PATH, "sp_cter.py"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "CorrectedSums", "corrsum_dw", "TcdA1-001*_frames.mrc"), self.new_output_folder + "pap", "--selection_list=" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "01_CTER", "Tutorial_micrographs_select.txt"), "--apix=1.14", "--Cs=0", "--pap", "--f_start=40", "--f_stop=34" ] testargs_old = [ path.join(ABSOLUTE_OLDBIN_PATH, "sp_cter.py"), path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "CorrectedSums", "corrsum_dw", "TcdA1-001*_frames.mrc"), self.old_output_folder + "pap", "--selection_list=" + path.join(ABSOLUTE_PATH_TO_SPHIRE_DEMO_RESULTS_FOLDER_NEW, "01_CTER", "Tutorial_micrographs_select.txt"), "--apix=1.14", "--Cs=0", "--pap", "--f_start=40", "--f_stop=34" ] with patch.object(sys, 'argv', testargs_new): fu.main() sp_global_def.BATCH = True with patch.object(sys, 'argv', testargs_old): oldfu.main() old_value = get_im( path.join(self.old_output_folder + "pap", self.filename)) new_value = get_im( path.join(self.new_output_folder + "pap", self.filename)) self.assertTrue( array_equal(old_value.get_2dview(), new_value.get_2dview())) self.assertTrue( array_equal(new_value.get_2dview().flatten().tolist()[0:100], [ -151.91610717773438, -5.15772008895874, -7.199570178985596, 16.844715118408203, -86.01467895507812, 224.5313720703125, 255.96446228027344, 127.28541564941406, -107.42439270019531, -146.97732543945312, 45.27460861206055, 134.89849853515625, 193.75506591796875, 1.6738426685333252, -291.7831726074219, -261.452880859375, -87.77507019042969, -253.7869873046875, -14.231243133544922, 105.49187469482422, 54.15253448486328, 202.34719848632812, -145.9459686279297, -310.8766784667969, -168.98582458496094, -246.27511596679688, -267.9120788574219, -83.6864013671875, 277.79608154296875, 151.8765106201172, 13.589789390563965, 11.07779312133789, -84.60417175292969, 100.78224182128906, -182.1418914794922, -1.2914609909057617, -105.66407775878906, -8.37000560760498, 96.46575164794922, -81.93226623535156, -29.234130859375, -128.64105224609375, 80.63739776611328, -11.062923431396484, 107.84751892089844, -108.09345245361328, 17.696636199951172, -93.53311157226562, 67.41581726074219, 273.3633728027344, -28.720521926879883, -34.706932067871094, -195.11680603027344, -200.7438507080078, -46.45978546142578, -22.808040618896484, -91.24805450439453, 113.92597961425781, 115.37574005126953, -19.18140411376953, -39.19940948486328, -80.63643646240234, 291.9253845214844, 32.61348342895508, -112.9101333618164, -130.7708282470703, -70.37080383300781, -260.5411071777344, -163.13958740234375, -141.8155975341797, -4.3243408203125, -79.0434341430664, -118.28507232666016, 245.7770233154297, -86.85401153564453, -84.1547622680664, -5.078440189361572, -53.13208770751953, -47.206058502197266, 53.22468948364258, 75.35106658935547, 77.2694320678711, 113.52538299560547, -53.97866439819336, 1.6344045400619507, 57.784603118896484, -78.45945739746094, -69.10759735107422, -83.55438232421875, 63.753501892089844, 75.83992767333984, -36.30785369873047, 97.44556427001953, 100.17158508300781, 57.608177185058594, -89.75988006591797, 141.65589904785156, 14.772521018981934, -143.1587371826172, -54.35596466064453 ])) self.remove_folders()