def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" from testing_utilities import run_functional_tests test_folder = "test_data" infile1 = "%s/INPUT_fasta_for_aln.fa" % test_folder # tests in (testname, [test_description,] arg_and_infile_string) format test_runs = [ ('aln__basic-1-error', '-e 1 -m 3 -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q -W' % infile1), ('aln__collapsed-input', '-e 1 -m 3 -c -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q -W' % infile1), ('aln__show-multiple-0-fasta', '-e 1 -m 0 -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q -W' % infile1), ('aln__dont-split', '-e 1 -m 3 -s -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q -W' % infile1), ('aln__no-split_multiple-0', '-e 1 -m 0 -s -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q -W' % infile1), ] # MAYBE-TODO add run-tests for more options/combinations? # argument_converter converts (parser,options,args) to the correct argument order for main argument_converter = lambda parser, options, args: (args, options) # use my custom function to run all the tests, auto-detect reference files, compare to output. return run_functional_tests(test_runs, define_option_parser(), main, test_folder, argument_converter=argument_converter, outfile_option='-o')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" from testing_utilities import run_functional_tests test_folder = 'test_data' infile1 = test_folder + '/INPUT_raw-fastq_complex-5prime.fq' infile2 = test_folder + '/INPUT_raw-fastq_simple-both-ends.fq' # tests in (testname, test_description, arg_string, infiles) format test_runs = [ ('full-not-unique', "testing all 'bad' cases, 5' end only, without collapsing to unique", '-3 ""', [infile1]), ('full-unique', "testing all 'bad' cases, 5' end only, WITH collapsing to unique for all outfiles", '-3 "" -C', [infile1]), ('end-5prime', "simpler test, 5' end only (collapsing to unique)", '-3 "" -C', [infile2]), ('end-3prime', "simpler test, 3' end only (collapsing to unique)", '-5 "" -C', [infile2]), ('ends-both', "simpler test, 5' and 3' ends (collapsing to unique)", '-C', [infile2]), # this test uses the standard 5' and 3' cassette seqs as two alternative 5' ones, so the 5' output is like ends-both 5'+3' ('ends-two-5prime', "simpler test, two 5' adapters (collapsing to unique)", '-5 %s,%s -3 "" -C'%( CASSETTE_DEFAULT_5prime,CASSETTE_DEFAULT_3prime), [infile2]), ] # MAYBE-TODO currently some of the tests are weird because fastx_collapser changes the order of the sequences for no good reason (see <IGNORE> lines in some of the files) # convert tests into (testname, arg_and_infile_string) format, adding the options that are always used test_runs = [('pre__'+testname, descr, test_args+' -Q '+' '.join(infiles)) for testname,descr,test_args,infiles in test_runs] # argument_converter converts (parser,options,args) to the correct argument order for main argument_converter = lambda parser,options,args: (args, options) # use my custom function to run all the tests, auto-detect reference files, compare to output. return run_functional_tests(test_runs, define_option_parser(), main, test_folder, argument_converter=argument_converter, outfile_option='-o', append_to_outfilenames='')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" test_folder = "test_data" infile = "test_data/INPUT_gene-data-1_all-cases.gff3" tests = [("gff-ex__gene-data-analysis", "-E -n -1 %s"%infile)] parser = define_option_parser() argument_converter = lambda parser,options,args: (args[0], options, args[1]) return run_functional_tests(tests, parser, main, test_folder, argument_converter=argument_converter, append_to_outfilenames='.txt')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" from testing_utilities import run_functional_tests test_folder = "test_data" sys.exit("NO TESTS DEFINED!") # tests in (testname, [test_description,] arg_and_infile_string) format test_runs = [ ] # argument_converter converts (parser,options,args) to the correct argument order for main argument_converter = lambda parser,options,args: (args, options) # use my custom function to run all the tests, auto-detect reference files, compare to output. return run_functional_tests(test_runs, define_option_parser(), main, test_folder, argument_converter=argument_converter, append_to_outfilenames='.txt')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" test_folder = "test_data_v0" aln_infile0 = "%s/INPUT_alignment0_old-format.sam"%test_folder aln_infile1 = "%s/INPUT_alignment1_genomic-unique.sam"%test_folder aln_infile2 = "%s/INPUT_alignment2_for-genes.sam"%test_folder aln_infile3 = "%s/INPUT_alignment3_for-merging.sam"%test_folder gff_genefile = "%s/INPUT_gene-data-1_all-cases.gff3"%test_folder dataset_to_remove = "%s/INPUT_mutants_to_remove.txt"%test_folder test_runs = [ ('cassette-end-5prime', "-e 5prime -r forward -n3 -L", [aln_infile1]), ('cassette-end-3prime', "-e 3prime -r forward -n3 -L", [aln_infile1]), ('read-direction-reverse', "-r reverse -e 5prime -n3 -L", [aln_infile1]), ('unknown-as-match', "--treat_unknown_as_match -e 5prime -r forward -n3 -L", [aln_infile1]), ('dont-count-cassette', "-l -e 5prime -r forward -n3 -L", [aln_infile1]), ('ignore-cassette', "-c -e 5prime -r forward -n3 -L", [aln_infile1]), ('separate-cassette', "-C -e 5prime -r forward -n3 -L", [aln_infile1]), ('sorted-by-count', "-o read_count -e 5prime -r forward -n3 -L", [aln_infile1]), ('with-gene-info_merged', "-e 5prime -r forward -g %s -n0"%gff_genefile, [aln_infile2]), ('with-gene-info_unmerged', "-B -e 5prime -r forward -g %s -n0"%gff_genefile, [aln_infile2]), ('multiple-infiles', "-e 5prime -r forward -n0 -L", [aln_infile1,aln_infile2]), ('dont-merge-tandems', "-n0", [aln_infile3]), ('merge-adjacent-none', "-n0 -Q -Y0", [aln_infile3]), ('merge-adjacent1-r3', "-MQ -D1 -w3 -Y0 -n0", [aln_infile3]), ('merge-adjacent1-r1', "-MQ -D1 -w1 -Y0 -n0", [aln_infile3]), ('merge-adjacent2-r3', "-MQ -D2 -w3 -Y0 -n0", [aln_infile3]), ('remove-from-other-all', "-x %s -n0"%dataset_to_remove, [aln_infile2]), ('remove-from-other-min4', "-x %s -z4 -n0"%dataset_to_remove, [aln_infile2]), ('remove-from-other-perfect', "-x %s -p -z4 -n0"%dataset_to_remove, [aln_infile2]), ('remove-not-other-all', "-X %s -n0"%dataset_to_remove, [aln_infile2]), ('remove-not-other-min4', "-X %s -Z4 -n0"%dataset_to_remove, [aln_infile2]), ('remove-not-other-perfect', "-X %s -P -Z4 -n0"%dataset_to_remove, [aln_infile2]), ('old-infile-format', "-e 5prime -r forward -n3 -L", [aln_infile0]), ] # TODO add run-test for removing data from multiple files? # MAYBE-TODO add run-test for a metadata file with 5' and 3' read counts? # MAYBE-TODO add run-tests for other mutant-merging options? But they all have pretty good unit-tests. # MAYBE-TODO add run-test for --gene_annotation_file? # MAYBE-TODO add run-test for --input_collapsed_to_unique? Or is that unit-tested already? # convert tests into (testname, arg_and_infile_string) format, adding the options that are always used test_names_and_args = [('count-aln__'+testname, test_args+' -q '+' '.join(infiles)) for testname,test_args,infiles in test_runs] parser = define_option_parser() argument_converter = lambda parser,options,args: (args[:-1], args[-1], options) return run_functional_tests(test_names_and_args, parser, main, test_folder, argument_converter=argument_converter, append_to_outfilenames='.txt')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" from testing_utilities import run_functional_tests test_folder = "_test_inputs" # tests in (testname, [test_description,] arg_and_infile_string) format test_runs = [ ("split-index", "-i CAGATC,ACCCGG -q %s/%s"%(test_folder, 'with_indexes.fq')), ("split-index", "-s -i CAGATC,ACCCGG -q %s/%s"%(test_folder, 'with_indexes_inseq.fq')), # same test name because same reference outfiles ] # argument_converter converts (parser,options,args) to the correct argument order for main argument_converter = lambda parser,options,args: (args, options) # use my custom function to run all the tests, auto-detect reference files, compare to output. return run_functional_tests(test_runs, define_option_parser(), main, test_folder, argument_converter=argument_converter, append_to_outfilenames='')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" from testing_utilities import run_functional_tests # tests in (testname, [test_description,] arg_and_infile_string) format # running the last test without -q to see the command-line output formatting test_runs = [ ('strip__basic', 'basic cassette-stripping', '-C expected-cassette-end_CIB1-3p -b "-f" -q %s'%Testing.infile1), ('strip__mism', 'cassette-stripping +mism', '-C expected-cassette-end_CIB1-3p -b "-f" -q %s'%Testing.infile2), ('strip__indel', 'cassette-stripping +indel', '-C expected-cassette-end_CIB1-3p -b "-f" -e 100 %s'%Testing.infile3), ] # argument_converter converts (parser,options,args) to the correct argument order for main argument_converter = lambda parser,options,args: (args, options) # use my custom function to run all the tests, auto-detect reference files, compare to output. return run_functional_tests(test_runs, define_option_parser(), main, Testing.test_folder, argument_converter=argument_converter)
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" test_folder = "test_data" # TODO replace those with pickled infiles? Since doing it this way uses the deprecated read_data_from_file method! Although that'll be harder to maintain... Hmmm. dataset1 = "test_data/INPUT_mutants1_no-genes.txt" dataset2 = "test_data/INPUT_mutants2_with-genes.txt" tests = [("join-datasets__basic", "-o position %s %s -q"%(dataset1, dataset2)), ("join-datasets__with-names", "-D dataset1,dataset2 -o position %s %s -q"%(dataset1, dataset2)), ("join-datasets__other-order", "-D dataset2,dataset1 -o position %s %s -q"%(dataset2, dataset1)), ] # MAYBE-TODO add run test for -A/-a option? # MAYBE-TODO add run-tests for -X, -z, -Z? parser = define_option_parser() argument_converter = lambda parser,options,args: (args[:-1], args[-1], options) return run_functional_tests(tests, parser, main, test_folder, argument_converter=argument_converter, append_to_outfilenames='.txt')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" from testing_utilities import run_functional_tests test_folder = "test_data" infile1 = "%s/INPUT_fasta_for_aln.fa"%test_folder # tests in (testname, [test_description,] arg_and_infile_string) format test_runs = [ ('aln__basic-1-error', '-e 1 -m 3 -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q'%infile1), ('aln__collapsed-input', '-e 1 -m 3 -c -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q'%infile1), ('aln__show-multiple-0-fasta', '-e 1 -m 0 -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q'%infile1), ('aln__dont-split', '-e 1 -m 3 -s -G Chlre4nm_chl-mit -C cassette-pMJ013b %s -q'%infile1), ] # MAYBE-TODO add run-tests for more options/combinations? # argument_converter converts (parser,options,args) to the correct argument order for main argument_converter = lambda parser,options,args: (args, options) # use my custom function to run all the tests, auto-detect reference files, compare to output. return run_functional_tests(test_runs, define_option_parser(), main, test_folder, argument_converter=argument_converter, outfile_option='-o')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" test_folder = "test_data" RISCC_infiles_1 = ('test_data/INPUT_RISCC1-alignment-cassette-side.sam', 'test_data/INPUT_RISCC1-alignment-genome-side.sam', 'test_data/INPUT_RISCC1-IBs.fq', 'test_data/INPUT_RISCC1-IB-clusters.py') #aln_infile0 = "test_data/INPUT_alignment0_old-format.sam" #aln_infile1 = "test_data/INPUT_alignment1_genomic-unique.sam" #aln_infile2 = "test_data/INPUT_alignment2_for-genes.sam" #gff_genefile = "test_data/INPUT_gene-data-1_all-cases.gff3" #dataset_to_remove = "test_data/INPUT_mutants_to_remove.txt" test_runs = [ ('basic-3prime-outward_clust', "-e 3prime -d outward -c %s -g %s -b %s -B %s"%RISCC_infiles_1, []), ('basic-3prime-outward_no-clust', "-e 3prime -d outward -c %s -g %s -b %s"%RISCC_infiles_1[:-1], []), #('cassette-end-5prime', "-e 5prime -r forward -n3 -L", [aln_infile1]), #('cassette-end-3prime', "-e 3prime -r forward -n3 -L", [aln_infile1]), #('read-direction-reverse', "-r reverse -e 5prime -n3 -L", [aln_infile1]), #('sorted-by-count', "-o read_count -e 5prime -r forward -n3 -L", [aln_infile1]), #('with-gene-info_merged', "-e 5prime -r forward -g %s -n0"%gff_genefile, [aln_infile2]), #('remove-from-other-all', "-x %s -n0"%dataset_to_remove, [aln_infile2]), #('remove-from-other-min4', "-x %s -z4 -n0"%dataset_to_remove, [aln_infile2]), #('remove-from-other-perfect', "-x %s -p -z4 -n0"%dataset_to_remove, [aln_infile2]), #('remove-not-other-all', "-X %s -n0"%dataset_to_remove, [aln_infile2]), #('remove-not-other-min4', "-X %s -Z4 -n0"%dataset_to_remove, [aln_infile2]), #('remove-not-other-perfect', "-X %s -P -Z4 -n0"%dataset_to_remove, [aln_infile2]), ] # TODO remove the mutation-detection lines from aln_infile1 and from all the outfiles, since that's been simplified? # TODO add run-test for removing data from multiple files? # MAYBE-TODO add run-test for a metadata file with 5' and 3' read counts? # MAYBE-TODO add run-tests for other mutant-merging options? But they all have pretty good unit-tests. # MAYBE-TODO add run-test for --gene_annotation_file? # MAYBE-TODO add run-test for --input_collapsed_to_unique? Or is that unit-tested already? # convert tests into (testname, arg_and_infile_string) format, adding the options that are always used test_names_and_args = [('count-aln__'+testname, test_args+' -q '+' '.join(infiles)) for testname,test_args,infiles in test_runs] parser = define_option_parser() argument_converter = lambda parser,options,args: (args[0], options) return run_functional_tests(test_names_and_args, parser, main, test_folder, argument_converter=argument_converter, append_to_outfilenames='.txt')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" from testing_utilities import run_functional_tests test_folder = 'test_data' infile1 = test_folder + '/INPUT_raw-fastq_complex-5prime.fq' infile2 = test_folder + '/INPUT_raw-fastq_simple-both-ends.fq' # tests in (testname, test_description, arg_string, infiles) format test_runs = [ ('full-not-unique', "testing all 'bad' cases, 5' end only, without collapsing to unique", '-3 ""', [infile1]), ('full-unique', "testing all 'bad' cases, 5' end only, WITH collapsing to unique for all outfiles", '-3 "" -C', [infile1]), ('end-5prime', "simpler test, 5' end only (collapsing to unique)", '-3 "" -C', [infile2]), ('end-3prime', "simpler test, 3' end only (collapsing to unique)", '-5 "" -C', [infile2]), ('ends-both', "simpler test, 5' and 3' ends (collapsing to unique)", '-C', [infile2]), # this test uses the standard 5' and 3' cassette seqs as two alternative 5' ones, so the 5' output is like ends-both 5'+3' ('ends-two-5prime', "simpler test, two 5' adapters (collapsing to unique)", '-5 %s,%s -3 "" -C' % (CASSETTE_DEFAULT_5prime, CASSETTE_DEFAULT_3prime), [infile2]), ] # MAYBE-TODO currently some of the tests are weird because fastx_collapser changes the order of the sequences for no good reason (see <IGNORE> lines in some of the files) # convert tests into (testname, arg_and_infile_string) format, adding the options that are always used test_runs = [('pre__' + testname, descr, test_args + ' -Q ' + ' '.join(infiles)) for testname, descr, test_args, infiles in test_runs] # argument_converter converts (parser,options,args) to the correct argument order for main argument_converter = lambda parser, options, args: (args, options) # use my custom function to run all the tests, auto-detect reference files, compare to output. return run_functional_tests(test_runs, define_option_parser(), main, test_folder, argument_converter=argument_converter, outfile_option='-o', append_to_outfilenames='')
def do_test_run(): """ Test run: run script on test infile, compare output to reference file.""" test_folder = "test_data_v0" aln_infile0 = "%s/INPUT_alignment0_old-format.sam" % test_folder aln_infile1 = "%s/INPUT_alignment1_genomic-unique.sam" % test_folder aln_infile2 = "%s/INPUT_alignment2_for-genes.sam" % test_folder aln_infile3 = "%s/INPUT_alignment3_for-merging.sam" % test_folder gff_genefile = "%s/INPUT_gene-data-1_all-cases.gff3" % test_folder dataset_to_remove = "%s/INPUT_mutants_to_remove.txt" % test_folder test_runs = [ ('cassette-end-5prime', "-e 5prime -r forward -n3 -L", [aln_infile1]), ('cassette-end-3prime', "-e 3prime -r forward -n3 -L", [aln_infile1]), ('read-direction-reverse', "-r reverse -e 5prime -n3 -L", [aln_infile1]), ('unknown-as-match', "--treat_unknown_as_match -e 5prime -r forward -n3 -L", [aln_infile1 ]), ('dont-count-cassette', "-l -e 5prime -r forward -n3 -L", [aln_infile1]), ('ignore-cassette', "-c -e 5prime -r forward -n3 -L", [aln_infile1]), ('separate-cassette', "-C -e 5prime -r forward -n3 -L", [aln_infile1]), ('sorted-by-count', "-o read_count -e 5prime -r forward -n3 -L", [aln_infile1]), ('with-gene-info_merged', "-e 5prime -r forward -g %s -n0" % gff_genefile, [aln_infile2]), ('with-gene-info_unmerged', "-B -e 5prime -r forward -g %s -n0" % gff_genefile, [aln_infile2]), ('multiple-infiles', "-e 5prime -r forward -n0 -L", [aln_infile1, aln_infile2]), ('dont-merge-tandems', "-n0", [aln_infile3]), ('merge-adjacent-none', "-n0 -Q -Y0", [aln_infile3]), ('merge-adjacent1-r3', "-MQ -D1 -w3 -Y0 -n0", [aln_infile3]), ('merge-adjacent1-r1', "-MQ -D1 -w1 -Y0 -n0", [aln_infile3]), ('merge-adjacent2-r3', "-MQ -D2 -w3 -Y0 -n0", [aln_infile3]), ('remove-from-other-all', "-x %s -n0" % dataset_to_remove, [aln_infile2]), ('remove-from-other-min4', "-x %s -z4 -n0" % dataset_to_remove, [aln_infile2]), ('remove-from-other-perfect', "-x %s -p -z4 -n0" % dataset_to_remove, [aln_infile2]), ('remove-not-other-all', "-X %s -n0" % dataset_to_remove, [aln_infile2]), ('remove-not-other-min4', "-X %s -Z4 -n0" % dataset_to_remove, [aln_infile2]), ('remove-not-other-perfect', "-X %s -P -Z4 -n0" % dataset_to_remove, [aln_infile2]), ('old-infile-format', "-e 5prime -r forward -n3 -L", [aln_infile0]), ] # TODO add run-test for removing data from multiple files? # MAYBE-TODO add run-test for a metadata file with 5' and 3' read counts? # MAYBE-TODO add run-tests for other mutant-merging options? But they all have pretty good unit-tests. # MAYBE-TODO add run-test for --gene_annotation_file? # MAYBE-TODO add run-test for --input_collapsed_to_unique? Or is that unit-tested already? # convert tests into (testname, arg_and_infile_string) format, adding the options that are always used test_names_and_args = [('count-aln__' + testname, test_args + ' -q ' + ' '.join(infiles)) for testname, test_args, infiles in test_runs] parser = define_option_parser() argument_converter = lambda parser, options, args: (args[:-1], args[-1], options) return run_functional_tests(test_names_and_args, parser, main, test_folder, argument_converter=argument_converter, append_to_outfilenames='.txt')