def main(source_base, binary_base): """Main entry point of the script.""" print 'Executing test for fiona' print '========================' print ph = app_tests.TestPathHelper( source_base, binary_base, 'apps/fiona/tests') # tests dir # ============================================================ # Auto-detect the binary path. # ============================================================ path_to_fiona = app_tests.autolocateBinary( binary_base, 'apps/fiona', 'fiona') path_to_fiona_illumina = app_tests.autolocateBinary( binary_base, 'apps/fiona', 'fiona_illumina') path_to_compute_gain = app_tests.autolocateBinary( binary_base, 'apps/fiona', 'compute_gain') # ============================================================ # Built TestConf list. # ============================================================ # Build list with TestConf objects, analoguely to how the output # was generated in generate_outputs.sh. conf_list = [] # We prepare a list of transforms to apply to the output files. This is # used to strip the input/output paths from the programs' output to # make it more canonical and host independent. ph.outFile('-') # To ensure that the out path is set. transforms = [ app_tests.ReplaceTransform( os.path.join(ph.source_base_path, 'apps/fiona/tests') + os.sep, '', right=True), app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True), app_tests.NormalizeScientificExponentsTransform(), ] # ============================================================ # Run on uniformly random DNA. # ============================================================ # Note that instead of comparing the results with expected results, we # use a checker that computes the gain and compares it with a threshold. # Illumina Mode for i in [1, 2]: min_gain = {1: 40.0, 2: 50.0} conf = app_tests.TestConf( program=path_to_fiona_illumina, args=['-nt', '1', '-i', str(i), '-g', '10000', ph.inFile('reads.illumina.fq'), ph.outFile('reads.illumina.corrected.i%d.fa' % i)], redir_stdout=ph.outFile('reads.illumina.fq.i%d.stdout' % i), redir_stderr=ph.outFile('reads.illumina.fq.i%d.stderr' % i), check_callback=ResultChecker( path_to_compute_gain, ph.inFile('genome.10k.fa'), ph.inFile('reads.illumina.sam'), ph.outFile('reads.illumina.corrected.i%d.fa' % i), min_gain.get(i, 100.0)), to_diff=[(ph.inFile('reads.illumina.fq.i%d.stdout' % i), ph.outFile('reads.illumina.fq.i%d.stdout' % i), transforms), (ph.inFile('reads.illumina.fq.i%d.stderr' % i), ph.outFile('reads.illumina.fq.i%d.stderr' % i), transforms), ]) conf_list.append(conf) # Indel Mode for i in [1, 2]: min_gain = {1: 70.0, 2: 85.0} conf = app_tests.TestConf( program=path_to_fiona, args=['-nt', '1', '-i', str(i), '-g', '10000', ph.inFile('reads.454.fq'), ph.outFile('reads.454.corrected.i%d.fa' % i)], redir_stdout=ph.outFile('reads.454.fq.i%d.stdout' % i), redir_stderr=ph.outFile('reads.454.fq.i%d.stderr' % i), check_callback=ResultChecker( path_to_compute_gain, ph.inFile('genome.10k.fa'), ph.inFile('reads.454.sam'), ph.outFile('reads.454.corrected.i%d.fa' % i), min_gain.get(i, 100.0)), to_diff=[(ph.inFile('reads.454.fq.i%d.stdout' % i), ph.outFile('reads.454.fq.i%d.stdout' % i), transforms), (ph.inFile('reads.454.fq.i%d.stderr' % i), ph.outFile('reads.454.fq.i%d.stderr' % i), transforms), ]) conf_list.append(conf) # Execute the tests. failures = 0 for conf in conf_list: res = app_tests.runTest(conf) # Output to the user. print ' '.join(conf.commandLineArgs()) if res: print 'OK' else: failures += 1 print 'FAILED' # Cleanup. ph.deleteTempDir() print '==============================' print ' total tests: %d' % len(conf_list) print ' failed tests: %d' % failures print 'successful tests: %d' % (len(conf_list) - failures) print '==============================' # Compute and return return code. return failures != 0
def main(source_base, binary_base): """Main entry point of the script.""" print 'Executing test for mason_variator' print '======================' print ph = app_tests.TestPathHelper(source_base, binary_base, 'extras/apps/mason2/tests') # tests dir # ============================================================ # Auto-detect the binary path. # ============================================================ path_to_genome = app_tests.autolocateBinary(binary_base, 'bin', 'mason_genome') path_to_methylation = app_tests.autolocateBinary(binary_base, 'bin', 'mason_methylation') path_to_variator = app_tests.autolocateBinary(binary_base, 'bin', 'mason_variator') path_to_materializer = app_tests.autolocateBinary(binary_base, 'bin', 'mason_materializer') path_to_simulator = app_tests.autolocateBinary(binary_base, 'bin', 'mason_simulator') # ============================================================ # Built TestConf list. # ============================================================ # Build list with TestConf objects, analoguely to how the output # was generated in generate_outputs.sh. conf_list = [] # We prepare a list of transforms to apply to the output files. This is # used to strip the input/output paths from the programs' output to # make it more canonical and host independent. ph.outFile('-') # To ensure that the out path is set. transforms = [ app_tests.ReplaceTransform( os.path.join(ph.source_base_path, 'extras/apps/mason2/tests') + os.sep, '', right=True), app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True), app_tests.NormalizeScientificExponentsTransform(), ] # ============================================================ # Test mason_genome # ============================================================ conf = app_tests.TestConf(program=path_to_genome, args=[ '-l', '1000', '-o', ph.outFile('genome.test1.fasta'), ], redir_stdout=ph.outFile('genome.test1.stdout'), redir_stderr=ph.outFile('genome.test1.stderr'), to_diff=[ (ph.inFile('genome.test1.fasta'), ph.outFile('genome.test1.fasta')), (ph.inFile('genome.test1.stdout'), ph.outFile('genome.test1.stdout'), transforms), (ph.inFile('genome.test1.stderr'), ph.outFile('genome.test1.stderr'), transforms), ]) conf_list.append(conf) conf = app_tests.TestConf(program=path_to_genome, args=[ '-s', '1', '-l', '1000', '-l', '100', '-o', ph.outFile('genome.test2.fasta'), ], redir_stdout=ph.outFile('genome.test2.stdout'), redir_stderr=ph.outFile('genome.test2.stderr'), to_diff=[ (ph.inFile('genome.test2.fasta'), ph.outFile('genome.test2.fasta')), (ph.inFile('genome.test2.stdout'), ph.outFile('genome.test2.stdout'), transforms), (ph.inFile('genome.test2.stderr'), ph.outFile('genome.test2.stderr'), transforms), ]) conf_list.append(conf) # ============================================================ # Test mason_methylation # ============================================================ conf = app_tests.TestConf( program=path_to_methylation, args=[ '--seed', '33', '-i', ph.inFile('random.fasta'), '-o', ph.outFile('random_meth1.fasta'), ], redir_stdout=ph.outFile('methylation.test1.stdout'), redir_stderr=ph.outFile('methylation.test1.stderr'), to_diff=[ (ph.inFile('methylation.test1.fasta'), ph.outFile('methylation.test1.fasta')), (ph.inFile('methylation.test1.stdout'), ph.outFile('methylation.test1.stdout'), transforms), (ph.inFile('methylation.test1.stderr'), ph.outFile('methylation.test1.stderr'), transforms), ]) # ============================================================ # Test mason_variator # ============================================================ # Generation methylation in variator. conf = app_tests.TestConf( program=path_to_variator, args=[ '-ir', ph.inFile('random.fasta'), '-n', '2', '-ov', ph.outFile('random_var1.vcf'), '-of', ph.outFile('random_var1.fasta'), '--snp-rate', '0.001', '--small-indel-rate', '0.001', '--sv-indel-rate', '0.001', '--sv-inversion-rate', '0.001', '--sv-translocation-rate', '0.001', '--sv-duplication-rate', '0.001', '--min-sv-size', '50', '--max-sv-size', '100', '--methylation-levels', '--meth-fasta-out', ph.outFile('random_var1_meth.fasta'), '--out-breakpoints', ph.outFile('random_var1_bp.txt'), ], redir_stdout=ph.outFile('random_var1.vcf.stdout'), redir_stderr=ph.outFile('random_var1.vcf.stderr'), to_diff=[ (ph.inFile('random_var1.vcf'), ph.outFile('random_var1.vcf'), transforms), (ph.inFile('random_var1.fasta'), ph.outFile('random_var1.fasta')), (ph.inFile('random_var1_bp.txt'), ph.outFile('random_var1_bp.txt')), (ph.inFile('random_var1_meth.fasta'), ph.outFile('random_var1_meth.fasta')), (ph.inFile('random_var1.vcf.stderr'), ph.outFile('random_var1.vcf.stderr'), transforms), (ph.inFile('random_var1.vcf.stdout'), ph.outFile('random_var1.vcf.stdout'), transforms), ]) conf_list.append(conf) # Generation methylation in variator. conf = app_tests.TestConf( program=path_to_variator, args=[ '-ir', ph.inFile('random.fasta'), '-n', '2', '-ov', ph.outFile('random_var2.vcf'), '-of', ph.outFile('random_var2.fasta'), '--snp-rate', '0.001', '--small-indel-rate', '0.001', '--sv-indel-rate', '0.001', '--sv-inversion-rate', '0.001', '--sv-translocation-rate', '0.001', '--sv-duplication-rate', '0.001', '--min-sv-size', '50', '--max-sv-size', '100', '--methylation-levels', '--meth-fasta-in', ph.inFile('random_meth1.fasta'), '--meth-fasta-out', ph.outFile('random_var2_meth.fasta'), '--out-breakpoints', ph.outFile('random_var2_bp.txt'), ], redir_stdout=ph.outFile('random_var2.vcf.stdout'), redir_stderr=ph.outFile('random_var2.vcf.stderr'), to_diff=[ (ph.inFile('random_var2.vcf'), ph.outFile('random_var2.vcf'), transforms), (ph.inFile('random_var2.fasta'), ph.outFile('random_var2.fasta')), (ph.inFile('random_var2_bp.txt'), ph.outFile('random_var2_bp.txt')), (ph.inFile('random_var2_meth.fasta'), ph.outFile('random_var2_meth.fasta')), (ph.inFile('random_var2.vcf.stderr'), ph.outFile('random_var2.vcf.stderr'), transforms), (ph.inFile('random_var2.vcf.stdout'), ph.outFile('random_var2.vcf.stdout'), transforms), ]) conf_list.append(conf) # Variation without methylation levels. conf = app_tests.TestConf( program=path_to_variator, args=[ '-ir', ph.inFile('random.fasta'), '-n', '2', '-ov', ph.outFile('random_var3.vcf'), '-of', ph.outFile('random_var3.fasta'), '--snp-rate', '0.001', '--small-indel-rate', '0.001', '--sv-indel-rate', '0.001', '--sv-inversion-rate', '0.001', '--sv-translocation-rate', '0.001', '--sv-duplication-rate', '0.001', '--min-sv-size', '50', '--max-sv-size', '100', '--out-breakpoints', ph.outFile('random_var3_bp.txt'), ], redir_stdout=ph.outFile('random_var3.vcf.stdout'), redir_stderr=ph.outFile('random_var3.vcf.stderr'), to_diff=[ (ph.inFile('random_var3.vcf'), ph.outFile('random_var3.vcf'), transforms), (ph.inFile('random_var3.fasta'), ph.outFile('random_var3.fasta')), (ph.inFile('random_var3_bp.txt'), ph.outFile('random_var3_bp.txt')), (ph.inFile('random_var3.vcf.stderr'), ph.outFile('random_var3.vcf.stderr'), transforms), (ph.inFile('random_var3.vcf.stdout'), ph.outFile('random_var3.vcf.stdout'), transforms), ]) conf_list.append(conf) # Previously crashing test conf = app_tests.TestConf( program=path_to_variator, args=[ '-ir', ph.inFile('adeno_virus.fa'), '-ov', ph.outFile('random_var9.vcf'), '-of', ph.outFile('random_var9.fasta'), '--sv-indel-rate', '0.01', '--sv-duplication-rate', '0.01', '--sv-inversion-rate', '0.01', '--min-sv-size', '20', '--max-sv-size', '300', ], redir_stdout=ph.outFile('random_var9.vcf.stdout'), redir_stderr=ph.outFile('random_var9.vcf.stderr'), to_diff=[ (ph.inFile('random_var9.vcf'), ph.outFile('random_var9.vcf'), transforms), (ph.inFile('random_var9.vcf.stderr'), ph.outFile('random_var9.vcf.stderr'), transforms), (ph.inFile('random_var9.vcf.stdout'), ph.outFile('random_var9.vcf.stdout'), transforms), ]) conf_list.append(conf) # ============================================================ # Test mason_materializer # ============================================================ # Without methylation levels. conf = app_tests.TestConf( program=path_to_materializer, args=[ '-ir', ph.inFile('random.fasta'), '-iv', ph.inFile('random_var1.vcf'), '-o', ph.outFile('materializer.random_var1.fasta'), ], redir_stdout=ph.outFile('materializer.random_var1.stdout'), redir_stderr=ph.outFile('materializer.random_var1.stderr'), to_diff=[ (ph.inFile('random_var1.fasta'), ph.outFile('materializer.random_var1.fasta')), (ph.inFile('materializer.random_var1.stdout'), ph.outFile('materializer.random_var1.stdout'), transforms), (ph.inFile('materializer.random_var1.stderr'), ph.outFile('materializer.random_var1.stderr'), transforms), ]) conf_list.append(conf) # With methylation levels. conf = app_tests.TestConf( program=path_to_materializer, args=[ '-ir', ph.inFile('random.fasta'), '-iv', ph.inFile('random_var2.vcf'), '-o', ph.outFile('materializer.random_var2.fasta'), '--meth-fasta-in', ph.inFile('random_meth1.fasta'), '--meth-fasta-out', ph.outFile('materializer.random_meth2.fasta'), ], redir_stdout=ph.outFile('materializer.random_var2.stdout'), redir_stderr=ph.outFile('materializer.random_var2.stderr'), to_diff=[ (ph.inFile('random_var1.fasta'), ph.outFile('materializer.random_var1.fasta')), (ph.inFile('random_var2_meth.fasta'), ph.outFile('materializer.random_meth2.fasta'), transforms), (ph.inFile('materializer.random_var2.stdout'), ph.outFile('materializer.random_var2.stdout'), transforms), (ph.inFile('materializer.random_var2.stderr'), ph.outFile('materializer.random_var2.stderr'), transforms), ]) conf_list.append(conf) # ============================================================ # Test mason_simulator # ============================================================ # Illumina Model conf = app_tests.TestConf(program=path_to_simulator, args=[ '-n', '1000', '-ir', ph.inFile('random.fasta'), '-o', ph.outFile('simulator.left1.fq'), '-or', ph.outFile('simulator.right1.fq'), '-oa', ph.outFile('simulator.out1.sam'), ], redir_stdout=ph.outFile('simulator.out1.stdout'), redir_stderr=ph.outFile('simulator.out1.stderr'), to_diff=[ (ph.inFile('simulator.left1.fq'), ph.outFile('simulator.left1.fq')), (ph.inFile('simulator.right1.fq'), ph.outFile('simulator.right1.fq')), (ph.inFile('simulator.out1.sam'), ph.outFile('simulator.out1.sam')), (ph.inFile('simulator.out1.stdout'), ph.outFile('simulator.out1.stdout'), transforms), (ph.inFile('simulator.out1.stderr'), ph.outFile('simulator.out1.stderr'), transforms), ]) conf_list.append(conf) conf = app_tests.TestConf(program=path_to_simulator, args=[ '-n', '1000', '-ir', ph.inFile('random.fasta'), '-iv', ph.inFile('random_var1.vcf'), '-o', ph.outFile('simulator.left2.fq'), '-or', ph.outFile('simulator.right2.fq'), '-oa', ph.outFile('simulator.out2.sam'), ], redir_stdout=ph.outFile('simulator.out2.stdout'), redir_stderr=ph.outFile('simulator.out2.stderr'), to_diff=[ (ph.inFile('simulator.left2.fq'), ph.outFile('simulator.left2.fq')), (ph.inFile('simulator.right2.fq'), ph.outFile('simulator.right2.fq')), (ph.inFile('simulator.out2.sam'), ph.outFile('simulator.out2.sam')), (ph.inFile('simulator.out2.stdout'), ph.outFile('simulator.out2.stdout'), transforms), (ph.inFile('simulator.out2.stderr'), ph.outFile('simulator.out2.stderr'), transforms), ]) conf_list.append(conf) conf = app_tests.TestConf(program=path_to_simulator, args=[ '-n', '1000', '-ir', ph.inFile('random.fasta'), '-o', ph.outFile('simulator.left3.fa'), '-or', ph.outFile('simulator.right3.fa'), ], redir_stdout=ph.outFile('simulator.out3.stdout'), redir_stderr=ph.outFile('simulator.out3.stderr'), to_diff=[ (ph.inFile('simulator.left3.fa'), ph.outFile('simulator.left3.fa')), (ph.inFile('simulator.right3.fa'), ph.outFile('simulator.right3.fa')), (ph.inFile('simulator.out3.stdout'), ph.outFile('simulator.out3.stdout'), transforms), (ph.inFile('simulator.out3.stderr'), ph.outFile('simulator.out3.stderr'), transforms), ]) conf_list.append(conf) conf = app_tests.TestConf(program=path_to_simulator, args=[ '-n', '1000', '-ir', ph.inFile('random.fasta'), '-iv', ph.inFile('random_var1.vcf'), '-o', ph.outFile('simulator.left7.fa'), '-oa', ph.outFile('simulator.out7.sam'), ], redir_stdout=ph.outFile('simulator.out7.stdout'), redir_stderr=ph.outFile('simulator.out7.stderr'), to_diff=[ (ph.inFile('simulator.left7.fa'), ph.outFile('simulator.left7.fa')), (ph.inFile('simulator.out7.sam'), ph.outFile('simulator.out7.sam')), (ph.inFile('simulator.out7.stdout'), ph.outFile('simulator.out7.stdout'), transforms), (ph.inFile('simulator.out7.stderr'), ph.outFile('simulator.out7.stderr'), transforms), ]) conf_list.append(conf) conf = app_tests.TestConf(program=path_to_simulator, args=[ '-n', '1000', '-ir', ph.inFile('random.fasta'), '-o', ph.outFile('simulator.left4.fa'), '-oa', ph.outFile('simulator.out4.sam'), ], redir_stdout=ph.outFile('simulator.out4.stdout'), redir_stderr=ph.outFile('simulator.out4.stderr'), to_diff=[ (ph.inFile('simulator.left4.fa'), ph.outFile('simulator.left4.fa')), (ph.inFile('simulator.out4.sam'), ph.outFile('simulator.out4.sam')), (ph.inFile('simulator.out4.stdout'), ph.outFile('simulator.out4.stdout'), transforms), (ph.inFile('simulator.out4.stderr'), ph.outFile('simulator.out4.stderr'), transforms), ]) conf_list.append(conf) conf = app_tests.TestConf(program=path_to_simulator, args=[ '-n', '1000', '-ir', ph.inFile('random.fasta'), '--meth-fasta-in', ph.inFile('random_meth1.fasta'), '--methylation-levels', '--enable-bs-seq', '-o', ph.outFile('simulator.left5.fq'), '-or', ph.outFile('simulator.right5.fq'), ], redir_stdout=ph.outFile('simulator.out5.stdout'), redir_stderr=ph.outFile('simulator.out5.stderr'), to_diff=[ (ph.inFile('simulator.left5.fq'), ph.outFile('simulator.left5.fq')), (ph.inFile('simulator.right5.fq'), ph.outFile('simulator.right5.fq')), (ph.inFile('simulator.out5.stdout'), ph.outFile('simulator.out5.stdout'), transforms), (ph.inFile('simulator.out5.stderr'), ph.outFile('simulator.out5.stderr'), transforms), ]) conf_list.append(conf) conf = app_tests.TestConf(program=path_to_simulator, args=[ '-n', '1000', '-ir', ph.inFile('random.fasta'), '-iv', ph.inFile('random_var1.vcf'), '--meth-fasta-in', ph.inFile('random_meth1.fasta'), '--methylation-levels', '--enable-bs-seq', '-o', ph.outFile('simulator.left6.fq'), '-or', ph.outFile('simulator.right6.fq'), ], redir_stdout=ph.outFile('simulator.out6.stdout'), redir_stderr=ph.outFile('simulator.out6.stderr'), to_diff=[ (ph.inFile('simulator.left6.fq'), ph.outFile('simulator.left6.fq')), (ph.inFile('simulator.right6.fq'), ph.outFile('simulator.right6.fq')), (ph.inFile('simulator.out6.stdout'), ph.outFile('simulator.out6.stdout'), transforms), (ph.inFile('simulator.out6.stderr'), ph.outFile('simulator.out6.stderr'), transforms), ]) conf_list.append(conf) # 454 Model conf = app_tests.TestConf(program=path_to_simulator, args=[ '--seq-technology', '454', '--fragment-mean-size', '800', '--454-read-length-mean', '200', '--454-read-length-stddev', '20', '-n', '1000', '-v', '-ir', ph.inFile('random.fasta'), '-o', ph.outFile('simulator.left8.fq'), '-oa', ph.outFile('simulator.out8.sam'), ], redir_stdout=ph.outFile('simulator.out8.stdout'), redir_stderr=ph.outFile('simulator.out8.stderr'), to_diff=[ (ph.inFile('simulator.left8.fq'), ph.outFile('simulator.left8.fq')), (ph.inFile('simulator.out8.sam'), ph.outFile('simulator.out8.sam')), (ph.inFile('simulator.out8.stdout'), ph.outFile('simulator.out8.stdout'), transforms), (ph.inFile('simulator.out8.stderr'), ph.outFile('simulator.out8.stderr'), transforms), ]) conf_list.append(conf) # Execute the tests. failures = 0 for conf in conf_list: res = app_tests.runTest(conf) # Output to the user. print ' '.join([os.path.basename(conf.program)] + conf.args), if res: print 'OK' else: failures += 1 print 'FAILED' # Cleanup. ph.deleteTempDir() print '==============================' print ' total tests: %d' % len(conf_list) print ' failed tests: %d' % failures print 'successful tests: %d' % (len(conf_list) - failures) print '==============================' # Compute and return return code. return failures != 0
def main(source_base, binary_base): """Main entry point of the script.""" print('Executing test for gustaf') print('===============================') print() ph = app_tests.TestPathHelper(source_base, binary_base, 'apps/gustaf/tests') # tests dir # ============================================================ # Auto-detect the binary path. # ============================================================ path_to_program = app_tests.autolocateBinary(binary_base, 'bin', 'gustaf') path_to_snd_program = app_tests.autolocateBinary(binary_base, 'bin', 'gustaf_mate_joining') # ============================================================ # Built TestConf list. # ============================================================ # Build list with TestConf objects, analoguely to how the output # was generated in generate_outputs.sh. conf_list = [] # We prepare a list of transforms to apply to the output files. This is # used to strip the input/output paths from the programs' output to # make it more canonical and host independent. ph.outFile('-') # To ensure that the out path is set. transforms = [ app_tests.ReplaceTransform( os.path.join(ph.source_base_path, 'apps/gustaf/tests') + os.sep, '', right=True), app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True), app_tests.NormalizeScientificExponentsTransform(), ] # ============================================================ # Gustaf_mate_joining Tests # ============================================================ # ============================================================ # Simple gustaf_mate_joining app test # ============================================================ conf = app_tests.TestConf( program=path_to_snd_program, redir_stdout=ph.outFile('gustaf_mate_joining.stdout'), redir_stderr=ph.outFile('gustaf_mate_joining.stderr'), args=[ ph.inFile('adeno_modified_reads_mates1.fa'), ph.inFile('adeno_modified_reads_mates2.fa'), '-o', ph.outFile('adeno_modified_reads_joinedMates.fa'), '-rc', ], to_diff=[ #(ph.inFile('st2_l100.vcf'), #ph.outFile('st2_l100.vcf'), #transforms), (ph.inFile('adeno_modified_reads_joinedMates.fa'), ph.outFile('adeno_modified_reads_joinedMates.fa')) ]) conf_list.append(conf) # ${JOINMATES} adeno_modified_reads_mates1.fa adeno_modified_reads_mates2.fa \ # -o adeno_modified_reads_joinedMates.fa -rc 1 \ # > gustaf_mate_joining.stdout 2> gustaf_mate_joining.stderr # ============================================================ # Read joining, reverse complement # ============================================================ conf = app_tests.TestConf( program=path_to_snd_program, redir_stdout=ph.outFile('gustaf_mate_joining.stdout'), redir_stderr=ph.outFile('gustaf_mate_joining.stderr'), args=[ ph.inFile('reads_simulated_mates1_gold.fa'), ph.inFile('reads_simulated_mates2_gold.fa'), '-o', ph.outFile('reads_simulated_joined_rc.fa'), '-rc', ], to_diff=[ #(ph.inFile('st2_l100.vcf'), #ph.outFile('st2_l100.vcf'), #transforms), (ph.inFile('reads_simulated_joined_rc.fa'), ph.outFile('reads_simulated_joined_rc.fa')) ]) conf_list.append(conf) # ${JOINMATES} reads_simulated_mates1_gold.fa reads_simulated_mates2_gold.fa \ # -o reads_simulated_joined_rc.fa -rc 1 \ # > gustaf_mate_joining.stdout 2> gustaf_mate_joining.stderr # ============================================================ # Read joining, no reverse complement # ============================================================ conf = app_tests.TestConf( program=path_to_snd_program, redir_stdout=ph.outFile('gustaf_mate_joining.stdout'), redir_stderr=ph.outFile('gustaf_mate_joining.stderr'), args=[ ph.inFile('reads_simulated_mates1_gold.fa'), ph.inFile('reads_simulated_mates2_gold.fa'), '-o', ph.outFile('reads_simulated_joined.fa'), ], to_diff=[ #(ph.inFile('st2_l100.vcf'), #ph.outFile('st2_l100.vcf'), #transforms), (ph.inFile('reads_simulated_joined.fa'), ph.outFile('reads_simulated_joined.fa')) ]) conf_list.append(conf) # ${JOINMATES} reads_simulated_mates1_gold.fa reads_simulated_mates2_gold.fa \ # -o reads_simulated_joined.fa \ # > gustaf_mate_joining.stdout 2> gustaf_mate_joining.stderr # ============================================================ # Read splitting, reverse complement # ============================================================ conf = app_tests.TestConf( program=path_to_snd_program, redir_stdout=ph.outFile('gustaf_mate_joining.stdout'), redir_stderr=ph.outFile('gustaf_mate_joining.stderr'), args=[ ph.inFile('reads_simulated_joined_gold.fa'), '-o', ph.outFile('reads_simulated_mates1_rc.fa'), '-o', ph.outFile('reads_simulated_mates2_rc.fa'), '-rc', ], to_diff=[(ph.inFile('reads_simulated_mates1_rc.fa'), ph.outFile('reads_simulated_mates1_rc.fa'), transforms), (ph.inFile('reads_simulated_mates2_rc.fa'), ph.outFile('reads_simulated_mates2_rc.fa'))]) conf_list.append(conf) # ${JOINMATES} reads_simulated_joined_gold.fa \ # -o reads_simulated_mates1_rc.fa -o reads_simulated_mates2_rc.fa -rc 1 \ # > gustaf_mate_joining.stdout 2> gustaf_mate_joining.stderr # ============================================================ # Read splitting, no reverse complement # ============================================================ conf = app_tests.TestConf( program=path_to_snd_program, redir_stdout=ph.outFile('gustaf_mate_joining.stdout'), redir_stderr=ph.outFile('gustaf_mate_joining.stderr'), args=[ ph.inFile('reads_simulated_joined_gold.fa'), '-o', ph.outFile('reads_simulated_mates1.fa'), '-o', ph.outFile('reads_simulated_mates2.fa'), ], to_diff=[(ph.inFile('reads_simulated_mates1.fa'), ph.outFile('reads_simulated_mates1.fa'), transforms), (ph.inFile('reads_simulated_mates2.fa'), ph.outFile('reads_simulated_mates2.fa'))]) conf_list.append(conf) # ${JOINMATES} reads_simulated_joined_gold.fa \ # -o reads_simulated_mates1.fa -o reads_simulated_mates2.fa \ # > gustaf_mate_joining.stdout 2> gustaf_mate_joining.stderr # ============================================================ # Gustaf Tests # ============================================================ # ============================================================ # Sanity check with default values and empty output file # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st2_l100.stdout'), redir_stderr=ph.outFile('st2_l100.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st2_l100.gff'), '-vcf', ph.outFile('st2_l100.vcf'), ], to_diff=[]) #(ph.inFile('st2_l100.vcf'), # ph.outFile('st2_l100.vcf'), # transforms), #(ph.inFile('st2_l100.gff'), # ph.outFile('st2_l100.gff'))]) conf_list.append(conf) #out="st2_l100" #${GUSTAF} adeno.fa adeno_modified_reads.fa -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -l 30 # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30.stdout'), redir_stderr=ph.outFile('st1_l30.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st1_l30.gff'), '-vcf', ph.outFile('st1_l30.vcf'), '-st', str(1), '-l', str(30), ], to_diff=[(ph.inFile('st1_l30.vcf'), ph.outFile('st1_l30.vcf'), transforms), (ph.inFile('st1_l30.gff'), ph.outFile('st1_l30.gff'))]) conf_list.append(conf) #out="st1_l30" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -l 30 -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -m stellar.gff # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30_m.stdout'), redir_stderr=ph.outFile('st1_l30_m.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-m', ph.inFile('stellar.gff'), '-gff', ph.outFile('st1_l30_m.gff'), '-vcf', ph.outFile('st1_l30_m.vcf'), '-st', str(1), ], to_diff=[(ph.inFile('st1_l30_m.vcf'), ph.outFile('st1_l30_m.vcf'), transforms), (ph.inFile('st1_l30_m.gff'), ph.outFile('st1_l30_m.gff'))]) conf_list.append(conf) #out="st1_l30_m" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -m stellar.gff -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -l 30 -ith 5 # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30_ith5.stdout'), redir_stderr=ph.outFile('st1_l30_ith5.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st1_l30_ith5.gff'), '-vcf', ph.outFile('st1_l30_ith5.vcf'), '-st', str(1), '-l', str(30), '-ith', str(5), '-bth', str(5), ], to_diff=[(ph.inFile('st1_l30_m.vcf'), ph.outFile('st1_l30_m.vcf'), transforms), (ph.inFile('st1_l30_ith5.gff'), ph.outFile('st1_l30_ith5.gff'))]) conf_list.append(conf) #out="st1_l30_ith5" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -l 30 -ith 5 -bth 5 -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -l 30 -gth 3 # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30_gth3.stdout'), redir_stderr=ph.outFile('st1_l30_gth3.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st1_l30_gth3.gff'), '-vcf', ph.outFile('st1_l30_gth3.vcf'), '-st', str(1), '-l', str(30), '-gth', str(3), ], to_diff=[(ph.inFile('st1_l30_m.vcf'), ph.outFile('st1_l30_m.vcf'), transforms), (ph.inFile('st1_l30_gth3.gff'), ph.outFile('st1_l30_gth3.gff'))]) conf_list.append(conf) #out="st1_l30_gth3" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -l 30 -gth 3 -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # paired-end # -st 1 -m stellar_joinedMates_l30.gff # ============================================================ conf = app_tests.TestConf( program=path_to_program, redir_stdout=ph.outFile('pairedEnd_st1_l30.stdout'), redir_stderr=ph.outFile('pairedEnd_st1_l30.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads_mates1.fa'), ph.inFile('adeno_modified_reads_mates2.fa'), '-m', ph.inFile('stellar_joinedMates_l30.gff'), '-gff', ph.outFile('pairedEnd_st1_l30.gff'), '-vcf', ph.outFile('pairedEnd_st1_l30.vcf'), '-st', str(1), '-mst', str(1), '-ll', str(1000), '-le', str(100), '-rc', ], to_diff=[(ph.inFile('pairedEnd_st1_l30.vcf'), ph.outFile('pairedEnd_st1_l30.vcf'), transforms), (ph.inFile('pairedEnd_st1_l30.gff'), ph.outFile('pairedEnd_st1_l30.gff'))]) conf_list.append(conf) #out="pairedEnd_st1_l30" #${GUSTAF} adeno.fa adeno_modified_reads_mates1.fa adeno_modified_reads_mates2.fa -m stellar_joinedMates_l30.gff -st 1 #-mst 1 -ll 1000 -le 30 -rc -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # Sanity check multiple references # -st 1 -l 30 # ============================================================ conf = app_tests.TestConf( program=path_to_program, redir_stdout=ph.outFile('reference2_st1_l30.stdout'), redir_stderr=ph.outFile('reference2_st1_l30.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('read_reference2.fa'), '-gff', ph.outFile('reference2_st1_l30.gff'), '-vcf', ph.outFile('reference2_st1_l30.vcf'), '-st', str(1), '-l', str(30), ], to_diff=[(ph.inFile('reference2_st1_l30.vcf'), ph.outFile('reference2_st1_l30.vcf'), transforms), (ph.inFile('reference2_st1_l30.gff'), ph.outFile('reference2_st1_l30.gff'))]) conf_list.append(conf) #out="reference2_st1_l30" #${GUSTAF} adeno.fa read_reference2.fa -st 1 \ #-l 30 -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # Execute the tests. # ============================================================ failures = 0 for conf in conf_list: res = app_tests.runTest(conf) # Output to the user. print(' '.join(['gustaf'] + conf.args), end=' ') if res: print('OK') else: failures += 1 print('FAILED') # Cleanup. ph.deleteTempDir() print('==============================') print(' total tests: %d' % len(conf_list)) print(' failed tests: %d' % failures) print('successful tests: %d' % (len(conf_list) - failures)) print('==============================') # Compute and return return code. return failures != 0
def main(source_base, binary_base): """Main entry point of the script.""" print 'Executing test for gustaf' print '===============================' print ph = app_tests.TestPathHelper(source_base, binary_base, 'extras/apps/gustaf/tests') # tests dir # ============================================================ # Auto-detect the binary path. # ============================================================ path_to_program = app_tests.autolocateBinary(binary_base, 'bin', 'gustaf') # ============================================================ # Built TestConf list. # ============================================================ # Build list with TestConf objects, analoguely to how the output # was generated in generate_outputs.sh. conf_list = [] # We prepare a list of transforms to apply to the output files. This is # used to strip the input/output paths from the programs' output to # make it more canonical and host independent. ph.outFile('-') # To ensure that the out path is set. transforms = [ app_tests.ReplaceTransform( os.path.join(ph.source_base_path, 'extras/apps/gustaf/tests') + os.sep, '', right=True), app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True), app_tests.NormalizeScientificExponentsTransform(), ] # ============================================================ # Adeno Tests # ============================================================ # ============================================================ # Sanity check with default values and empty output file # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st2_l100.stdout'), redir_stderr=ph.outFile('st2_l100.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st2_l100.gff'), '-vcf', ph.outFile('st2_l100.vcf'), ], to_diff=[(ph.inFile('st2_l100.vcf'), ph.outFile('st2_l100.vcf'), transforms), (ph.inFile('st2_l100.gff'), ph.outFile('st2_l100.gff'))]) conf_list.append(conf) #out="st2_l100" #${GUSTAF} adeno.fa adeno_modified_reads.fa -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -l 30 # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30.stdout'), redir_stderr=ph.outFile('st1_l30.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st1_l30.gff'), '-vcf', ph.outFile('st1_l30.vcf'), '-st', str(1), '-l', str(30), ], to_diff=[(ph.inFile('st1_l30.vcf'), ph.outFile('st1_l30.vcf'), transforms), (ph.inFile('st1_l30.gff'), ph.outFile('st1_l30.gff'))]) conf_list.append(conf) #out="st1_l30" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -l 30 -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -m stellar.gff # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30_m.stdout'), redir_stderr=ph.outFile('st1_l30_m.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-m', ph.inFile('stellar.gff'), '-gff', ph.outFile('st1_l30_m.gff'), '-vcf', ph.outFile('st1_l30_m.vcf'), '-st', str(1), ], to_diff=[(ph.inFile('st1_l30_m.vcf'), ph.outFile('st1_l30_m.vcf'), transforms), (ph.inFile('st1_l30_m.gff'), ph.outFile('st1_l30_m.gff'))]) conf_list.append(conf) #out="st1_l30_m" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -m stellar.gff -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -l 30 -ith 5 # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30_ith5.stdout'), redir_stderr=ph.outFile('st1_l30_ith5.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st1_l30_ith5.gff'), '-vcf', ph.outFile('st1_l30_ith5.vcf'), '-st', str(1), '-l', str(30), '-ith', str(5), ], to_diff=[(ph.inFile('st1_l30_m.vcf'), ph.outFile('st1_l30_m.vcf'), transforms), (ph.inFile('st1_l30_ith5.gff'), ph.outFile('st1_l30_ith5.gff'))]) conf_list.append(conf) #out="st1_l30_ith5" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -l 30 -ith 5 -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # -st 1 -l 30 -gth 3 # ============================================================ conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('st1_l30_gth3.stdout'), redir_stderr=ph.outFile('st1_l30_gth3.stderr'), args=[ ph.inFile('adeno.fa'), ph.inFile('adeno_modified_reads.fa'), '-gff', ph.outFile('st1_l30_gth3.gff'), '-vcf', ph.outFile('st1_l30_gth3.vcf'), '-st', str(1), '-l', str(30), '-gth', str(3), ], to_diff=[(ph.inFile('st1_l30_m.vcf'), ph.outFile('st1_l30_m.vcf'), transforms), (ph.inFile('st1_l30_gth3.gff'), ph.outFile('st1_l30_gth3.gff'))]) conf_list.append(conf) #out="st1_l30_gth3" #${GUSTAF} adeno.fa adeno_modified_reads.fa -st 1 -l 30 -gth 3 -gff ${out}.gff -vcf ${out}.vcf > ${out}.stdout 2> ${out}.stderr # ============================================================ # Execute the tests. # ============================================================ failures = 0 for conf in conf_list: res = app_tests.runTest(conf) # Output to the user. print ' '.join(['gustaf'] + conf.args), if res: print 'OK' else: failures += 1 print 'FAILED' # Cleanup. ph.deleteTempDir() print '==============================' print ' total tests: %d' % len(conf_list) print ' failed tests: %d' % failures print 'successful tests: %d' % (len(conf_list) - failures) print '==============================' # Compute and return return code. return failures != 0
def main(source_base, binary_base): """Main entry point of the script.""" print 'Executing test for stellar' print '=========================' print ph = app_tests.TestPathHelper(source_base, binary_base, 'core/apps/stellar/tests') # tests dir # ============================================================ # Auto-detect the binary path. # ============================================================ path_to_program = app_tests.autolocateBinary(binary_base, 'core/apps/stellar', 'stellar') # ============================================================ # Built TestConf list. # ============================================================ # Build list with TestConf objects, analoguely to how the output # was generated in generate_outputs.sh. conf_list = [] # We prepare a list of transforms to apply to the output files. This is # used to strip the input/output paths from the programs' output to # make it more canonical and host independent. ph.outFile('-') # To ensure that the out path is set. transforms = [ app_tests.ReplaceTransform( os.path.join(ph.source_base_path, 'core/apps/stellar/tests') + os.sep, '', right=True), app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True), app_tests.NormalizeScientificExponentsTransform(), ] # ============================================================ # Run STELLAR. # ============================================================ # Error rate 0.1: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('e-1.stdout'), args=[ '-e', '0.1', '-l', '50', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('e-1.gff'), ph.inFile('512_simSeq1_e-1.fa'), ph.inFile('512_simSeq2_e-1.fa') ], to_diff=[(ph.inFile('e-1.stdout'), ph.outFile('e-1.stdout'), transforms), (ph.inFile('e-1.gff'), ph.outFile('e-1.gff'), transforms)]) conf_list.append(conf) # Error rate 0.05: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('5e-2.stdout'), args=[ '-e', '0.05', '-l', '50', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('5e-2.gff'), ph.inFile('512_simSeq1_5e-2.fa'), ph.inFile('512_simSeq2_5e-2.fa') ], to_diff=[(ph.inFile('5e-2.stdout'), ph.outFile('5e-2.stdout'), transforms), (ph.inFile('5e-2.gff'), ph.outFile('5e-2.gff'), transforms)]) conf_list.append(conf) # Error rate 0.25: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('25e-3.stdout'), args=[ '-e', '0.025', '-l', '50', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('25e-3.gff'), ph.inFile('512_simSeq1_25e-3.fa'), ph.inFile('512_simSeq2_25e-3.fa') ], to_diff=[(ph.inFile('25e-3.stdout'), ph.outFile('25e-3.stdout'), transforms), (ph.inFile('25e-3.gff'), ph.outFile('25e-3.gff'), transforms)]) conf_list.append(conf) # Error rate 0.75: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('75e-3.stdout'), args=[ '-e', '0.075', '-l', '50', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('75e-3.gff'), ph.inFile('512_simSeq1_75e-3.fa'), ph.inFile('512_simSeq2_75e-3.fa') ], to_diff=[(ph.inFile('75e-3.stdout'), ph.outFile('75e-3.stdout'), transforms), (ph.inFile('75e-3.gff'), ph.outFile('75e-3.gff'), transforms)]) conf_list.append(conf) # Error rate 0.0001: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('e-4.stdout'), args=[ '-e', '0.0001', '-l', '50', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('e-4.gff'), ph.inFile('512_simSeq1_e-4.fa'), ph.inFile('512_simSeq2_e-4.fa') ], to_diff=[(ph.inFile('e-4.stdout'), ph.outFile('e-4.stdout'), transforms), (ph.inFile('e-4.gff'), ph.outFile('e-4.gff'), transforms)]) conf_list.append(conf) # Minimal length: 20, Error rate 0.05: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('minLen20.stdout'), args=[ '-e', '0.05', '-l', '20', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('minLen20.gff'), ph.inFile('512_simSeq1_5e-2.fa'), ph.inFile('512_simSeq2_5e-2.fa') ], to_diff=[ (ph.inFile('minLen20.stdout'), ph.outFile('minLen20.stdout'), transforms), (ph.inFile('minLen20.gff'), ph.outFile('minLen20.gff'), transforms) ]) conf_list.append(conf) # Minimal length: 150, Error rate 0.05: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('minLen150.stdout'), args=[ '-e', '0.05', '-l', '150', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('minLen150.gff'), ph.inFile('512_simSeq1_5e-2.fa'), ph.inFile('512_simSeq2_5e-2.fa') ], to_diff=[ (ph.inFile('minLen150.stdout'), ph.outFile('minLen150.stdout'), transforms), (ph.inFile('minLen150.gff'), ph.outFile('minLen150.gff'), transforms) ]) conf_list.append(conf) # Output format text: conf = app_tests.TestConf(program=path_to_program, redir_stdout=ph.outFile('5e-2txt.stdout'), args=[ '-e', '0.05', '-l', '50', '-x', '10', '-k', '7', '-n', '5000', '-s', '10000', '-f', '-v', '-t', '-o', ph.outFile('5e-2.txt'), ph.inFile('512_simSeq1_5e-2.fa'), ph.inFile('512_simSeq2_5e-2.fa') ], to_diff=[(ph.inFile('5e-2txt.stdout'), ph.outFile('5e-2txt.stdout'), transforms), (ph.inFile('5e-2.txt'), ph.outFile('5e-2.txt'), transforms)]) conf_list.append(conf) # ============================================================ # Execute the tests. # ============================================================ failures = 0 for conf in conf_list: res = app_tests.runTest(conf) # Output to the user. print ' '.join(['stellar'] + conf.args), if res: print 'OK' else: failures += 1 print 'FAILED' print '==============================' print ' total tests: %d' % len(conf_list) print ' failed tests: %d' % failures print 'successful tests: %d' % (len(conf_list) - failures) print '==============================' # Compute and return return code. return failures != 0
def main(source_base, binary_base): """Main entry point of the script.""" print 'Executing test for seqcons2' print '===========================' print ph = app_tests.TestPathHelper(source_base, binary_base, 'apps/seqcons2/tests') # tests dir # ============================================================ # Auto-detect the binary path. # ============================================================ path_to_seqcons = app_tests.autolocateBinary(binary_base, 'bin', 'seqcons2') # ============================================================ # Built TestConf list. # ============================================================ # Build list with TestConf objects, analoguely to how the output # was generated in generate_outputs.sh. conf_list = [] # We prepare a list of transforms to apply to the output files. This is # used to strip the input/output paths from the programs' output to # make it more canonical and host independent. ph.outFile('-') # To ensure that the out path is set. transforms = [ app_tests.ReplaceTransform( os.path.join(ph.source_base_path, 'apps/seqcons2/tests') + os.sep, '', right=True), app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True), app_tests.RegexpReplaceTransform(r'Overall time: .*s', r'Overall time: <removed>s', right=True, left=True), app_tests.NormalizeScientificExponentsTransform(), ] # ============================================================ # Test seqcons2 # ============================================================ # overlap_consensus and nop for FASTA input for method in ['overlap_consensus', 'nop']: conf = app_tests.TestConf( program=path_to_seqcons, args=[ '-m', method, '-i', ph.inFile('alns1.sam'), '-oc', ph.outFile('alns1.%s.fa' % method), '-oa', ph.outFile('alns1.%s.sam' % method), ], redir_stdout=ph.outFile('alns1.%s.sam.stdout' % method), redir_stderr=ph.outFile('alns1.%s.sam.stderr' % method), to_diff=[ (ph.inFile('alns1.%s.fa' % method), ph.outFile('alns1.%s.fa' % method)), (ph.inFile('alns1.%s.sam' % method), ph.outFile('alns1.%s.sam' % method)), (ph.inFile('alns1.%s.sam.stderr' % method), ph.outFile('alns1.%s.sam.stderr' % method), transforms), (ph.inFile('alns1.%s.sam.stdout' % method), ph.outFile('alns1.%s.sam.stdout' % method), transforms), ]) conf_list.append(conf) # all consensus variants (except for align) for SAM input for oa_ext in ['.sam', '.txt']: for method in [ 'overlap_consensus', 'pos_consensus', 'contig_consensus', 'realign', 'nop' ]: args = [ '-m', method, '-i', ph.inFile('alns1.sam'), '-oa', ph.outFile('alns1.%s%s' % (method, oa_ext)), ] to_diff = [(ph.inFile('alns1.%s.fa' % method), ph.outFile('alns1.%s.fa' % method)), (ph.inFile('alns1.%s%s' % (method, oa_ext)), ph.outFile('alns1.%s%s' % (method, oa_ext))), (ph.inFile('alns1.%s%s.stderr' % (method, oa_ext)), ph.outFile('alns1.%s%s.stderr' % (method, oa_ext)), transforms), (ph.inFile('alns1.%s%s.stdout' % (method, oa_ext)), ph.outFile('alns1.%s%s.stdout' % (method, oa_ext)), transforms)] if oa_ext != '.txt': args += [ '-oc', ph.outFile('alns1.%s.fa' % method), ] to_diff += [(ph.inFile('alns1.%s.fa' % method), ph.outFile('alns1.%s.fa' % method))] conf = app_tests.TestConf( program=path_to_seqcons, args=args, redir_stdout=ph.outFile('alns1.%s%s.stdout' % (method, oa_ext)), redir_stderr=ph.outFile('alns1.%s%s.stderr' % (method, oa_ext)), to_diff=to_diff) conf_list.append(conf) # align_consensus for longer sequences that are roughly globally similar for oa_ext in ['.sam', '.txt']: for method in ['align_consensus']: args = [ '-m', method, '-i', ph.inFile('seqs2.fa'), '-oa', ph.outFile('seqs2.%s%s' % (method, oa_ext)), ] to_diff = [(ph.inFile('seqs2.%s.fa' % method), ph.outFile('seqs2.%s.fa' % method)), (ph.inFile('seqs2.%s%s' % (method, oa_ext)), ph.outFile('seqs2.%s%s' % (method, oa_ext))), (ph.inFile('seqs2.%s%s.stderr' % (method, oa_ext)), ph.outFile('seqs2.%s%s.stderr' % (method, oa_ext)), transforms), (ph.inFile('seqs2.%s%s.stdout' % (method, oa_ext)), ph.outFile('seqs2.%s%s.stdout' % (method, oa_ext)), transforms)] if oa_ext != '.txt': args += [ '-oc', ph.outFile('seqs2.%s.fa' % method), ] to_diff += [(ph.inFile('seqs2.%s.fa' % method), ph.outFile('seqs2.%s.fa' % method))] conf = app_tests.TestConf( program=path_to_seqcons, args=args, redir_stdout=ph.outFile('seqs2.%s%s.stdout' % (method, oa_ext)), redir_stderr=ph.outFile('seqs2.%s%s.stderr' % (method, oa_ext)), to_diff=to_diff) conf_list.append(conf) # Execute the tests. failures = 0 for conf in conf_list: res = app_tests.runTest(conf) # Output to the user. print ' '.join([os.path.basename(conf.program)] + conf.args), if res: print 'OK' else: failures += 1 print 'FAILED' # Cleanup. ph.deleteTempDir() print '==============================' print ' total tests: %d' % len(conf_list) print ' failed tests: %d' % failures print 'successful tests: %d' % (len(conf_list) - failures) print '==============================' # Compute and return return code. return failures != 0