Ejemplo n.º 1
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for snp_store'
    print '========================='
    print
    
    ph = app_tests.TestPathHelper(
        source_base, binary_base,
        'apps/snp_store/tests')  # tests dir

    # ============================================================
    # Auto-detect the binary path.
    # ============================================================

    path_to_program = app_tests.autolocateBinary(
      binary_base, 'apps/snp_store', 'snp_store')

    # ============================================================
    # 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.RegexpReplaceTransform("#.*snp_store.exe", "#snp_store"),
        app_tests.RegexpReplaceTransform("#[^ ]+snp_store", "#snp_store"),
        app_tests.ReplaceTransform(ph.inFile(''), ''),
        app_tests.ReplaceTransform(ph.outFile(''), ''),
        ]

    # ============================================================
    # First Section.
    # ============================================================

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    # default
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('snp_store_default.stdout'),
        args=[ph.inFile('human-chr22-inf2.fa'),
              ph.inFile('human-reads2.gff'),
              '-o', ph.outFile('snps_default.vcf'),
              '-id', ph.outFile('indels_default.gff'),],
        to_diff=[(ph.inFile('snp_store_default.stdout'),
                  ph.outFile('snp_store_default.stdout')),
                 (ph.inFile('snps_default.vcf'),
                  ph.outFile('snps_default.vcf'),
                  transforms),
                 (ph.inFile('indels_default.gff'),
                  ph.outFile('indels_default.gff',))])
    conf_list.append(conf)

    # test 2
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('snp_store_realign.stdout'),
        args=[ph.inFile('human-chr22-inf2.fa'),
              ph.inFile('human-reads2.sam'),
              '-re',
              '-o', ph.outFile('snps_realign.vcf'),
              '-id', ph.outFile('indels_realign.gff')],
        to_diff=[(ph.inFile('snp_store_realign.stdout'),
                  ph.outFile('snp_store_realign.stdout')),
                 (ph.inFile('snps_realign.vcf'),
                  ph.outFile('snps_realign.vcf'),
                  transforms),
                 (ph.inFile('indels_realign.gff'),
                  ph.outFile('indels_realign.gff'))])
    conf_list.append(conf)

    # test 3
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('snp_store_realign_m1mp1oa.stdout'),
        args=[ph.inFile('human-chr22-inf2.fa'),
              ph.inFile('human-reads2.sam'),
              '-it', str(1), '-re', '-oa', '-mp', str(1), '-m', 'maq', '-hq',
              '-o', ph.outFile('snps_realign_m1mp1oa.vcf'),
              '-id', ph.outFile('indels_realign_m1mp1oa.gff')],
        to_diff=[(ph.inFile('snp_store_realign_m1mp1oa.stdout'),
                  ph.outFile('snp_store_realign_m1mp1oa.stdout')),
                 (ph.inFile('snps_realign_m1mp1oa.vcf'),
                  ph.outFile('snps_realign_m1mp1oa.vcf'),
                  transforms),
                 (ph.inFile('indels_realign_m1mp1oa.gff'),
                  ph.outFile('indels_realign_m1mp1oa.gff'))])
    conf_list.append(conf)

    # test 4
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('snp_store_realign_m0mp1oa.stdout'),
        args=[ph.inFile('human-chr22-inf2.fa'),
              ph.inFile('human-reads2.gff'),
              '-it', str(2), '-re', '-oa', '-mp', str(1), '-hq',
              '-o', ph.outFile('snps_realign_m0mp1oa.vcf'),
              '-id', ph.outFile('indels_realign_m0mp1oa.gff')],
        to_diff=[(ph.inFile('snp_store_realign_m0mp1oa.stdout'),
                  ph.outFile('snp_store_realign_m0mp1oa.stdout')),
                 (ph.inFile('snps_realign_m0mp1oa.vcf'),
                  ph.outFile('snps_realign_m0mp1oa.vcf'),
                  transforms),
                 (ph.inFile('indels_realign_m0mp1oa.gff'),
                  ph.outFile('indels_realign_m0mp1oa.gff'))])
    conf_list.append(conf)

    # test 5
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('snp_store_realign_m0mp1oa_it1ipt01.stdout'),
        args=[ph.inFile('human-chr22-inf2.fa'),
              ph.inFile('human-reads2.sam'),
              '-it', str(1), '-ipt', str(0.1), '-osc', '-re', '-oa', '-hq',
              '-o', ph.outFile('snps_realign_m0mp1oa_it1ipt01.vcf'),
              '-id', ph.outFile('indels_realign_m0mp1oa_it1ipt01.gff')],
        to_diff=[(ph.inFile('snp_store_realign_m0mp1oa_it1ipt01.stdout'),
                  ph.outFile('snp_store_realign_m0mp1oa_it1ipt01.stdout')),
                 (ph.inFile('snps_realign_m0mp1oa_it1ipt01.vcf'),
                  ph.outFile('snps_realign_m0mp1oa_it1ipt01.vcf'),
                  transforms),
                 (ph.inFile('indels_realign_m0mp1oa_it1ipt01.gff'),
                  ph.outFile('indels_realign_m0mp1oa_it1ipt01.gff'))])
    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(['snp_store'] + 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
Ejemplo n.º 2
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for roi_intersect'
    print '================================'
    print

    ph = app_tests.TestPathHelper(source_base, binary_base,
                                  'apps/ngs_roi/tests')  # tests dir

    # ============================================================
    # Auto-detect the binary path.
    # ============================================================

    path_to_project = app_tests.autolocateBinary(binary_base, 'apps/ngs_roi',
                                                 'roi_feature_projection')
    path_to_bam2roi = app_tests.autolocateBinary(binary_base, 'apps/ngs_roi',
                                                 'bam2roi')

    # ============================================================
    # 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/ngs_roi/tests') + os.sep,
            '',
            right=True),
        app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True),
    ]

    # ------------------------------------------------------------
    # Projection: Intersect with BED or GFF/GTF in BED style.
    # ------------------------------------------------------------

    for mode in ['projection', 'union', 'difference', 'intersection']:
        for fmt in ['bed', 'gff', 'gtf']:
            for ss_flag, ss_name in [('-ss', '_ss'), ('', '')]:
                conf = app_tests.TestConf(
                    program=path_to_project,
                    redir_stderr=ph.outFile('out_small_%s_m%s%s.stderr' %
                                            (fmt, mode, ss_name)),
                    redir_stdout=ph.outFile('out_small_%s_m%s%s.stdout' %
                                            (fmt, mode, ss_name)),
                    args=[
                        '-m', mode, ss_flag, '-ir',
                        ph.inFile('small.roi'), '-if',
                        ph.inFile('small.%s' % fmt), '-or',
                        ph.outFile('out_small_%s_m%s%s.roi' %
                                   (fmt, mode, ss_name))
                    ],
                    to_diff=[
                        (ph.inFile('out_small_%s_m%s%s.stderr' %
                                   (fmt, mode, ss_name)),
                         ph.outFile('out_small_%s_m%s%s.stderr' %
                                    (fmt, mode, ss_name)), transforms),
                        (ph.inFile('out_small_%s_m%s%s.stdout' %
                                   (fmt, mode, ss_name)),
                         ph.outFile('out_small_%s_m%s%s.stdout' %
                                    (fmt, mode, ss_name)), transforms),
                        (ph.inFile('out_small_%s_m%s%s.roi' %
                                   (fmt, mode, ss_name)),
                         ph.outFile('out_small_%s_m%s%s.roi' %
                                    (fmt, mode, ss_name)), transforms),
                    ])
                conf_list.append(conf)

    # TODO(holtgrew): Test with projection to transcripts.

    # ------------------------------------------------------------
    # BAM to ROI Conversion
    # ------------------------------------------------------------

    conf = app_tests.TestConf(
        program=path_to_bam2roi,
        redir_stderr=ph.outFile('out_mrna_2l_ss.roi.stderr'),
        redir_stdout=ph.outFile('out_mrna_2l_ss.roi.stdout'),
        args=[
            '--strand-specific', '-if',
            ph.inFile('micro_rna_sorted_2l.bam'), '-of',
            ph.outFile('out_mrna_2l_ss.roi')
        ],
        to_diff=[(ph.inFile('out_mrna_2l_ss.roi.stderr'),
                  ph.outFile('out_mrna_2l_ss.roi.stderr'), transforms),
                 (ph.inFile('out_mrna_2l_ss.roi.stdout'),
                  ph.outFile('out_mrna_2l_ss.roi.stdout'), transforms),
                 (ph.inFile('out_mrna_2l_ss.roi'),
                  ph.outFile('out_mrna_2l_ss.roi'))])
    conf_list.append(conf)
    conf = app_tests.TestConf(
        program=path_to_bam2roi,
        redir_stderr=ph.outFile('out_mrna_2l.roi.stderr'),
        redir_stdout=ph.outFile('out_mrna_2l.roi.stdout'),
        args=[
            '-if',
            ph.inFile('micro_rna_sorted_2l.bam'), '-of',
            ph.outFile('out_mrna_2l.roi')
        ],
        to_diff=[(ph.inFile('out_mrna_2l.roi.stderr'),
                  ph.outFile('out_mrna_2l.roi.stderr'), transforms),
                 (ph.inFile('out_mrna_2l.roi.stdout'),
                  ph.outFile('out_mrna_2l.roi.stdout'), transforms),
                 (ph.inFile('out_mrna_2l.roi'), ph.outFile('out_mrna_2l.roi'))
                 ])
    conf_list.append(conf)

    # TODO(holtgrew): Test with paired-end data with/without ignoring pairing.

    # 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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for bs_tools'
    print '========================='
    print

    ##############################################################
    ### Casbar
    ##############################################################
    ph = app_tests.TestPathHelper(source_base, binary_base,
                                  'extras/apps/bs_tools/tests')  # tests dir

    # ============================================================
    # Auto-detect the binary path.
    # ============================================================

    path_to_bisar = app_tests.autolocateBinary(binary_base,
                                               'extras/apps/bs_tools', 'bisar')
    path_to_casbar = app_tests.autolocateBinary(binary_base,
                                                'extras/apps/bs_tools',
                                                'casbar')

    # ============================================================
    # Built TestConf list.
    # ============================================================

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []
    ph.outFile('-')  # To ensure that the out path is set.
    transforms = [
        app_tests.ReplaceTransform(
            os.path.join(ph.source_base_path, 'extras/apps/bs_tools/tests') +
            os.sep,
            '',
            right=True),
        app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True),
        app_tests.RegexpReplaceTransform(r'\tVN:[^\t]*',
                                         r'\tVN:VERSION',
                                         right=True,
                                         left=True)
    ]

    # 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.

    # Transforms for SAM output format only.  Make VN field of @PG header canonical.
    #sam_transforms = [app_tests.RegexpReplaceTransform(r'\tVN:[^\t]*', r'\tVN:VERSION', right=True, left=True)]

    # ============================================================
    # se
    # ============================================================

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    # 0
    conf = app_tests.TestConf(
        program=path_to_bisar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-e3',
            str(4),
            '-e4',
            str(5),
            #-e3 4 -e4 5
            '-o',
            ph.outFile('reads_se_N6000_0.CT_GA.verified.sam'),
            ph.inFile('reads_se_N6000.CT_GA.sam'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_se_N6000.fastq')
        ],
        to_diff=[  #(ph.inFile('STDOUT_FILE'),
            #ph.outFile('STDOUT_FILE')),
            (ph.inFile('reads_se_N6000_0.CT_GA.verified.sam'),
             ph.outFile('reads_se_N6000_0.CT_GA.verified.sam'), transforms)
        ])
    conf_list.append(conf)
    # 1
    conf = app_tests.TestConf(
        program=path_to_bisar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-gas',
            str(-4.5),
            '-ges',
            str(-2.0),
            '-der',
            str(0.001),
            '-bsc',
            str(0.99),
            '-gmr',
            str(0.5),
            '-i',
            str(0.8),
            '-rn',
            str(0.001),
            '-pms',
            str(0.9),
            '-e3',
            str(4),
            '-e4',
            str(5),
            # -gas -4.5 -ges -2.0 -der 0.001 -bsc 0.99 -gmr 0.5 -i 0.8 -rn 0.001 -pms 0.9 -mq 0 -e3 4 -e4 5
            '-o',
            ph.outFile('reads_se_N6000_1.CT_GA.verified.sam'),
            ph.inFile('reads_se_N6000.CT_GA.sam'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_se_N6000.fastq')
        ],
        to_diff=[  #(ph.inFile('STDOUT_FILE'),
            #ph.outFile('STDOUT_FILE')),
            (ph.inFile('reads_se_N6000_1.CT_GA.verified.sam'),
             ph.outFile('reads_se_N6000_1.CT_GA.verified.sam'), transforms)
        ])
    conf_list.append(conf)

    # 2
    conf = app_tests.TestConf(
        program=path_to_bisar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-nse',
            '-nsi',
            '-nsd',
            '-gas',
            str(-4.5),
            '-ges',
            str(-2.0),
            '-der',
            str(0.001),
            '-bsc',
            str(0.99),
            '-gmr',
            str(0.5),
            '-i',
            str(0.8),
            '-rn',
            str(0.001),
            '-pms',
            str(0.9),
            '-e3',
            str(4),
            '-e4',
            str(5),
            # -nse -nsi -nsd -gas -4.5 -ges -2.0 -der 0.001 -bsc 0.99 -gmr 0.5 -i 0.8 -rn 0.001 -pms 0.9 -mq 0 -e3 4 -e4 5
            '-o',
            ph.outFile('reads_se_N6000_2.CT_GA.verified.sam'),
            ph.inFile('reads_se_N6000.CT_GA.sam'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_se_N6000.fastq')
        ],
        to_diff=[(ph.inFile('reads_se_N6000_2.CT_GA.verified.sam'),
                  ph.outFile('reads_se_N6000_2.CT_GA.verified.sam'),
                  transforms)])
    conf_list.append(conf)

    # 3
    conf = app_tests.TestConf(
        program=path_to_bisar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-nse',
            '-nsi',
            '-nsd',
            '-gas',
            str(-4.5),
            '-ges',
            str(-2.0),
            '-der',
            str(0.001),
            '-bsc',
            str(0.99),
            '-gmr',
            str(0.2),
            '-i',
            str(0.8),
            '-rn',
            str(0.001),
            '-pms',
            str(0.9),
            '-e3',
            str(4),
            '-e4',
            str(5),
            # -nse -nsi -nsd -gas -4.5 -ges -2.0 -der 0.001 -bsc 0.99 -gmr 0.2 -i 0.8 -rn 0.001 -pms 0.9 -mq 0 -e3 4 -e4 5
            '-o',
            ph.outFile('reads_se_N6000_3.CT_GA.verified.sam'),
            ph.inFile('reads_se_N6000.CT_GA.sam'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_se_N6000.fastq')
        ],
        to_diff=[(ph.inFile('reads_se_N6000_3.CT_GA.verified.sam'),
                  ph.outFile('reads_se_N6000_3.CT_GA.verified.sam'),
                  transforms)])
    conf_list.append(conf)

    # 4
    conf = app_tests.TestConf(
        program=path_to_bisar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-nse',
            '-nsi',
            '-nsd',
            '-gas',
            str(-4.5),
            '-ges',
            str(-2.0),
            '-der',
            str(0.001),
            '-bsc',
            str(0.99),
            '-gmr',
            str(0.8),
            '-i',
            str(0.8),
            '-rn',
            str(0.001),
            '-pms',
            str(0.9),
            '-e3',
            str(4),
            '-e4',
            str(5),
            # -nse -nsi -nsd -gas -4.5 -ges -2.0 -der 0.001 -bsc 0.99 -gmr 0.8 -i 0.8 -rn 0.001 -pms 0.9 -mq 0 -e3 4 -e4 5
            '-o',
            ph.outFile('reads_se_N6000_4.CT_GA.verified.sam'),
            ph.inFile('reads_se_N6000.CT_GA.sam'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_se_N6000.fastq')
        ],
        to_diff=[(ph.inFile('reads_se_N6000_4.CT_GA.verified.sam'),
                  ph.outFile('reads_se_N6000_4.CT_GA.verified.sam'),
                  transforms)])
    conf_list.append(conf)

    # ============================================================
    # pe
    # ============================================================
    # 0
    conf = app_tests.TestConf(
        program=path_to_bisar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-e3',
            str(4),
            '-e4',
            str(5),
            #-e3 4 -e4 5
            '-o',
            ph.outFile('reads_pe_N6000_0.CT_GA.verified.sam'),
            ph.inFile('reads_pe_N6000.CT_GA.sam'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_pe_N6000.L.fastq'),
            ph.inFile('reads_pe_N6000.R.fastq')
        ],
        to_diff=[(ph.inFile('reads_pe_N6000_0.CT_GA.verified.sam'),
                  ph.outFile('reads_pe_N6000_0.CT_GA.verified.sam'),
                  transforms)])
    conf_list.append(conf)

    ##############################################################
    ### Casbar
    ##############################################################

    # 0
    conf = app_tests.TestConf(
        program=path_to_casbar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-nec', '-mc',
            str(6), '-msc',
            str(5), '-mpc',
            str(0.5), '-hes',
            str(0.005), '-o',
            ph.outFile('snps_se_0.vcf'), '-b',
            ph.outFile('meths_se_0.bed'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_se_N6000_2.CT_GA.verified.pos_so.sam')
        ],
        to_diff=[(ph.inFile('snps_se_0.vcf'), ph.outFile('snps_se_0.vcf')),
                 (ph.inFile('meths_se_0.bed'), ph.outFile('meths_se_0.bed'))])
    conf_list.append(conf)

    # 1
    conf = app_tests.TestConf(
        program=path_to_casbar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-nec', '-mc',
            str(2), '-msc',
            str(3), '-mpc',
            str(0.5), '-hes',
            str(0.005), '-o',
            ph.outFile('snps_se_1.vcf'), '-b',
            ph.outFile('meths_se_1.bed'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_se_N6000_2.CT_GA.verified.pos_so.sam')
        ],
        to_diff=[(ph.inFile('snps_se_1.vcf'), ph.outFile('snps_se_1.vcf')),
                 (ph.inFile('meths_se_1.bed'), ph.outFile('meths_se_1.bed'))])
    conf_list.append(conf)

    # ============================================================
    # pe
    # ============================================================
    # 0
    conf = app_tests.TestConf(
        program=path_to_casbar,
        redir_stdout=ph.outFile('other.stdout'),
        args=[
            '-nec', '-mc',
            str(6), '-msc',
            str(5), '-mpc',
            str(0.5), '-hes',
            str(0.005), '-o',
            ph.outFile('snps_pe_0.vcf'), '-b',
            ph.outFile('meths_pe_0.bed'),
            ph.inFile('hg18_chr21_3000.fa'),
            ph.inFile('reads_pe_N6000_0.CT_GA.verified.pos_so.sam')
        ],
        to_diff=[(ph.inFile('snps_pe_0.vcf'), ph.outFile('snps_pe_0.vcf')),
                 (ph.inFile('meths_pe_0.bed'), ph.outFile('meths_pe_0.bed'))])
    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
