def test_run_all_fixture_commands(self, test_outdir, commands): """This test runs all the commands parameterized in the 'commands' fixture defined above. (pytest is actually responsible for running the running this test once for each command / fixture parameter). Args: test_outdir (a fixture): This is the output directory into which all output files are placed. commands (a parameterized fixture): This boils down to actual command line arguments given to dupliganger. """ # Get the arguments passed args = docopt(__doc__, help=False, argv=commands.split()) # Fix input file path(s) and outdir path (prepend INFILE_DIR and OUTFILE_DIR) args = fix_paths(args, INFILE_DIR, OUTFILE_DIR, COMMAND_FILE_PARAMS) # Get alignment file... alignment_file = args['<alignment-file>'] # Run dupliganger command! (parent_db, read_group_db, loc_db) = run(*parse_args(args)) # 13_third_test.sam -> 13_third_test.read_group_db # 13_third_test.sam -> 13_third_test.read_name_db # 13_third_test.sam -> 13_third_test.loc_db for db_name in 'read_group_db loc_db'.split(): # Get string representation of db db_repr = str(locals()[db_name]) # Get expected out filename eout = to_eout_db_dump_filename(alignment_file, db_name) with open(eout, 'r') as e: assert db_repr == e.read()
def test_run_all_fixture_commands(self, test_outdir, commands): """This test runs all the commands parameterized in the 'commands' fixture defined above. (pytest is actually responsible for running the running this test once for each command / fixture parameter). Args: test_outdir (a fixture): This is the output directory into which all output files are placed. commands (a parameterized fixture): This boils down to actual command line arguments given to dupliganger. """ # Get the arguments passed args = docopt(__doc__, help=False, argv=commands.split()) # Fix input file path(s) and outdir path (prepend INFILE_DIR and OUTFILE_DIR) args = fix_paths(args, INFILE_DIR, OUTFILE_DIR, COMMAND_FILE_PARAMS) # Run dupliganger command! out_files = run(*parse_args(args)) for fout in out_files: if fout == '/dev/null': # skip /dev/null's obviously... continue # Note that dedup.py uses python's pseudo-random number generator, and # the RNG differs between py2 and py3, so we pass fix_paths the python # version to get around this (we have to keep two versions of in/eout # files, one for py2 and one for py3). eout = to_eout_filename(fout, sys.version_info[0]) with open(fout, 'r') as f, open(eout, 'r') as e: assert f.read() == e.read()
def test_run_all_fixture_commands(self, test_outdir, commands): """This test runs all the commands parameterized in the 'commands' fixture defined above. (pytest is actually responsible for running the running this test once for each command / fixture parameter). Args: test_outdir (a fixture): This is the output directory into which all output files are placed. commands (a parameterized fixture): This boils down to actual command line arguments given to dupliganger. """ # Get the arguments passed args = docopt(__doc__, help=False, argv=commands.split()) # Fix input file path(s) and outdir path (prepend INFILE_DIR and OUTFILE_DIR) args = fix_paths(args, INFILE_DIR, OUTFILE_DIR, COMMAND_FILE_PARAMS) # Run dupliganger command! out_files = run(*parse_args(args)) for fout in out_files: eout = to_eout_filename(fout) with open(fout, 'r') as f, open(eout, 'r') as e: assert f.read() == e.read()