예제 #1
0
 def test_required_input_data_missing_one(self):
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em", "-m",
         "emd_1305.map"
     ]
     with self.assertRaises(AssertionError):
         cm.parse_args()
예제 #2
0
 def setUp(self):
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em",
         "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map"
     ]
     args = cm.parse_args()
     self.tbl_test, self.transformations_test_tbl = cm.rearrange_matrix_tbl(
         args)
예제 #3
0
 def test_print_voxel_size(self):
     """Test when 'v' given, print the voxel_size of the .em data"""
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em",
         "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map",
         "-v"
     ]
     args = cm.parse_args()
     self.assertEqual(args.voxel_size, 1)
예제 #4
0
 def test_data_is_compressed(self):
     """Test when '-c' or '--compress' given, its 'action' is true*. """
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em",
         "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map",
         "--compress"
     ]
     args = cm.parse_args()
     self.assertEqual(args.compress, 1)
예제 #5
0
 def test_print_origin(self):
     """Test when '-s' given, print the origin of the .em data"""
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em",
         "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map",
         "-s"
     ]
     args = cm.parse_args()
     self.assertEqual(args.map_start, 1)
예제 #6
0
 def test_print_map_start(self):
     captured_output = io.StringIO()
     sys.stdout = captured_output
     sys.argv = [
         "something", "-motl", "emd_3465.map", "tests/motl_1_1t.csv",
         "--tomogram-map-file", "emd_3464.map", "-o", "rm_c.txt", "-c", "-s"
     ]
     args = cm.parse_args()
     cm.create_output_motl(args)
     self.assertTrue(
         "nxstart: 0\nnystart: 0\nnzstart: 0" in captured_output.getvalue())
     os.remove("rm_c.txt")
예제 #7
0
 def test_motl_files_assigned_correctly(self):
     sys.argv = [
         "something", "-motl", "emd_3465.map", "tests/motl_1_1t.csv",
         "--tomogram-map-file", "emd_3464.map"
     ]
     args = cm.parse_args()
     self.assertTrue(os.path.exists(f"{args.motl_files[0]}"))
     self.assertTrue(os.path.exists(f"{args.motl_files[1]}"))
     self.assertTrue(os.path.exists(f"{args.tomogram_map_file}"))
     self.assertEqual(args.compress, 0)
     self.assertEqual(args.map_start, 0)
     self.assertEqual(args.voxel_size, 0)
예제 #8
0
 def test_output_name_specified_c(self):
     captured_output = io.StringIO()
     sys.stdout = captured_output
     sys.argv = [
         "something", "-motl", "emd_3465.map", "tests/motl_1_1t.csv",
         "--tomogram-map-file", "emd_3464.map", "-o", "rm_c.txt", "-c"
     ]
     args = cm.parse_args()
     cm.create_output_motl(args)
     self.assertTrue(os.path.exists("rm_c.txt"))
     self.assertTrue("is compressed" in captured_output.getvalue())
     os.remove("rm_c.txt")
예제 #9
0
 def test_print_map_start(self):
     captured_output = io.StringIO()
     sys.stdout = captured_output
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em",
         "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map",
         "--output", "rm_nc_2.txt", "-s"
     ]
     args = cm.parse_args()
     cm.create_output_tbl(args)
     self.assertTrue("nxstart: -162\nnystart: -162\nnzstart: -162" in
                     captured_output.getvalue())
     os.remove("rm_nc_2.txt")
예제 #10
0
 def test_print_voxel_size(self):
     captured_output = io.StringIO()
     sys.stdout = captured_output
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em",
         "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map",
         "--output", "rm_3.txt", "-v"
     ]
     args = cm.parse_args()
     cm.create_output_tbl(args)
     self.assertTrue("voxel_size in x, y, z: (5.43, 5.43, 5.43)" in
                     captured_output.getvalue())
     os.remove("rm_3.txt")