Ejemplo n.º 7
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
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
0
def main(source_base, binary_base, num_threads=1):
    """Main entry point of the script."""

    print('Executing test for razers3')
    print('===========================')
    print()

    ph = app_tests.TestPathHelper(source_base, binary_base,
                                  'apps/razers3/tests')  # tests dir

    # ============================================================
    # Auto-detect the binary path.
    # ============================================================

    path_to_program = app_tests.autolocateBinary(binary_base, 'bin', 'razers3')

    # ============================================================
    # 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/razers3/tests') + os.sep,
            '',
            right=True),
        app_tests.ReplaceTransform(ph.temp_dir + os.sep, '', right=True),
    ]

    # Transforms for SAM output format only.  Make VN field of @PG header canonical.
    sam_transforms = [
        app_tests.RegexpReplaceTransform(r'\tVN:[^\t]*',
                                         r'\tVN:VERSION',
                                         right=True,
                                         left=True)
    ]

    # Transforms for RazerS output format only.  Remove pair id column.
    razers_transforms = [RemovePairIdColumn()]

    # ============================================================
    # Run Adeno Single-End Tests
    # ============================================================

    # We run the following for all read lengths we have reads for.
    for rl in [36, 100]:
        # Run with default options.
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('se-adeno-reads%d_1-tc%d.stdout' %
                                    (rl, num_threads)),
            args=[
                '-tc',
                str(num_threads),
                ph.inFile('adeno-genome.fa'),
                ph.inFile('adeno-reads%d_1.fa' % rl), '-o',
                ph.outFile('se-adeno-reads%d_1-tc%d.razers' %
                           (rl, num_threads))
            ],
            to_diff=[(ph.inFile('se-adeno-reads%d_1-tc%d.razers' %
                                (rl, num_threads)),
                      ph.outFile('se-adeno-reads%d_1-tc%d.razers' %
                                 (rl, num_threads))),
                     (ph.inFile('se-adeno-reads%d_1-tc%d.stdout' %
                                (rl, num_threads)),
                      ph.outFile('se-adeno-reads%d_1-tc%d.stdout' %
                                 (rl, num_threads)))])
        conf_list.append(conf)

        # Allow indels.
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('se-adeno-reads%d_1-ng-tc%d.stdout' %
                                    (rl, num_threads)),
            args=[
                '-tc',
                str(num_threads), '-ng',
                ph.inFile('adeno-genome.fa'),
                ph.inFile('adeno-reads%d_1.fa' % rl), '-o',
                ph.outFile('se-adeno-reads%d_1-ng-tc%d.razers' %
                           (rl, num_threads))
            ],
            to_diff=[(ph.inFile('se-adeno-reads%d_1-ng-tc%d.razers' %
                                (rl, num_threads)),
                      ph.outFile('se-adeno-reads%d_1-ng-tc%d.razers' %
                                 (rl, num_threads))),
                     (ph.inFile('se-adeno-reads%d_1-ng-tc%d.stdout' %
                                (rl, num_threads)),
                      ph.outFile('se-adeno-reads%d_1-ng-tc%d.stdout' %
                                 (rl, num_threads)))])
        conf_list.append(conf)

        # Compute forward/reverse matches only.
        for o in ['-r', '-f']:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('se-adeno-reads%d_1%s-tc%d.stdout' %
                                        (rl, o, num_threads)),
                args=[
                    '-tc',
                    str(num_threads), o,
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl), '-o',
                    ph.outFile('se-adeno-reads%d_1%s-tc%d.razers' %
                               (rl, o, num_threads))
                ],
                to_diff=[(ph.inFile('se-adeno-reads%d_1%s-tc%d.razers' %
                                    (rl, o, num_threads)),
                          ph.outFile('se-adeno-reads%d_1%s-tc%d.razers' %
                                     (rl, o, num_threads))),
                         (ph.inFile('se-adeno-reads%d_1%s-tc%d.stdout' %
                                    (rl, o, num_threads)),
                          ph.outFile('se-adeno-reads%d_1%s-tc%d.stdout' %
                                     (rl, o, num_threads)))])
            conf_list.append(conf)

        # Compute with different identity rates.
        for i in range(90, 101):
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('se-adeno-reads%d_1-i%d-tc%d.stdout' %
                                        (rl, i, num_threads)),
                args=[
                    '-tc',
                    str(num_threads), '-i',
                    str(i),
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl), '-o',
                    ph.outFile('se-adeno-reads%d_1-i%d-tc%d.razers' %
                               (rl, i, num_threads))
                ],
                to_diff=[(ph.inFile('se-adeno-reads%d_1-i%d-tc%d.razers' %
                                    (rl, i, num_threads)),
                          ph.outFile('se-adeno-reads%d_1-i%d-tc%d.razers' %
                                     (rl, i, num_threads))),
                         (ph.inFile('se-adeno-reads%d_1-i%d-tc%d.stdout' %
                                    (rl, i, num_threads)),
                          ph.outFile('se-adeno-reads%d_1-i%d-tc%d.stdout' %
                                     (rl, i, num_threads)))])
            conf_list.append(conf)

        # Compute with different output formats.
        for of, suffix in enumerate(
            ['razers', 'fa', 'eland', 'gff', 'sam', 'afg']):
            this_transforms = list(transforms)
            if suffix == 'razers':
                this_transforms += razers_transforms
            elif suffix == 'sam':
                this_transforms += sam_transforms
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('se-adeno-reads%d_1-of%d-tc%d.stdout' %
                                        (rl, of, num_threads)),
                args=[
                    '-tc',
                    str(num_threads),
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl), '-o',
                    ph.outFile('se-adeno-reads%d_1-of%d-tc%d.%s' %
                               (rl, of, num_threads, suffix))
                ],
                to_diff=[(ph.inFile('se-adeno-reads%d_1-of%d-tc%d.%s' %
                                    (rl, of, num_threads, suffix)),
                          ph.outFile('se-adeno-reads%d_1-of%d-tc%d.%s' %
                                     (rl, of, num_threads, suffix)),
                          this_transforms),
                         (ph.inFile('se-adeno-reads%d_1-of%d-tc%d.stdout' %
                                    (rl, of, num_threads)),
                          ph.outFile('se-adeno-reads%d_1-of%d-tc%d.stdout' %
                                     (rl, of, num_threads)), transforms)])
            conf_list.append(conf)

        # Compute with different sort orders.
        for so in [0, 1]:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('se-adeno-reads%d_1-so%d-tc%d.stdout' %
                                        (rl, so, num_threads)),
                args=[
                    '-tc',
                    str(num_threads), '-so',
                    str(so),
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl), '-o',
                    ph.outFile('se-adeno-reads%d_1-so%d-tc%d.razers' %
                               (rl, so, num_threads))
                ],
                to_diff=[(ph.inFile('se-adeno-reads%d_1-so%d-tc%d.razers' %
                                    (rl, so, num_threads)),
                          ph.outFile('se-adeno-reads%d_1-so%d-tc%d.razers' %
                                     (rl, so, num_threads))),
                         (ph.inFile('se-adeno-reads%d_1-so%d-tc%d.stdout' %
                                    (rl, so, num_threads)),
                          ph.outFile('se-adeno-reads%d_1-so%d-tc%d.stdout' %
                                     (rl, so, num_threads)))])
            conf_list.append(conf)

    # ============================================================
    # Run Adeno Paired-End Tests
    # ============================================================

    # We run the following for all read lengths we have reads for.
    for rl in [36, 100]:
        # Run with default options.
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('pe-adeno-reads%d_2-tc%d.stdout' %
                                    (rl, num_threads)),
            args=[
                '-tc',
                str(num_threads),
                ph.inFile('adeno-genome.fa'),
                ph.inFile('adeno-reads%d_1.fa' % rl),
                ph.inFile('adeno-reads%d_2.fa' % rl), '-o',
                ph.outFile('pe-adeno-reads%d_2-tc%d.razers' %
                           (rl, num_threads))
            ],
            to_diff=[(ph.inFile('pe-adeno-reads%d_2-tc%d.razers' %
                                (rl, num_threads)),
                      ph.outFile('pe-adeno-reads%d_2-tc%d.razers' %
                                 (rl, num_threads)), razers_transforms),
                     (ph.inFile('pe-adeno-reads%d_2-tc%d.stdout' %
                                (rl, num_threads)),
                      ph.outFile('pe-adeno-reads%d_2-tc%d.stdout' %
                                 (rl, num_threads)))])
        conf_list.append(conf)

        # Allow indels.
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('pe-adeno-reads%d_2-tc%d.stdout' %
                                    (rl, num_threads)),
            args=[
                '-tc',
                str(num_threads),
                ph.inFile('adeno-genome.fa'),
                ph.inFile('adeno-reads%d_1.fa' % rl),
                ph.inFile('adeno-reads%d_2.fa' % rl), '-o',
                ph.outFile('pe-adeno-reads%d_2-tc%d.razers' %
                           (rl, num_threads))
            ],
            to_diff=[(ph.inFile('pe-adeno-reads%d_2-tc%d.razers' %
                                (rl, num_threads)),
                      ph.outFile('pe-adeno-reads%d_2-tc%d.razers' %
                                 (rl, num_threads)), razers_transforms),
                     (ph.inFile('pe-adeno-reads%d_2-tc%d.stdout' %
                                (rl, num_threads)),
                      ph.outFile('pe-adeno-reads%d_2-tc%d.stdout' %
                                 (rl, num_threads)))])
        conf_list.append(conf)

        # Compute forward/reverse matches only.
        for o in ['-r', '-f']:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('pe-adeno-reads%d_2%s-tc%d.stdout' %
                                        (rl, o, num_threads)),
                args=[
                    '-tc',
                    str(num_threads), o,
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl),
                    ph.inFile('adeno-reads%d_2.fa' % rl), '-o',
                    ph.outFile('pe-adeno-reads%d_2%s-tc%d.razers' %
                               (rl, o, num_threads))
                ],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2%s-tc%d.razers' %
                                    (rl, o, num_threads)),
                          ph.outFile('pe-adeno-reads%d_2%s-tc%d.razers' %
                                     (rl, o, num_threads)), razers_transforms),
                         (ph.inFile('pe-adeno-reads%d_2%s-tc%d.stdout' %
                                    (rl, o, num_threads)),
                          ph.outFile('pe-adeno-reads%d_2%s-tc%d.stdout' %
                                     (rl, o, num_threads)))])
            conf_list.append(conf)

        # Compute with different identity rates.
        for i in range(90, 101):
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('pe-adeno-reads%d_2-i%d-tc%d.stdout' %
                                        (rl, i, num_threads)),
                args=[
                    '-tc',
                    str(num_threads), '-i',
                    str(i),
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl),
                    ph.inFile('adeno-reads%d_2.fa' % rl), '-o',
                    ph.outFile('pe-adeno-reads%d_2-i%d-tc%d.razers' %
                               (rl, i, num_threads))
                ],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2-i%d-tc%d.razers' %
                                    (rl, i, num_threads)),
                          ph.outFile('pe-adeno-reads%d_2-i%d-tc%d.razers' %
                                     (rl, i, num_threads)), razers_transforms),
                         (ph.inFile('pe-adeno-reads%d_2-i%d-tc%d.stdout' %
                                    (rl, i, num_threads)),
                          ph.outFile('pe-adeno-reads%d_2-i%d-tc%d.stdout' %
                                     (rl, i, num_threads)))])
            conf_list.append(conf)

        # Compute with different output formats.
        for of, suffix in enumerate(
            ['razers', 'fa', 'eland', 'gff', 'sam', 'afg']):
            this_transforms = list(transforms)
            if suffix == 'razers':
                this_transforms += razers_transforms
            elif suffix == 'sam':
                this_transforms += sam_transforms
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('pe-adeno-reads%d_2-of%d-tc%d.stdout' %
                                        (rl, of, num_threads)),
                args=[
                    '-tc',
                    str(num_threads),
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl),
                    ph.inFile('adeno-reads%d_2.fa' % rl), '-o',
                    ph.outFile('pe-adeno-reads%d_2-of%d-tc%d.%s' %
                               (rl, of, num_threads, suffix))
                ],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2-of%d-tc%d.%s' %
                                    (rl, of, num_threads, suffix)),
                          ph.outFile('pe-adeno-reads%d_2-of%d-tc%d.%s' %
                                     (rl, of, num_threads, suffix)),
                          this_transforms),
                         (ph.inFile('pe-adeno-reads%d_2-of%d-tc%d.stdout' %
                                    (rl, of, num_threads)),
                          ph.outFile('pe-adeno-reads%d_2-of%d-tc%d.stdout' %
                                     (rl, of, num_threads)), this_transforms)])
            conf_list.append(conf)

        # Compute with different sort orders.
        for so in [0, 1]:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('pe-adeno-reads%d_2-so%d-tc%d.stdout' %
                                        (rl, so, num_threads)),
                args=[
                    '-tc',
                    str(num_threads), '-so',
                    str(so),
                    ph.inFile('adeno-genome.fa'),
                    ph.inFile('adeno-reads%d_1.fa' % rl),
                    ph.inFile('adeno-reads%d_2.fa' % rl), '-o',
                    ph.outFile('pe-adeno-reads%d_2-so%d-tc%d.razers' %
                               (rl, so, num_threads))
                ],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2-so%d-tc%d.razers' %
                                    (rl, so, num_threads)),
                          ph.outFile('pe-adeno-reads%d_2-so%d-tc%d.razers' %
                                     (rl, so, num_threads)),
                          razers_transforms),
                         (ph.inFile('pe-adeno-reads%d_2-so%d-tc%d.stdout' %
                                    (rl, so, num_threads)),
                          ph.outFile('pe-adeno-reads%d_2-so%d-tc%d.stdout' %
                                     (rl, so, num_threads)))])
            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(['razers3'] + 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