Ejemplo n.º 1
0
	def test_read(self):

		in_grp = grp.read(os.path.join(FUNCTIONAL_TESTS_DIR, "test.grp"))
		self.assertEqual(in_grp, ["r", "d", "e"])

		with self.assertRaises(AssertionError) as e:
			grp.read("testt.grp")
		self.assertIn("The following GRP file", str(e.exception))
Ejemplo n.º 2
0
def main():
    """Main function
    """

    # Get args
    parser = build_parser()
    try:
        args = parser.parse_args()
    except:
        parser.print_help()
        sys.exit(0)

    if args.input_glob:
        gct_files = glob.glob(args.input_glob)
    elif args.input_list:
        gct_files = grp.read(args.input_list)
    else:
        raise Exception('input_glob or input_list must be specified')

    gct_list = load_data(gct_files)

    setup_logger.setup(verbose=args.verbose)
    adj_ds, adj_list = combat_by_group(gct_list,
                                       col_group=args.col_group,
                                       batch_field=args.batch_field,
                                       use_col_group_as_batch=args.use_col_group_as_batch)
    save_data(adj_ds, adj_list)
Ejemplo n.º 3
0
def _read_arg(arg):
    """
    If arg is a list with 1 element that corresponds to a valid file path, use
    set_io.grp to read the grp file. Otherwise, check that arg is a list of strings.

    Args:
        arg (list or None)

    Returns:
        arg_out (list or None)
    """

    # If arg is None, just return it back
    if arg is None:
        arg_out = arg

    else:
        # If len(arg) == 1 and arg[0] is a valid filepath, read it as a grp file
        if len(arg) == 1 and os.path.exists(arg[0]):
            arg_out = grp.read(arg[0])
        else:
            arg_out = arg

        # Make sure that arg_out is a list of strings
        assert isinstance(arg_out, list), "arg_out must be a list."
        assert type(arg_out[0]) == str, "arg_out must be a list of strings."

    return arg_out
Ejemplo n.º 4
0
	def test_write(self):

		example_grp = ["x", "z", "w"]

		out_path = os.path.join(FUNCTIONAL_TESTS_DIR, "test_write.grp")
		grp.write(example_grp, out_path)
		self.assertTrue(os.path.exists(out_path))

		read_back_in = grp.read(out_path)
		self.assertEqual(example_grp, read_back_in)

		# Cleanup
		os.remove(out_path)