예제 #11
0
 def test_output_name_specified_c(self):
     captured_output = io.StringIO()
     sys.stdout = captured_output
     sys.argv = [
         "something", "-dynamo", "emd_1305_averaged.em",
         "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map",
         "--output", "rm_c.txt", "-c"
     ]
     args = cm.parse_args()
     cm.create_output_tbl(args)
     self.assertTrue(os.path.exists("rm_c.txt"))
     self.assertTrue("is compressed" in captured_output.getvalue())
     os.remove("rm_c.txt")
예제 #12
0
 def test_print_voxel_size(self):
     captured_output = io.StringIO()
     sys.stdout = captured_output
     sys.argv = [
         "something", "-motl", "emd_3465.map", "tests/motl_1_1t.csv",
         "--tomogram-map-file", "emd_3464.map", "-o", "rm_c.txt", "-c",
         "-s", "-v"
     ]
     args = cm.parse_args()
     cm.create_output_motl(args)
     self.assertTrue("voxel_size in x, y, z: (7.12, 7.12, 7.12)" in
                     captured_output.getvalue())
     os.remove("rm_c.txt")
예제 #13
0
 def test_check_output_data(self):
     sys.argv = [
         "something", "-motl", "emd_3465.map", "tests/motl_1_1t.csv",
         "--tomogram-map-file", "emd_3464.map"
     ]
     args = cm.parse_args()
     cm.create_output_motl(args)
     with open("output_nc.txt",
               "r") as text:  # output_nc.txt created in the last step
         data = text.readlines()
         for each in data:
             if re.match("^Data", each):
                 string_first_10 = each.replace("Data:\t", "")[0:10]
     self.assertEqual('wLHtOYrHeD', string_first_10)
     os.remove("output_nc.txt")
예제 #14
0
    def test_dynamo_files_assigned_correctly(self):
        """test that the file with {args.data}.em, {args.data}.tbl and {args.map_file} exist"""
        sys.argv = [
            "something", "-dynamo", "emd_1305_averaged.em",
            "emd_1305_averaged.tbl", "--tomogram-map-file", "emd_1305.map"
        ]
        args = cm.parse_args()

        self.assertTrue(os.path.exists(f"{args.dynamo_files[0]}"))
        self.assertTrue(os.path.exists(f"{args.dynamo_files[1]}"))
        # print(f"{args.dynamo_files}")
        self.assertTrue(os.path.exists(f"{args.tomogram_map_file}"))
        self.assertEqual(args.compress, 0)
        self.assertEqual(args.map_start, 0)
        self.assertEqual(args.voxel_size, 0)
예제 #15
0
    def test_motl_half_box(self):
        sys.argv = [
            "something", "-motl", "emd_3465.map", "tests/motl_1_1t.csv",
            "--tomogram-map-file", "emd_3464.map"
        ]
        args = cm.parse_args()
        motl, observes = cm.rearrange_matrix_motl(args)
        observed = observes[0]

        motl_object = cm.Data("tests/motl_1_1t.csv")
        motl_row = cm.MotlRow(motl_object.col_data[0], (1.78, 1.78, 1.78))
        expect_translation = motl_row.transformation
        half_box_m = np.array([[0, 0, 0, 80 * 1.78], [0, 0, 0, 80 * 1.78],
                               [0, 0, 0, 80 * 1.78]])
        # expect = expect_translation - half_box_m
        expect = expect_translation
        self.assertTrue(np.allclose(observed, expect))
예제 #16
0
    def test_compressed(self):
        sys.argv = [
            "something", "-motl", "emd_3465.map", "tests/motl_1_1t.csv",
            "--tomogram-map-file", "emd_3464.map", "-c"
        ]
        args = cm.parse_args()
        cm.create_output_motl(args)
        self.assertTrue(os.path.exists("output_c.txt"))

        with open("output_c.txt", "r") as text:
            data = text.readlines()
            for each in data:
                if re.match("^Data", each):
                    string_first_10 = each.replace("Data:\t", "")[0:10]
        print(string_first_10)
        self.assertEqual("eJwUm/cj1e", string_first_10)
        os.remove("output_c.txt")
예제 #17
0
 def test_required_input_data(self):
     sys.argv = ["something", "--tomogram_file", "emd_1305.map"]
     with self.assertRaises(AssertionError):
         cm.parse_args()