Example #1
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print "Executing test for breakpoint_calculator"
    print "========================="
    print

    ph = app_tests.TestPathHelper(source_base, binary_base, "extras/apps/breakpoint_calculator/tests")  # tests dir

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

    path_to_program = app_tests.autolocateBinary(
        binary_base, "extras/apps/breakpoint_calculator", "breakpoint_calculator"
    )

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run breakpoint_calculator
    # ============================================================

    # pairwise counts, xmfa format
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile("d2_xmfa.stdout"),
        args=["-d2", ph.inFile("alignment.xmfa")],
        to_diff=[(ph.inFile("d2_xmfa.stdout"), ph.outFile("d2_xmfa.stdout"))],
    )
    conf_list.append(conf)

    # pairwise counts, maf format, detailed list of all pairs
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile("d2_maf.stdout"),
        args=["-d2", "-d", ph.inFile("alignment.maf")],
        to_diff=[(ph.inFile("d2_maf.stdout"), ph.outFile("d2_maf.stdout"))],
    )
    conf_list.append(conf)

    # threeway counts, xmfa format, format directly specified
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile("d3_xmfa.stdout"),
        args=["-d3", "-f", "xmfa", ph.inFile("alignment.xmfa")],
        to_diff=[(ph.inFile("d3_xmfa.stdout"), ph.outFile("d3_xmfa.stdout"))],
    )
    conf_list.append(conf)

    # threeway counts, maf format, detailed list of all triplets
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile("d3_maf.stdout"),
        args=["-d3", "-d", ph.inFile("alignment.maf")],
        to_diff=[(ph.inFile("d3_maf.stdout"), ph.outFile("d3_maf.stdout"))],
    )
    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(["breakpoint_calculator"] + 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
Example #2
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for razers2'
    print '==========================='
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # 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.stdout' % rl),
            args=['--low-memory',
                  ph.inFile('adeno-genome.fa'),
                  ph.inFile('adeno-reads%d_1.fa' % rl),
                  '-o', ph.outFile('se-adeno-reads%d_1.razers' % rl)],
            to_diff=[(ph.inFile('se-adeno-reads%d_1.razers' % rl),
                      ph.outFile('se-adeno-reads%d_1.razers' % rl)),
                     (ph.inFile('se-adeno-reads%d_1.stdout' % rl),
                      ph.outFile('se-adeno-reads%d_1.stdout' % rl))])
        conf_list.append(conf)

        # Allow indels.
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('se-adeno-reads%d_1-id.stdout' % rl),
            args=['--low-memory', '-id',
                  ph.inFile('adeno-genome.fa'),
                  ph.inFile('adeno-reads%d_1.fa' % rl),
                  '-o', ph.outFile('se-adeno-reads%d_1-id.razers' % rl)],
            to_diff=[(ph.inFile('se-adeno-reads%d_1-id.razers' % rl),
                      ph.outFile('se-adeno-reads%d_1-id.razers' % rl)),
                     (ph.inFile('se-adeno-reads%d_1-id.stdout' % rl),
                      ph.outFile('se-adeno-reads%d_1-id.stdout' % rl))])
        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-id%s.stdout' % (rl, o)),
                args=['--low-memory', '-id', o,
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1-id%s.razers' % (rl, o))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1-id%s.razers' % (rl, o)),
                          ph.outFile('se-adeno-reads%d_1-id%s.razers' % (rl, o))),
                         (ph.inFile('se-adeno-reads%d_1-id%s.stdout' % (rl, o)),
                          ph.outFile('se-adeno-reads%d_1-id%s.stdout' % (rl, o)))])
            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-id-i%d.stdout' % (rl, i)),
                args=['--low-memory', '-id', '-i', str(i),
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1-id-i%d.razers' % (rl, i))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1-id-i%d.razers' % (rl, i)),
                          ph.outFile('se-adeno-reads%d_1-id-i%d.razers' % (rl, i))),
                         (ph.inFile('se-adeno-reads%d_1-id-i%d.stdout' % (rl, i)),
                          ph.outFile('se-adeno-reads%d_1-id-i%d.stdout' % (rl, i)))])
            conf_list.append(conf)

        # Compute with different output formats.
        for suffix in ['razers', 'fa', 'eland', 'gff', 'sam', 'afg']:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('se-adeno-reads%d_1-id.%s.stdout' % (rl, suffix)),
                args=['--low-memory', '-id',
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1-id.%s' % (rl, suffix))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1-id.%s' % (rl, suffix)),
                          ph.outFile('se-adeno-reads%d_1-id.%s' % (rl, suffix))),
                         (ph.inFile('se-adeno-reads%d_1-id.%s.stdout' % (rl, suffix)),
                          ph.outFile('se-adeno-reads%d_1-id.%s.stdout' % (rl, suffix)))])
            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-id-so%d.stdout' % (rl, so)),
                args=['--low-memory', '-id', '-so', str(so),
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1-id-so%d.razers' % (rl, so))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1-id-so%d.razers' % (rl, so)),
                          ph.outFile('se-adeno-reads%d_1-id-so%d.razers' % (rl, so))),
                         (ph.inFile('se-adeno-reads%d_1-id-so%d.stdout' % (rl, so)),
                          ph.outFile('se-adeno-reads%d_1-id-so%d.stdout' % (rl, so)))])
            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.stdout' % rl),
            args=['--low-memory',
                  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.razers' % rl)],
            to_diff=[(ph.inFile('pe-adeno-reads%d_2.razers' % rl),
                      ph.outFile('pe-adeno-reads%d_2.razers' % rl)),
                     (ph.inFile('pe-adeno-reads%d_2.stdout' % rl),
                      ph.outFile('pe-adeno-reads%d_2.stdout' % rl))])
        conf_list.append(conf)

        # Allow indels.
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('pe-adeno-reads%d_2-id.stdout' % rl),
            args=['--low-memory', '-id',
                  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-id.razers' % rl)],
            to_diff=[(ph.inFile('pe-adeno-reads%d_2-id.razers' % rl),
                      ph.outFile('pe-adeno-reads%d_2-id.razers' % rl)),
                     (ph.inFile('pe-adeno-reads%d_2-id.stdout' % rl),
                      ph.outFile('pe-adeno-reads%d_2-id.stdout' % rl))])
        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-id%s.stdout' % (rl, o)),
                args=['--low-memory', '-id', 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-id%s.razers' % (rl, o))],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2-id%s.razers' % (rl, o)),
                          ph.outFile('pe-adeno-reads%d_2-id%s.razers' % (rl, o))),
                         (ph.inFile('pe-adeno-reads%d_2-id%s.stdout' % (rl, o)),
                          ph.outFile('pe-adeno-reads%d_2-id%s.stdout' % (rl, o)))])
            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-id-i%d.stdout' % (rl, i)),
                args=['--low-memory', '-id', '-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-id-i%d.razers' % (rl, i))],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2-id-i%d.razers' % (rl, i)),
                          ph.outFile('pe-adeno-reads%d_2-id-i%d.razers' % (rl, i))),
                         (ph.inFile('pe-adeno-reads%d_2-id-i%d.stdout' % (rl, i)),
                          ph.outFile('pe-adeno-reads%d_2-id-i%d.stdout' % (rl, i)))])
            conf_list.append(conf)

        # Compute with different output formats.
        for suffix in ['razers', 'fa', 'eland', 'gff', 'sam', 'afg']:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('pe-adeno-reads%d_2-id.%s.stdout' % (rl, suffix)),
                args=['--low-memory', '-id',
                      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-id.%s' % (rl, suffix))],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2-id.%s' % (rl, suffix)),
                          ph.outFile('pe-adeno-reads%d_2-id.%s' % (rl, suffix))),
                         (ph.inFile('pe-adeno-reads%d_2-id.%s.stdout' % (rl, suffix)),
                          ph.outFile('pe-adeno-reads%d_2-id.%s.stdout' % (rl, suffix)))])
            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-id-so%d.stdout' % (rl, so)),
                args=['--low-memory', '-id', '-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-id-so%d.razers' % (rl, so))],
                to_diff=[(ph.inFile('pe-adeno-reads%d_2-id-so%d.razers' % (rl, so)),
                          ph.outFile('pe-adeno-reads%d_2-id-so%d.razers' % (rl, so))),
                         (ph.inFile('pe-adeno-reads%d_2-id-so%d.stdout' % (rl, so)),
                          ph.outFile('pe-adeno-reads%d_2-id-so%d.stdout' % (rl, so)))])
            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(['razers2'] + 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
Example #3
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
Example #4
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    
    # Example 1
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('iso_r01_m200.A00_B00.stdout'),
        args=['-o', ph.inFile('../example/r01/iso_r01_m200.A00'), '-c',
              ph.inFile('../example/r01/iso_r01_m200.B00'), '-v', '2', '-i'],
        to_diff=[(ph.inFile('iso_r01_m200.A00_B00.stdout'),
                  ph.outFile('iso_r01_m200.A00_B00.stdout'))])
    conf_list.append(conf)

    # Example 2
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('iso_r01_m200.A01_B01.stdout'),
        args=['-o', ph.inFile('../example/r01/iso_r01_m200.A01'), '-c',
              ph.inFile('../example/r01/iso_r01_m200.B01'), '-v', '2', '-i'],
        to_diff=[(ph.inFile('iso_r01_m200.A01_B01.stdout'),
                  ph.outFile('iso_r01_m200.A01_B01.stdout'))])
    conf_list.append(conf)
    # Example 3
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('iso_r01_m200.A00_B01.stdout'),
        args=['-o', ph.inFile('../example/r01/iso_r01_m200.A00'), '-c',
              ph.inFile('../example/r01/iso_r01_m200.B01'), '-v', '2','-i'],
        to_diff=[(ph.inFile('iso_r01_m200.A00_B01.stdout'),
                  ph.outFile('iso_r01_m200.A00_B01.stdout'))])
    conf_list.append(conf)
	# Example 4
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('iso_r01_m200.A00.stdout'),
        args=['-o', ph.inFile('../example/r01/iso_r01_m200.A00'), '-v', '2'],
        to_diff=[(ph.inFile('iso_r01_m200.A00.stdout'),
                  ph.outFile('iso_r01_m200.A00.stdout'))])
    conf_list.append(conf)
	# Example 5

	#Example 6
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('srg_latin-4.stdout'),
        args=['-o', ph.inFile('../example/srg/latin-4'), '-v', '2'],
        to_diff=[(ph.inFile('srg_latin-4.stdout'),
                  ph.outFile('srg_latin-4.stdout'))])
    conf_list.append(conf)
    # Example 7
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('srg_lattice-4.stdout'),
        args=['-o', ph.inFile('../example/srg/lattice-4'), '-v', '2'],
        to_diff=[(ph.inFile('srg_lattice-4.stdout'),
                  ph.outFile('srg_lattice-4.stdout'))])
    conf_list.append(conf)
    # Example 8
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('srg_paley-5.stdout'),
        args=['-o', ph.inFile('../example/srg/paley-5'), '-v', '2'],
        to_diff=[(ph.inFile('srg_paley-5.stdout'),
                  ph.outFile('srg_paley-5.stdout'))])
    conf_list.append(conf)
    # Example 9
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('srg_sts7.stdout'),
        args=['-o', ph.inFile('../example/srg/sts-7'), '-v', '2'],
        to_diff=[(ph.inFile('srg_sts7.stdout'),
                  ph.outFile('srg_sts7.stdout'))])
    conf_list.append(conf)
    # Example 10
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('srg_triang-5.stdout'),
        args=['-o', ph.inFile('../example/srg/triang-5'), '-v', '2'],
        to_diff=[(ph.inFile('srg_triang-5.stdout'),
                  ph.outFile('srg_triang-5.stdout'))])
    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(['sgip'] + 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
Example #5
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),
        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
Example #6
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    if platform.machine().startswith('mips') or platform.machine().startswith(
            's390'):
        print 'Skipping tests for seqan_tcoffee on mips* and s390*'
        print '==================================================='
        return 0

    print 'Executing test for seqan_tcoffee'
    print '================================'
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run on Proteins (Balibase).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.fasta' % fname)
                                  ],
                                  to_diff=[(ph.inFile('%s.fasta' % fname),
                                            ph.outFile('%s.fasta' % fname))])
        conf_list.append(conf)

    # Run with explicit alphabet.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-a', 'protein', '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.protein.fasta' % fname)
                                  ],
                                  to_diff=[
                                      (ph.inFile('%s.protein.fasta' % fname),
                                       ph.outFile('%s.protein.fasta' % fname))
                                  ])
        conf_list.append(conf)

        # Run with different segment match generation options.  We run
    # with with single values and combinations of neighbours
    for fname in ['1aab', '1ad2', '2trx']:

        for m in ['global', 'local', 'overlap', 'lcs']:
            conf = app_tests.TestConf(
                program=path_to_program,
                args=[
                    '-m', m, '-s',
                    ph.inFile('%s.fa' % fname), '-o',
                    ph.outFile('%s.m%s.fasta' % (fname, m))
                ],
                to_diff=[(ph.inFile('%s.m%s.fasta' % (fname, m)),
                          ph.outFile('%s.m%s.fasta' % (fname, m)))])
            conf_list.append(conf)
        m1 = 'global'
        m2 = 'local'
        conf = app_tests.TestConf(
            program=path_to_program,
            args=[
                '-m', m1, '-m', m2, '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))
            ],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])
        conf_list.append(conf)
        m1 = 'local'
        m2 = 'overlap'
        conf = app_tests.TestConf(
            program=path_to_program,
            args=[
                '-m', m1, '-m', m2, '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))
            ],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])
        conf_list.append(conf)

        m1 = 'overlap'
        m2 = 'lcs'
        conf = app_tests.TestConf(
            program=path_to_program,
            args=[
                '-m', m1, '-m', m2, '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))
            ],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])
        m1 = 'global'
        m2 = 'lcs'
        conf = app_tests.TestConf(
            program=path_to_program,
            args=[
                '-m', m1, '-m', m2, '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))
            ],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])

    # Run with different match files variations.
    # TODO

    # Run with different scoring options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-g', '-20', '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.g-20.fasta' % fname)
                                  ],
                                  to_diff=[
                                      (ph.inFile('%s.g-20.fasta' % fname),
                                       ph.outFile('%s.g-20.fasta' % fname))
                                  ])
        conf_list.append(conf)
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-e', '-5', '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.e-5.fasta' % fname)
                                  ],
                                  to_diff=[(ph.inFile('%s.e-5.fasta' % fname),
                                            ph.outFile('%s.e-5.fasta' % fname))
                                           ])
        conf_list.append(conf)
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-ms', '10', '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.ms10.fasta' % fname)
                                  ],
                                  to_diff=[
                                      (ph.inFile('%s.ms10.fasta' % fname),
                                       ph.outFile('%s.ms10.fasta' % fname))
                                  ])
        conf_list.append(conf)
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-mm', '-8', '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.mm-8.fasta' % fname)
                                  ],
                                  to_diff=[
                                      (ph.inFile('%s.mm-8.fasta' % fname),
                                       ph.outFile('%s.mm-8.fasta' % fname))
                                  ])
        conf_list.append(conf)

    # Run with matrix file.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=[
                '-ma',
                ph.inFile('VTML200I'), '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.maVTML200.fasta' % fname)
            ],
            to_diff=[(ph.inFile('%s.maVTML200.fasta' % fname),
                      ph.outFile('%s.maVTML200.fasta' % fname))])
        conf_list.append(conf)

    # Run with manual guide tree.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-u',
                                      ph.inFile('%s.newick' % fname), '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.u.fasta' % fname)
                                  ],
                                  to_diff=[(ph.inFile('%s.u.fasta' % fname),
                                            ph.outFile('%s.u.fasta' % fname))])
        conf_list.append(conf)

    # Run with different guide tree building options.
    for fname in ['1aab', '1ad2', '2trx']:
        for b in ['nj', 'min', 'max', 'avg', 'wavg']:
            conf = app_tests.TestConf(
                program=path_to_program,
                args=[
                    '-b', b, '-s',
                    ph.inFile('%s.fa' % fname), '-o',
                    ph.outFile('%s.b%s.fasta' % (fname, b))
                ],
                to_diff=[(ph.inFile('%s.b%s.fasta' % (fname, b)),
                          ph.outFile('%s.b%s.fasta' % (fname, b)))])
            conf_list.append(conf)

    # Run alignment evaluation.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=['-i',
                                        ph.inFile('%s.fasta' % fname)],
                                  redir_stdout=ph.outFile('%s.i.fasta' %
                                                          fname),
                                  to_diff=[(ph.inFile('%s.i.fasta' % fname),
                                            ph.outFile('%s.i.fasta' % fname))])
        conf_list.append(conf)

    # ============================================================
    # Run on DNA (Adenoviruses).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [2, 3, 4]:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-a', 'dna', '-s',
                                      ph.inFile('adeno%d.fa' % i), '-o',
                                      ph.outFile('adeno%d.fasta' % i)
                                  ],
                                  to_diff=[(ph.inFile('adeno%d.fasta' % i),
                                            ph.outFile('adeno%d.fasta' % i))])
        conf_list.append(conf)

    # ============================================================
    # Run on RNA.
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [2, 3, 4]:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-a', 'rna', '-s',
                                      ph.inFile('adeno%d-rna.fa' % i), '-o',
                                      ph.outFile('adeno%d-rna.fasta' % i)
                                  ],
                                  to_diff=[
                                      (ph.inFile('adeno%d-rna.fasta' % i),
                                       ph.outFile('adeno%d-rna.fasta' % i))
                                  ])
        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(['seqan_tcoffee'] + 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
Example #7
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,
        'extras/apps/ngs_roi/tests')  # tests dir

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

    path_to_project = app_tests.autolocateBinary(
      binary_base, 'extras/apps/ngs_roi', 'roi_feature_projection')
    path_to_bam2roi = app_tests.autolocateBinary(
      binary_base, 'extras/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, 'extras/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
Example #8
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for searchjoin'
    print '==========================='
    print

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

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

    path_to_join = app_tests.autolocateBinary(binary_base, 'bin', 's4_join')

    path_to_search = app_tests.autolocateBinary(binary_base, 'bin',
                                                's4_search')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Define program parameters.
    # ============================================================

    # Seed length
    SL = {'geo': ['5'], 'dna': ['10']}
    # Errors
    K = {'geo': ['0', '1', '3'], 'dna': ['0', '8', '16']}
    # Threads
    THREADS = '4'

    # ============================================================
    # Configure Join Tests.
    # ============================================================

    for alphabet in ['geo', 'dna']:
        for k in K[alphabet]:
            for sl in SL[alphabet]:
                conf = app_tests.TestConf(
                    program=path_to_join,
                    #                    redir_stdout=ph.outFile('join_%s_%s_%s.stdout' % (alphabet, k, sl)),
                    args=[
                        ph.inFile('%s_database.csv' % alphabet), k, '-i',
                        alphabet, '-t', THREADS, '-sl', sl, '-o',
                        ph.outFile('join_%s_%s_%s.out' % (alphabet, k, sl))
                    ],
                    to_diff=[
                        (ph.inFile('join_%s_%s.out' % (alphabet, k)),
                         ph.outFile('join_%s_%s_%s.out' % (alphabet, k, sl)),
                         transforms)
                    ])
                conf_list.append(conf)

    # ============================================================
    # Configure Search Tests.
    # ============================================================

    for alphabet in ['geo', 'dna']:
        for sl in SL[alphabet]:
            conf = app_tests.TestConf(
                program=path_to_search,
                #                redir_stdout=ph.outFile('search_%s_%s.stdout' % (alphabet, sl)),
                args=[
                    ph.inFile('%s_database.csv' % alphabet),
                    ph.inFile('%s_queries.csv' % alphabet), '--no-wait', '-i',
                    alphabet, '-t', THREADS, '-sl', sl, '-o',
                    ph.outFile('search_%s_%s.out' % (alphabet, sl))
                ],
                to_diff=[(ph.inFile('search_%s.out' % (alphabet)),
                          ph.outFile('search_%s_%s.out' % (alphabet, sl)),
                          transforms)])
            conf_list.append(conf)

    # ============================================================
    # Run Tests.
    # ============================================================

    # Execute the tests.
    failures = 0
    for conf in conf_list:
        res = app_tests.runTest(conf)
        # Output to the user.
        print ' '.join([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
Example #9
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print "Executing test for insegt"
    print "========================="
    print

    ph = app_tests.TestPathHelper(source_base, binary_base, "apps/insegt/tests")  # tests dir

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

    path_to_program = app_tests.autolocateBinary(binary_base, "bin", "insegt")

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            "-ro",
            ph.outFile("default_readOutput.gff"),
            "-ao",
            ph.outFile("default_annoOutput.gff"),
            "-to",
            ph.outFile("default_tupleOutput.gff"),
            ph.inFile("alignments.sam"),
            ph.inFile("annotations.gff"),
        ],
        to_diff=[
            (ph.inFile("default_annoOutput.gff"), ph.outFile("default_annoOutput.gff")),
            (ph.inFile("default_readOutput.gff"), ph.outFile("default_readOutput.gff")),
            (ph.inFile("default_tupleOutput.gff"), ph.outFile("default_tupleOutput.gff")),
        ],
    )
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            "-c",
            str(2),
            "-ro",
            ph.outFile("threshold-count2_readOutput.gff"),
            "-ao",
            ph.outFile("threshold-count2_annoOutput.gff"),
            "-to",
            ph.outFile("threshold-count2_tupleOutput.gff"),
            ph.inFile("alignments.sam"),
            ph.inFile("annotations.gff"),
        ],
        to_diff=[
            (ph.inFile("threshold-count2_annoOutput.gff"), ph.outFile("threshold-count2_annoOutput.gff")),
            (ph.inFile("threshold-count2_readOutput.gff"), ph.outFile("threshold-count2_readOutput.gff")),
            (ph.inFile("threshold-count2_tupleOutput.gff"), ph.outFile("threshold-count2_tupleOutput.gff")),
        ],
    )
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            "-n",
            str(3),
            "-ro",
            ph.outFile("ntuple3_readOutput.gff"),
            "-ao",
            ph.outFile("ntuple3_annoOutput.gff"),
            "-to",
            ph.outFile("ntuple3_tupleOutput.gff"),
            ph.inFile("alignments.sam"),
            ph.inFile("annotations.gff"),
        ],
        to_diff=[
            (ph.inFile("ntuple3_annoOutput.gff"), ph.outFile("ntuple3_annoOutput.gff")),
            (ph.inFile("ntuple3_readOutput.gff"), ph.outFile("ntuple3_readOutput.gff")),
            (ph.inFile("ntuple3_tupleOutput.gff"), ph.outFile("ntuple3_tupleOutput.gff")),
        ],
    )
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            "-m",
            "-ro",
            ph.outFile("max-tuple_readOutput.gff"),
            "-ao",
            ph.outFile("max-tuple_annoOutput.gff"),
            "-to",
            ph.outFile("max-tuple_tupleOutput.gff"),
            ph.inFile("alignments.sam"),
            ph.inFile("annotations.gff"),
        ],
        to_diff=[
            (ph.inFile("max-tuple_annoOutput.gff"), ph.outFile("max-tuple_annoOutput.gff")),
            (ph.inFile("max-tuple_readOutput.gff"), ph.outFile("max-tuple_readOutput.gff")),
            (ph.inFile("max-tuple_tupleOutput.gff"), ph.outFile("max-tuple_tupleOutput.gff")),
        ],
    )
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            "-e",
            "-ro",
            ph.outFile("exact-ntuple_readOutput.gff"),
            "-ao",
            ph.outFile("exact-ntuple_annoOutput.gff"),
            "-to",
            ph.outFile("exact-ntuple_tupleOutput.gff"),
            ph.inFile("alignments.sam"),
            ph.inFile("annotations.gff"),
        ],
        to_diff=[
            (ph.inFile("exact-ntuple_annoOutput.gff"), ph.outFile("exact-ntuple_annoOutput.gff")),
            (ph.inFile("exact-ntuple_readOutput.gff"), ph.outFile("exact-ntuple_readOutput.gff")),
            (ph.inFile("exact-ntuple_tupleOutput.gff"), ph.outFile("exact-ntuple_tupleOutput.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(["insegt"] + 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
Example #10
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for samcat'
    print '========================='
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run on DNA (Adenoviruses).
    # ============================================================

    conf = app_tests.TestConf(program=path_to_program,
                              args=[
                                  ph.inFile('ex1_a1.sam'),
                                  ph.inFile('ex1_a2.sam'),
                                  ph.inFile('ex1_a3.sam'), '-o',
                                  ph.outFile('ex1_merged.sam')
                              ],
                              to_diff=[(ph.inFile('ex1_merged.sam'),
                                        ph.outFile('ex1_merged.sam'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(program=path_to_program,
                              args=[
                                  ph.inFile('ex1_a1.sam'),
                                  ph.inFile('ex1_a2.sam'),
                                  ph.inFile('ex1_a3.sam'), '-o',
                                  ph.outFile('ex1_merged.bam')
                              ],
                              to_diff=[(ph.inFile('ex1_merged.bam'),
                                        ph.outFile('ex1_merged.bam'), "gunzip")
                                       ])
    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
Example #11
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

    path_to_prepare = app_tests.autolocateBinary(
      binary_base, 'core/apps/rabema', 'rabema_prepare_sam')
    path_to_build = app_tests.autolocateBinary(
      binary_base, 'core/apps/rabema', 'rabema_build_gold_standard')
    path_to_evaluate = app_tests.autolocateBinary(
      binary_base, 'core/apps/rabema', 'rabema_evaluate')

    # ============================================================
    # Copy Files To Temp Dir.
    # ============================================================

    # We copy over the genome because an FAI file will be created.
    shutil.copyfile(ph.inFile('adeno-genome.fa'),
                    ph.outFile('adeno-genome.fa'))

    # ============================================================
    # Build TestConf list.
    # ============================================================

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Prepare SAM
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_prepare,
        args=['-i', ph.inFile('gold-adeno-hamming-08.sam'),
              '-o', ph.outFile('gold-adeno-hamming-08.by_qname.sam')],
        to_diff=[(ph.inFile('gold-adeno-hamming-08.by_qname.sam'),
                  ph.outFile('gold-adeno-hamming-08.by_qname.sam'))])
    conf_list.append(conf)
    conf = app_tests.TestConf(
        program=path_to_prepare,
        args=['-i', ph.inFile('gold-adeno-edit-08.sam'),
              '-o', ph.outFile('gold-adeno-edit-08.by_qname.sam')],
        to_diff=[(ph.inFile('gold-adeno-edit-08.by_qname.sam'),
                  ph.outFile('gold-adeno-edit-08.by_qname.sam'))])
    conf_list.append(conf)

    # ============================================================
    # Build Gold Standard
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_build,
        redir_stdout=ph.outFile('gold-adeno-hamming-08.stdout'),
        args=['--distance-metric', 'hamming', '-e', '8',
              '-o', ph.outFile('gold-adeno-hamming-08.gsi'),
              '--reference', ph.outFile('adeno-genome.fa'),
              '--in-sam', ph.inFile('gold-adeno-hamming-08.by_coordinate.sam')],
        to_diff=[(ph.inFile('gold-adeno-hamming-08.stdout'),
                  ph.outFile('gold-adeno-hamming-08.stdout')),
                 (ph.inFile('gold-adeno-hamming-08.gsi'),
                  ph.outFile('gold-adeno-hamming-08.gsi'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_build,
        redir_stdout=ph.outFile('gold-adeno-edit-08.stdout'),
        args=['--distance-metric', 'edit', '-e', '8',
              '-o', ph.outFile('gold-adeno-edit-08.gsi'),
              '--reference', ph.outFile('adeno-genome.fa'),
              '--in-sam', ph.inFile('gold-adeno-edit-08.by_coordinate.sam')],
        to_diff=[(ph.inFile('gold-adeno-edit-08.stdout'),
                  ph.outFile('gold-adeno-edit-08.stdout')),
                 (ph.inFile('gold-adeno-edit-08.gsi'),
                  ph.outFile('gold-adeno-edit-08.gsi'))])
    conf_list.append(conf)

    # ============================================================
    # Compare.
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-hamming-08.stdout'),
        args=['--distance-metric', 'hamming', '-e', '8',
              '--reference', ph.outFile('adeno-genome.fa'),
              '--in-sam', ph.inFile('razers2-adeno-hamming-08.sam'),
              '--in-gsi', ph.inFile('gold-adeno-hamming-08.gsi')],
        to_diff=[(ph.inFile('razers2-adeno-hamming-08.stdout'),
                  ph.outFile('razers2-adeno-hamming-08.stdout'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-hamming-04.stdout'),
        args=['--distance-metric', 'hamming', '-e', '8',
              '--reference', ph.outFile('adeno-genome.fa'),
              '--in-sam', ph.inFile('razers2-adeno-hamming-04.sam'),
              '--in-gsi', ph.inFile('gold-adeno-hamming-08.gsi')],
        to_diff=[(ph.inFile('razers2-adeno-hamming-04.stdout'),
                  ph.outFile('razers2-adeno-hamming-04.stdout'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-edit-08.stdout'),
        args=['--distance-metric', 'edit', '-e', '8',
              '--reference', ph.outFile('adeno-genome.fa'),
              '--in-sam', ph.inFile('razers2-adeno-edit-08.sam'),
              '--in-gsi', ph.inFile('gold-adeno-edit-08.gsi')],
        to_diff=[(ph.inFile('razers2-adeno-edit-08.stdout'),
                  ph.outFile('razers2-adeno-edit-08.stdout'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-edit-04.stdout'),
        args=['--distance-metric', 'edit', '-e', '8',
              '--reference', ph.outFile('adeno-genome.fa'),
              '--in-sam', ph.inFile('razers2-adeno-edit-04.sam'),
              '--in-gsi', ph.inFile('gold-adeno-edit-08.gsi')],
        to_diff=[(ph.inFile('razers2-adeno-edit-04.stdout'),
                  ph.outFile('razers2-adeno-edit-04.stdout'))])

    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
Example #12
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(
        program=path_to_program,
        args=['-ro', ph.outFile('default_readOutput.gff'),
              '-ao', ph.outFile('default_annoOutput.gff'),
              '-to', ph.outFile('default_tupleOutput.gff'),
              ph.inFile('alignments.sam'),
              ph.inFile('annotations.gff')],
        to_diff=[(ph.inFile('default_annoOutput.gff'),
                  ph.outFile('default_annoOutput.gff')),
                 (ph.inFile('default_readOutput.gff'),
                  ph.outFile('default_readOutput.gff')),
                 (ph.inFile('default_tupleOutput.gff'),
                  ph.outFile('default_tupleOutput.gff'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=['-c', str(2), 
              '-ro', ph.outFile('threshold-count2_readOutput.gff'),
              '-ao', ph.outFile('threshold-count2_annoOutput.gff'),
              '-to', ph.outFile('threshold-count2_tupleOutput.gff'),
              ph.inFile('alignments.sam'),
              ph.inFile('annotations.gff')],
        to_diff=[(ph.inFile('threshold-count2_annoOutput.gff'),
                  ph.outFile('threshold-count2_annoOutput.gff')),
                 (ph.inFile('threshold-count2_readOutput.gff'),
                  ph.outFile('threshold-count2_readOutput.gff')),
                 (ph.inFile('threshold-count2_tupleOutput.gff'),
                  ph.outFile('threshold-count2_tupleOutput.gff'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=['-n', str(3), 
              '-ro', ph.outFile('ntuple3_readOutput.gff'),
              '-ao', ph.outFile('ntuple3_annoOutput.gff'),
              '-to', ph.outFile('ntuple3_tupleOutput.gff'),
              ph.inFile('alignments.sam'),
              ph.inFile('annotations.gff')],
        to_diff=[(ph.inFile('ntuple3_annoOutput.gff'),
                  ph.outFile('ntuple3_annoOutput.gff')),
                 (ph.inFile('ntuple3_readOutput.gff'),
                  ph.outFile('ntuple3_readOutput.gff')),
                 (ph.inFile('ntuple3_tupleOutput.gff'),
                  ph.outFile('ntuple3_tupleOutput.gff'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=['-m', 
              '-ro', ph.outFile('max-tuple_readOutput.gff'),
              '-ao', ph.outFile('max-tuple_annoOutput.gff'),
              '-to', ph.outFile('max-tuple_tupleOutput.gff'),
              ph.inFile('alignments.sam'),
              ph.inFile('annotations.gff')],
        to_diff=[(ph.inFile('max-tuple_annoOutput.gff'),
                  ph.outFile('max-tuple_annoOutput.gff')),
                 (ph.inFile('max-tuple_readOutput.gff'),
                  ph.outFile('max-tuple_readOutput.gff')),
                 (ph.inFile('max-tuple_tupleOutput.gff'),
                  ph.outFile('max-tuple_tupleOutput.gff'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=['-e', 
              '-ro', ph.outFile('exact-ntuple_readOutput.gff'),
              '-ao', ph.outFile('exact-ntuple_annoOutput.gff'),
              '-to', ph.outFile('exact-ntuple_tupleOutput.gff'),
              ph.inFile('alignments.sam'),
              ph.inFile('annotations.gff')],
        to_diff=[(ph.inFile('exact-ntuple_annoOutput.gff'),
                  ph.outFile('exact-ntuple_annoOutput.gff')),
                 (ph.inFile('exact-ntuple_readOutput.gff'),
                  ph.outFile('exact-ntuple_readOutput.gff')),
                 (ph.inFile('exact-ntuple_tupleOutput.gff'),
                  ph.outFile('exact-ntuple_tupleOutput.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(['insegt'] + 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
Example #13
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for seqan_flexbar'
    print '================================'
    print

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

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

    path_to_program = []
    path_to_program.append(
        app_tests.autolocateBinary(binary_base, 'bin', 'sflexQC'))

    path_to_program.append(
        app_tests.autolocateBinary(binary_base, 'bin', 'sflexFilter'))

    path_to_program.append(
        app_tests.autolocateBinary(binary_base, 'bin', 'sflexAR'))

    path_to_program.append(
        app_tests.autolocateBinary(binary_base, 'bin', 'sflexDMulti'))

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(program=path_to_program[0],
                              redir_stdout=ph.outFile('out.stdout'),
                              args=[
                                  ph.inFile('testsample.fq'), '-q', '20', '-o',
                                  ph.outFile('qc_test.fa'), '-t', '-ni'
                              ],
                              to_diff=[(ph.inFile('qc_test.stdout'),
                                        ph.outFile('out.stdout')),
                                       (ph.inFile('gold_qc_test.fa'),
                                        ph.outFile('qc_test.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(program=path_to_program[1],
                              redir_stdout=ph.outFile('out.stdout'),
                              args=[
                                  ph.inFile('testsample.fq'), '-tl', '3',
                                  '-tr', '4', '-ml', '70', '-u', '1', '-s',
                                  'A', '-fl', '70', '-ni', '-o',
                                  ph.outFile('filter_test.fq')
                              ],
                              to_diff=[(ph.inFile('filter_test.stdout'),
                                        ph.outFile('out.stdout')),
                                       (ph.inFile('gold_filter_test.fq'),
                                        ph.outFile('filter_test.fq'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(program=path_to_program[2],
                              redir_stdout=ph.outFile('out.stdout'),
                              args=[
                                  ph.inFile('testsample.fq'), '-a',
                                  ph.inFile('adapter.fa'), '-o',
                                  ph.outFile('ar_test.fq'), '-ni'
                              ],
                              to_diff=[(ph.inFile('ar_test.stdout'),
                                        ph.outFile('out.stdout')),
                                       (ph.inFile('gold_ar_test.fq'),
                                        ph.outFile('ar_test.fq'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(program=path_to_program[3],
                              redir_stdout=ph.outFile('out.stdout'),
                              args=[
                                  ph.inFile('testsample_multiplex.fq'), '-b',
                                  ph.inFile('barcodes.fa'), '-o',
                                  ph.outFile('test_de_multi.fq'), '-ni'
                              ],
                              to_diff=[
                                  (ph.inFile('gold_de_multi.stdout'),
                                   ph.outFile('out.stdout')),
                                  (ph.inFile('gold_de_multi_Sample-1.fq'),
                                   ph.outFile('test_de_multi_Sample-1.fq')),
                                  (ph.inFile('gold_de_multi_Sample26.fq'),
                                   ph.outFile('test_de_multi_Sample26.fq')),
                                  (ph.inFile('gold_de_multi_Sample-2.fq'),
                                   ph.outFile('test_de_multi_Sample-2.fq')),
                                  (ph.inFile('gold_de_multi_Sample0.fq'),
                                   ph.outFile('test_de_multi_Sample0.fq')),
                                  (ph.inFile('gold_de_multi_Sample1458.fq'),
                                   ph.outFile('test_de_multi_Sample1458.fq')),
                                  (ph.inFile('gold_de_multi_Sample37.fq'),
                                   ph.outFile('test_de_multi_Sample37.fq')),
                                  (ph.inFile('gold_de_multi_unidentified.fq'),
                                   ph.outFile('test_de_multi_unidentified.fq'))
                              ])
    conf_list.append(conf)

    # ============================================================
    # Execute the tests.
    # ============================================================
    failures = 0
    counter = 0
    for conf in conf_list:
        res = app_tests.runTest(conf)
        # Output to the user.
        print ' '.join([path_to_program[counter]] + conf.args),
        if res:
            print 'OK'
        else:
            failures += 1
            print 'FAILED'
        counter += 1

    # 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
Example #14
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # Run with default options.
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('se-adeno-reads36_1_default.stdout'),
        args=[ph.inFile('adeno-genome.fa'),
              ph.inFile('adeno-reads36_1.fa'),
              '-o', ph.outFile('se-adeno-reads36_1_default.razers' )],
        to_diff=[(ph.inFile('se-adeno-reads36_1_default.razers' ),
                  ph.outFile('se-adeno-reads36_1_default.razers' )),
                 (ph.inFile('se-adeno-reads36_1_default.stdout' ),
                  ph.outFile('se-adeno-reads36_1_default.stdout' ))])
    conf_list.append(conf)
    
    # Run with different seed lengths
    for sl in range(14,21):
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('se-adeno-reads36_1_sl%d.stdout' % sl),
            args=['-sL', str(sl), 
                  ph.inFile('adeno-genome.fa'),
                  ph.inFile('adeno-reads36_1.fa'),
                  '-o', ph.outFile('se-adeno-reads36_1_sl%d.razers' % sl)],
            to_diff=[(ph.inFile('se-adeno-reads36_1_sl%d.razers' % sl),
                      ph.outFile('se-adeno-reads36_1_sl%d.razers' % sl)),
                     (ph.inFile('se-adeno-reads36_1_sl%d.stdout' % sl),
                      ph.outFile('se-adeno-reads36_1_sl%d.stdout' % sl))])
        conf_list.append(conf)
    
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('se-adeno-reads36_1_sl%d_sam.stdout' % sl),
            args=['-sL', str(sl), 
                  ph.inFile('adeno-genome.fa'),
                  ph.inFile('adeno-reads36_1.fa'),
                  '-o', ph.outFile('se-adeno-reads36_1_sl%d.sam' % sl)],
            to_diff=[(ph.inFile('se-adeno-reads36_1_sl%d.sam' % sl),
                      ph.outFile('se-adeno-reads36_1_sl%d.sam' % sl)),
                     (ph.inFile('se-adeno-reads36_1_sl%d_sam.stdout' % sl),
                      ph.outFile('se-adeno-reads36_1_sl%d_sam.stdout' % sl))])
        conf_list.append(conf)
    
        # allow error in seed
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('se-adeno-reads36_1_sl%d_se.stdout' % sl),
            args=['-sL', str(sl), '-sE',
                  ph.inFile('adeno-genome.fa'),
                  ph.inFile('adeno-reads36_1.fa'),
                  '-o', ph.outFile('se-adeno-reads36_1_sl%d_se.razers' % sl)],
            to_diff=[(ph.inFile('se-adeno-reads36_1_sl%d_se.razers' % sl),
                      ph.outFile('se-adeno-reads36_1_sl%d_se.razers' % sl)),
                     (ph.inFile('se-adeno-reads36_1_sl%d_se.stdout' % sl),
                      ph.outFile('se-adeno-reads36_1_sl%d_se.stdout' % sl))])
        conf_list.append(conf)


    # change maxhits parameter 
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('se-adeno-reads36_1_sl18_m20_pa.stdout' ),
        args=['-sL', str(18), '-m', str(20), '-pa',
              ph.inFile('adeno-genome.fa'),
              ph.inFile('adeno-reads36_1.fa'),
              '-o', ph.outFile('se-adeno-reads36_1_sl18_m20_pa.razers' )],
        to_diff=[(ph.inFile('se-adeno-reads36_1_sl18_m20_pa.razers' ),
                  ph.outFile('se-adeno-reads36_1_sl18_m20_pa.razers' )),
                 (ph.inFile('se-adeno-reads36_1_sl18_m20_pa.stdout' ),
                  ph.outFile('se-adeno-reads36_1_sl18_m20_pa.stdout' ))])
    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(['micro_razers'] + 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
Example #15
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
Example #16
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
Example #17
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    # gold standard binary files created on little endian
    if sys.byteorder != 'little':
        print('Skipping tests for DREAM-Yara on big endian')
        print('=====================================')
        return 0

    print('Executing test for DREAM-Yara')
    print('====================================')

    ph = app_tests.TestPathHelper(source_base, binary_base,
                                  'test')  # tests dir

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

    path_to_dream_indexer = app_tests.autolocateBinary(binary_base, 'bin',
                                                       'dream_yara_indexer')

    path_to_ibf_filter = app_tests.autolocateBinary(binary_base, 'bin',
                                                    'dream_yara_build_filter')

    path_to_dream_mapper = app_tests.autolocateBinary(binary_base, 'bin',
                                                      'dream_yara_mapper')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run Distributed indexer Tests
    # ============================================================

    for organism in ['64-viral']:
        # ============================================================
        # Split the genomes in to 64 bins.
        # ============================================================
        tempFastaDir = ph.outFile('%s-binned-genomes/' % organism)
        if not os.path.exists(tempFastaDir):
            os.makedirs(tempFastaDir)
        binFastaLen = 101  # each fasta entry is 100 lines long (101 including the header)
        inputFasta = open(ph.inFile('data/input/%s-genomes.fa' % organism),
                          'r').read().split('\n')
        for b in range(64):
            # First, get the slice
            binFasta = inputFasta[b * binFastaLen:(b + 1) * binFastaLen]
            # Now open one file per bin and dump the part
            outputFasta = open(tempFastaDir + '/' + str(b) + '.fa', 'w')
            outputFasta.write('\n'.join(binFasta))
            outputFasta.close()

        # Get file extensions for the fm index files
        exts = [
            os.path.basename(fname).split('.', 1)[-1] for fname in glob.glob(
                ph.inFile('data/gold/%s-genomes.*' % organism))
        ]

        outFileDir = ph.outFile('data/input/%s-binned-indices/' % organism)
        InfileNames = [tempFastaDir + str(b) + '.fa' for b in range(64)]
        fileNames = [str(b) + '.' + e for b in range(64) for e in exts]
        if not os.path.exists(outFileDir):
            os.makedirs(outFileDir)

        conf = app_tests.TestConf(
            program=path_to_dream_indexer,
            args=['--verbose', '-o', outFileDir] + InfileNames,
            to_diff=[(ph.inFile('data/gold/%s-binned-indices/%s' %
                                (organism, fileName)),
                      ph.outFile(outFileDir + fileName), 'md5')
                     for fileName in fileNames])
        conf_list.append(conf)

    # ============================================================
    # Run DREAM-yara IBF Filter Tests compute
    # ============================================================

    ibf_args = ['-t', '4', '-k', '19', '-nh', ' 2', '-bs', '1']
    for organism in ['64-viral']:
        conf = app_tests.TestConf(
            program=path_to_ibf_filter,
            args=[
                '--verbose', '-o',
                ph.outFile('%s-binned-genomes.filter' % organism)
            ] + ibf_args + InfileNames)
        conf_list.append(conf)

    # ============================================================
    # Run Single-End DREAM-Yara Tests
    # ============================================================

    dis_mapper_args = [
        ['-e', '0.03', '--threads', '1'],
        ['-e', '0.03', '--threads', '1', '-sm', 'record', '-s', '10'],
        ['-e', '0.03', '--threads', '1', '-sm', 'tag', '-s', '10']
    ]
    dis_mapper_suffix = ['t1', 'rec.t1', 'tag.t1']

    for organism in ['64-viral']:
        for i in range(0, len(dis_mapper_args)):

            basic = app_tests.TestConf(
                program=path_to_dream_mapper,
                args=[
                    '--verbose',
                    ph.inFile('data/gold/%s-binned-indices/' % organism),
                    ph.inFile('data/input/%s-reads.fa' % organism), '-fi',
                    ph.outFile('%s-binned-genomes.filter' % organism), '-o',
                    ph.outFile('%s-reads.%s.sam' %
                               (organism, dis_mapper_suffix[i]))
                ] + dis_mapper_args[i],
                to_diff=[(ph.inFile('data/gold/%s-reads.%s.sam' %
                                    (organism, dis_mapper_suffix[i])),
                          ph.outFile('%s-reads.%s.sam' %
                                     (organism, dis_mapper_suffix[i])),
                          sam_transforms)])
            conf_list.append(basic)

    # ============================================================
    # Execute the tests
    # ============================================================

    failures = 0
    try:
        for conf in conf_list:
            # Output to the user.
            print('Executing: {}'.format(' '.join([conf.program] + conf.args)))
            res = app_tests.runTest(conf)
            if res:
                print('OK\n==============================\n')
            else:
                failures += 1
                print('FAILED\n==============================\n')
    except Exception as e:
        raise e  # This exception is saved, then finally is executed, and then the exception is raised.
    finally:
        # 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
Example #18
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
Example #19
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
Example #20
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

    path_to_join = app_tests.autolocateBinary(
      binary_base, 'bin', 's4_join')

    path_to_search = app_tests.autolocateBinary(
      binary_base, 'bin', 's4_search')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Define program parameters.
    # ============================================================

    # Seed length
    SL = {
            'geo': ['5'],
            'dna': ['10']
    }
    # Errors
    K  = {
            'geo': ['0', '1', '3'],
            'dna': ['0', '8', '16']
    }
    # Threads
    THREADS = '4'

    # ============================================================
    # Configure Join Tests.
    # ============================================================

    for alphabet in ['geo', 'dna']:
        for k in K[alphabet]:
            for sl in SL[alphabet]:
                conf = app_tests.TestConf(
                    program=path_to_join,
#                    redir_stdout=ph.outFile('join_%s_%s_%s.stdout' % (alphabet, k, sl)),
                    args=[ph.inFile('%s_database.csv' % alphabet), k,
                          '-i', alphabet,
                          '-t', THREADS,
                          '-sl', sl,
                          '-o', ph.outFile('join_%s_%s_%s.out' % (alphabet, k, sl))],
                    to_diff=[(ph.inFile('join_%s_%s.out' % (alphabet, k)),
                             ph.outFile('join_%s_%s_%s.out' % (alphabet, k, sl)),
                             transforms)])
                conf_list.append(conf)

    # ============================================================
    # Configure Search Tests.
    # ============================================================

    for alphabet in ['geo', 'dna']:
        for sl in SL[alphabet]:
            conf = app_tests.TestConf(
                program=path_to_search,
#                redir_stdout=ph.outFile('search_%s_%s.stdout' % (alphabet, sl)),
                args=[ph.inFile('%s_database.csv' % alphabet),
                      ph.inFile('%s_queries.csv' % alphabet),
                      '--no-wait',
                      '-i', alphabet,
                      '-t', THREADS,
                      '-sl', sl,
                      '-o', ph.outFile('search_%s_%s.out' % (alphabet, sl))],
                to_diff=[(ph.inFile('search_%s.out' % (alphabet)),
                         ph.outFile('search_%s_%s.out' % (alphabet, sl)),
                         transforms)])
            conf_list.append(conf)

    # ============================================================
    # Run Tests.
    # ============================================================

    # Execute the tests.
    failures = 0
    for conf in conf_list:
        res = app_tests.runTest(conf)
        # Output to the user.
        print ' '.join([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
Example #21
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    # gold standard binary files created on little endian
    if sys.byteorder != 'little':
        print 'Skipping tests for Yara on big endian'
        print '====================================='
        return 0

    print 'Executing test for Yara'
    print '=============================='
    print

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

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

    path_to_indexer = app_tests.autolocateBinary(binary_base, 'bin',
                                                 'yara_indexer')

    path_to_mapper = app_tests.autolocateBinary(binary_base, 'bin',
                                                'yara_mapper')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run Indexer Tests
    # ============================================================

    for organism in ['adeno']:

        # Get file extensions for the fm index files
        exts = [
            os.path.basename(fname).split('.', 1)[-1]
            for fname in glob.glob(ph.inFile('gold/%s-genome.*' % organism))
        ]

        conf = app_tests.TestConf(
            program=path_to_indexer,
            args=[
                ph.inFile('input/%s-genome.fa' % organism), '-o',
                ph.outFile('%s-genome' % organism)
            ],
            to_diff=[(ph.inFile('gold/%s-genome.%s' % (organism, ext)),
                      ph.outFile('%s-genome.%s' % (organism, ext)), 'md5')
                     for ext in exts])
        conf_list.append(conf)

    # ============================================================
    # Run Single-End Mapper Tests
    # ============================================================


#    mapper_args = [
#                    ['--threads', '1' ]],
#                    ['--threads', '8' ]
#                  ]
#    mapper_suffix = ['t1', 't8']

    mapper_args = [['--threads', '1']]
    mapper_suffix = ['t1']

    for organism in ['adeno']:
        for i in range(0, len(mapper_args)):

            conf = app_tests.TestConf(
                program=path_to_mapper,
                args=[
                    ph.inFile('gold/%s-genome' % organism),
                    ph.inFile('input/%s-reads_1.fa' % organism), '-o',
                    ph.outFile('%s-reads_1.%s.sam' %
                               (organism, mapper_suffix[i]))
                ] + mapper_args[i],
                to_diff=[(ph.inFile('gold/%s-reads_1.%s.sam' %
                                    (organism, mapper_suffix[i])),
                          ph.outFile('%s-reads_1.%s.sam' %
                                     (organism, mapper_suffix[i])),
                          sam_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.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
Example #22
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for sak'
    print '======================'
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run on DNA (Adenoviruses).
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-o',
            ph.outFile('adeno.all.fa')
        ],
        to_diff=[(ph.inFile('adeno.all.fa'), ph.outFile('adeno.all.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-s',
            '1',
            '-o',
            ph.outFile('adeno.seq1.fa')
        ],
        to_diff=[(ph.inFile('adeno.seq1.fa'), ph.outFile('adeno.seq1.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-ss',
            '1-2',
            '-o',
            ph.outFile('adeno.seq1-2.fa')
        ],
        to_diff=[(ph.inFile('adeno.seq1-2.fa'), ph.outFile('adeno.seq1-2.fa'))
                 ])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-s',
            '3',
            '-o',
            ph.outFile('adeno.seq3.fa')
        ],
        to_diff=[(ph.inFile('adeno.seq3.fa'), ph.outFile('adeno.seq3.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-sn',
            'gi|9626621',
            '-o',
            ph.outFile('adeno.sn.fa')
        ],
        to_diff=[(ph.inFile('adeno.sn.fa'), ph.outFile('adeno.sn.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-s',
            '1',
            '-i',
            '5-25',
            '-o',
            ph.outFile('adeno.s1i5-25.fa')
        ],
        to_diff=[(ph.inFile('adeno.s1i5-25.fa'),
                  ph.outFile('adeno.s1i5-25.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-ss',
            '1-2',
            '-i',
            '5-25',
            '-o',
            ph.outFile('adeno.s1-2i5-25.fa')
        ],
        to_diff=[(ph.inFile('adeno.s1-2i5-25.fa'),
                  ph.outFile('adeno.s1-2i5-25.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            ph.inFile('adeno.fasta'),
            #              '-ll', '1000',
            '-s',
            '1',
            '-rc',
            '-o',
            ph.outFile('adeno.s1rc.fa')
        ],
        to_diff=[(ph.inFile('adeno.s1rc.fa'), ph.outFile('adeno.s1rc.fa'))])
    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(['sak'] + 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
Example #23
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for cuda mapper'
    print '=============================='
    print

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

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

    path_to_indexer = app_tests.autolocateBinary(binary_base, 'bin',
                                                 'cuda_indexer')

    path_to_mapper = app_tests.autolocateBinary(binary_base, 'bin',
                                                'cuda_mapper')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run Indexer Tests
    # ============================================================

    #    for organism in ['celegans', 'hg18']:
    for organism in []:

        # Get file extensions for the fm index files
        exts = [
            os.path.basename(fname).split('.', 2)[-1] for fname in glob.glob(
                ph.inFile('datasets/%s/genome.fasta.*' % organism))
        ]

        conf = app_tests.TestConf(
            program=path_to_indexer,
            args=[
                ph.inFile('datasets/%s/genome.fasta' % organism), '-xp',
                ph.outFile('%s.fm' % organism)
            ],
            redir_stdout=ph.outFile('indexer.%s.stdout' % organism),
            to_diff=[(ph.inFile('datasets/%s/genome.fm.%s' % (organism, ext)),
                      ph.outFile('%s.fm.%s' % (organism, ext)), 'md5')
                     for ext in exts] +
            [(ph.inFile('logs/indexer.%s.stdout' % organism),
              ph.outFile('indexer.%s.stdout' % organism), transforms)])
        conf_list.append(conf)

    # ============================================================
    # Run Single-End Mapper Tests
    # ============================================================

    mapper_args = [['--no-cuda', '--threads', '1'],
                   ['--no-cuda', '--threads', '8'], []]
    log_suffix = ['t1', 't8', 'cuda']

    for organism in ['celegans', 'hg18']:
        for i in range(0, len(mapper_args)):

            conf = app_tests.TestConf(
                program=path_to_mapper,
                args=[
                    ph.inFile('datasets/%s/genome.fasta' % organism),
                    ph.inFile('datasets/%s/reads.fastq' % organism), '-xp',
                    ph.inFile('datasets/%s/genome.fm' % organism)
                ] + mapper_args[i],
                redir_stdout=ph.outFile('mapper.%s.%s.stdout' %
                                        (organism, log_suffix[i])),
                to_diff=[(ph.inFile('logs/mapper.%s.%s.stdout' %
                                    (organism, log_suffix[i])),
                          ph.outFile('mapper.%s.%s.stdout' %
                                     (organism, log_suffix[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.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
Example #24
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for tree_recomb'
    print '=============================='
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []
    for i in [1, 2, 3]:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-m',
                                      ph.inFile('example%d.dist' % i), '-o',
                                      ph.outFile('example%d.dot' % i)
                                  ],
                                  to_diff=[(ph.inFile('example%d.dot' % i),
                                            ph.outFile('example%d.dot' % i))])
        conf_list.append(conf)
    for i in [1, 2, 3]:
        for b in ['nj', 'min', 'max', 'avg', 'wavg']:
            if i == 1 and b == 'avg':
                continue  # Skip, rounding problems MSVC vs GCC.
            conf = app_tests.TestConf(
                program=path_to_program,
                args=[
                    '-b', b, '-m',
                    ph.inFile('example%d.dist' % i), '-o',
                    ph.outFile('example%d.%s.dot' % (i, b))
                ],
                to_diff=[(ph.inFile('example%d.%s.dot' % (i, b)),
                          ph.outFile('example%d.%s.dot' % (i, b)))])
            conf_list.append(conf)
    for i in [1, 2, 3]:
        for f in ['dot', 'newick']:
            conf = app_tests.TestConf(program=path_to_program,
                                      args=[
                                          '-m',
                                          ph.inFile('example%d.dist' % i),
                                          '-o',
                                          ph.outFile('example%d.%s' % (i, f))
                                      ],
                                      to_diff=[
                                          (ph.inFile('example%d.%s' % (i, f)),
                                           ph.outFile('example%d.%s' % (i, f)))
                                      ])
            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(['tree_recomb'] + 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
Example #25
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for %(APP_NAME)s'
    print '========================='
    print
    
    ph = app_tests.TestPathHelper(
        source_base, binary_base,
        '%(LOCATION)s/tests')  # tests dir

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

    path_to_program = app_tests.autolocateBinary(
      binary_base, '%(LOCATION)s', '%(APP_NAME)s')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('STDOUT_FILE'),
        args=['ARGS', 'MUST', 'BE', 'STRINGS', str(1), str(99),
              ph.inFile('INPUT_FILE1'),
              ph.inFile('INPUT_FILE2')],
        to_diff=[(ph.inFile('STDOUT_FILE'),
                  ph.outFile('STDOUT_FILE')),
                 (ph.inFile('INPUT_FILE1'),
                  ph.outFile('INPUT_FILE1'))])
    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(['%(APP_NAME)s'] + 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
Example #26
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
Example #27
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for %(APP_NAME)s'
    print '========================='
    print
    
    ph = app_tests.TestPathHelper(
        source_base, binary_base,
        '%(LOCATION)s/tests')  # tests dir

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

    path_to_program = app_tests.autolocateBinary(
      binary_base, '%(LOCATION)s', '%(APP_NAME)s')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('STDOUT_FILE'),
        args=['ARGS', 'MUST', 'BE', 'STRINGS', str(1), str(99),
              ph.inFile('INPUT_FILE1'),
              ph.inFile('INPUT_FILE2')],
        to_diff=[(ph.inFile('STDOUT_FILE'),
                  ph.outFile('STDOUT_FILE')),
                 (ph.inFile('INPUT_FILE1'),
                  ph.outFile('INPUT_FILE1'))])
    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(['%(APP_NAME)s'] + 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
Example #28
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for dfi'
    print '======================'
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    paramsFile = open(ph.inFile("params.txt"), "r")

    # unzip datasets into test directory
    unzip_file_into_dir(ph.inFile("datasets.zip"), ph.outFile('', 'datasets'))
    unzip_file_into_dir(ph.inFile("results.zip"), ph.outFile('', 'expected'))

    # We run the following for all read lengths we have reads for.
    for paramLine in paramsFile.readlines():
        params = paramLine.split()
        # Run with options parsed from params file.
        conf = app_tests.TestConf(program=path_to_program,
                                  redir_stdout=ph.outFile(params[0]),
                                  args=[
                                      ph.outFile(params[1], 'datasets'),
                                      ph.outFile(params[2], 'datasets')
                                  ] + params[3:],
                                  to_diff=[(ph.outFile(params[0], 'expected'),
                                            ph.outFile(params[0]))])
        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(['dfi'] + 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
Example #29
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
Example #30
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
Example #31
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []
    for i in [1, 2, 3]:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-m', ph.inFile('example%d.dist' % i),
                  '-o', ph.outFile('example%d.out' % i)],
            to_diff=[(ph.inFile('example%d.out' % i),
                      ph.outFile('example%d.out' % i))])
        conf_list.append(conf)
    for i in [1, 2, 3]:
        for b in ['nj', 'min', 'max', 'avg', 'wavg']:
            if i == 1 and b == 'avg':
                continue  # Skip, rounding problems MSVC vs GCC.
            conf = app_tests.TestConf(
                program=path_to_program,
                args=['-b', b,
                      '-m', ph.inFile('example%d.dist' % i),
                      '-o', ph.outFile('example%d.%s.out' % (i, b))],
                to_diff=[(ph.inFile('example%d.%s.out' % (i, b)),
                          ph.outFile('example%d.%s.out' % (i, b)))])
            conf_list.append(conf)
    for i in [1, 2, 3]:
        for f in ['dot', 'newick']:
            conf = app_tests.TestConf(
                program=path_to_program,
                args=['-f', f,
                      '-m', ph.inFile('example%d.dist' % i),
                      '-o', ph.outFile('example%d.%s.out' % (i, f))],
                to_diff=[(ph.inFile('example%d.%s.out' % (i, f)),
                          ph.outFile('example%d.%s.out' % (i, f)))])
            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(['tree_recomb'] + 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
Example #32
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

    # ============================================================
    # 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: Strip the
    # running times from output.
    transforms = [
        app_tests.RegexpReplaceTransform(r'Finished haplotype creation in [^ ]+s',
                                         r'Finished haplotype creation in <cut out>s',
                                         left=True, right=True),
        ]

    # ============================================================
    # Run 454 Reads, Single-End
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('454-se-random-N100-nm400-ne40-s0.stdout'),
        args=['454', '-N', '100', '-nm', '400', '-ne', '40', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('454-se-random-N100-nm400-ne40-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('454-se-random-N100-nm400-ne40-s0.fasta'),
                  ph.outFile('454-se-random-N100-nm400-ne40-s0.fasta')),
                 (ph.inFile('454-se-random-N100-nm400-ne40-s0.fasta.sam'),
                  ph.outFile('454-se-random-N100-nm400-ne40-s0.fasta.sam')),
                 (ph.inFile('454-se-random-N100-nm400-ne40-s0.stdout'),
                  ph.outFile('454-se-random-N100-nm400-ne40-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('454-se-random-N100-nm400-ne40-s0-sq.stdout'),
        args=['454', '-N', '100', '-nm', '400', '-ne', '40', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('454-se-random-N100-nm400-ne40-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('454-se-random-N100-nm400-ne40-s0-sq.fastq'),
                  ph.outFile('454-se-random-N100-nm400-ne40-s0-sq.fastq')),
                 (ph.inFile('454-se-random-N100-nm400-ne40-s0-sq.fastq.sam'),
                  ph.outFile('454-se-random-N100-nm400-ne40-s0-sq.fastq.sam')),
                 (ph.inFile('454-se-random-N100-nm400-ne40-s0-sq.stdout'),
                  ph.outFile('454-se-random-N100-nm400-ne40-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('454-se-random-N100-nm200-ne20-s0.stdout'),
        args=['454', '-N', '100', '-nm', '200', '-ne', '20', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('454-se-random-N100-nm200-ne20-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('454-se-random-N100-nm200-ne20-s0.fasta'),
                  ph.outFile('454-se-random-N100-nm200-ne20-s0.fasta')),
                 (ph.inFile('454-se-random-N100-nm200-ne20-s0.fasta.sam'),
                  ph.outFile('454-se-random-N100-nm200-ne20-s0.fasta.sam')),
                 (ph.inFile('454-se-random-N100-nm200-ne20-s0.stdout'),
                  ph.outFile('454-se-random-N100-nm200-ne20-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('454-se-random-N100-nm200-ne20-s0-sq.stdout'),
        args=['454', '-N', '100', '-nm', '200', '-ne', '20', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('454-se-random-N100-nm200-ne20-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('454-se-random-N100-nm200-ne20-s0-sq.fastq'),
                  ph.outFile('454-se-random-N100-nm200-ne20-s0-sq.fastq')),
                 (ph.inFile('454-se-random-N100-nm200-ne20-s0-sq.fastq.sam'),
                  ph.outFile('454-se-random-N100-nm200-ne20-s0-sq.fastq.sam')),
                 (ph.inFile('454-se-random-N100-nm200-ne20-s0-sq.stdout'),
                  ph.outFile('454-se-random-N100-nm200-ne20-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    # ============================================================
    # Run Illumina Reads, Single-End
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-random-N100-n36-s0.stdout'),
        args=['illumina', '-N', '100', '-n', '36', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-random-N100-n36-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-se-random-N100-n36-s0.fasta'),
                  ph.outFile('illumina-se-random-N100-n36-s0.fasta')),
                 (ph.inFile('illumina-se-random-N100-n36-s0.fasta.sam'),
                  ph.outFile('illumina-se-random-N100-n36-s0.fasta.sam')),
                 (ph.inFile('illumina-se-random-N100-n36-s0.stdout'),
                  ph.outFile('illumina-se-random-N100-n36-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-random-N100-n36-s0-sq.stdout'),
        args=['illumina', '-N', '100', '-n', '36', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-random-N100-n36-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-se-random-N100-n36-s0-sq.fastq'),
                  ph.outFile('illumina-se-random-N100-n36-s0-sq.fastq')),
                 (ph.inFile('illumina-se-random-N100-n36-s0-sq.fastq.sam'),
                  ph.outFile('illumina-se-random-N100-n36-s0-sq.fastq.sam')),
                 (ph.inFile('illumina-se-random-N100-n36-s0-sq.stdout'),
                  ph.outFile('illumina-se-random-N100-n36-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-random-N100-n100-s0.stdout'),
        args=['illumina', '-N', '100', '-n', '100', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-random-N100-n100-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-se-random-N100-n100-s0.fasta'),
                  ph.outFile('illumina-se-random-N100-n100-s0.fasta')),
                 (ph.inFile('illumina-se-random-N100-n100-s0.fasta.sam'),
                  ph.outFile('illumina-se-random-N100-n100-s0.fasta.sam')),
                 (ph.inFile('illumina-se-random-N100-n100-s0.stdout'),
                  ph.outFile('illumina-se-random-N100-n100-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-random-N100-n100-s0-sq.stdout'),
        args=['illumina', '-N', '100', '-n', '100', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-random-N100-n100-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-se-random-N100-n100-s0-sq.fastq'),
                  ph.outFile('illumina-se-random-N100-n100-s0-sq.fastq')),
                 (ph.inFile('illumina-se-random-N100-n100-s0-sq.fastq.sam'),
                  ph.outFile('illumina-se-random-N100-n100-s0-sq.fastq.sam')),
                 (ph.inFile('illumina-se-random-N100-n100-s0-sq.stdout'),
                  ph.outFile('illumina-se-random-N100-n100-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    # ============================================================
    # Run Illumina Reads, Single-End, Existing Contig
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-adeno-N100-n36-s0.stdout'),
        args=['illumina', '-N', '100', '-n', '36', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-adeno-N100-n36-s0.fasta'),
              ph.inFile('adeno-genome.fa')],
        to_diff=[(ph.inFile('illumina-se-adeno-N100-n36-s0.fasta'),
                  ph.outFile('illumina-se-adeno-N100-n36-s0.fasta')),
                 (ph.inFile('illumina-se-adeno-N100-n36-s0.fasta.sam'),
                  ph.outFile('illumina-se-adeno-N100-n36-s0.fasta.sam')),
                 (ph.inFile('illumina-se-adeno-N100-n36-s0.stdout'),
                  ph.outFile('illumina-se-adeno-N100-n36-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-adeno-N100-n36-s0-sq.stdout'),
        args=['illumina', '-N', '100', '-n', '36', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-adeno-N100-n36-s0-sq.fastq'),
              ph.inFile('adeno-genome.fa')],
        to_diff=[(ph.inFile('illumina-se-adeno-N100-n36-s0-sq.fastq'),
                  ph.outFile('illumina-se-adeno-N100-n36-s0-sq.fastq')),
                 (ph.inFile('illumina-se-adeno-N100-n36-s0-sq.fastq.sam'),
                  ph.outFile('illumina-se-adeno-N100-n36-s0-sq.fastq.sam')),
                 (ph.inFile('illumina-se-adeno-N100-n36-s0-sq.stdout'),
                  ph.outFile('illumina-se-adeno-N100-n36-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-adeno-N100-n100-s0.stdout'),
        args=['illumina', '-N', '100', '-n', '100', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-adeno-N100-n100-s0.fasta'),
              ph.inFile('adeno-genome.fa')],
        to_diff=[(ph.inFile('illumina-se-adeno-N100-n100-s0.fasta'),
                  ph.outFile('illumina-se-adeno-N100-n100-s0.fasta')),
                 (ph.inFile('illumina-se-adeno-N100-n100-s0.fasta.sam'),
                  ph.outFile('illumina-se-adeno-N100-n100-s0.fasta.sam')),
                 (ph.inFile('illumina-se-adeno-N100-n100-s0.stdout'),
                  ph.outFile('illumina-se-adeno-N100-n100-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-se-adeno-N100-n100-s0-sq.stdout'),
        args=['illumina', '-N', '100', '-n', '100', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('illumina-se-adeno-N100-n100-s0-sq.fastq'),
              ph.inFile('adeno-genome.fa')],
        to_diff=[(ph.inFile('illumina-se-adeno-N100-n100-s0-sq.fastq'),
                  ph.outFile('illumina-se-adeno-N100-n100-s0-sq.fastq')),
                 (ph.inFile('illumina-se-adeno-N100-n100-s0-sq.fastq.sam'),
                  ph.outFile('illumina-se-adeno-N100-n100-s0-sq.fastq.sam')),
                 (ph.inFile('illumina-se-adeno-N100-n100-s0-sq.stdout'),
                  ph.outFile('illumina-se-adeno-N100-n100-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    # ============================================================
    # Run Illumina Reads, Paired-End
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-pe-random-N100-n36-s0.stdout'),
        args=['illumina', '-mp', '-N', '100', '-n', '36', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('illumina-pe-random-N100-n36-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-pe-random-N100-n36-s0_1.fasta'),
                  ph.outFile('illumina-pe-random-N100-n36-s0_1.fasta')),
                 (ph.inFile('illumina-pe-random-N100-n36-s0_2.fasta'),
                  ph.outFile('illumina-pe-random-N100-n36-s0_2.fasta')),
                 (ph.inFile('illumina-pe-random-N100-n36-s0.fasta.sam'),
                  ph.outFile('illumina-pe-random-N100-n36-s0.fasta.sam')),
                 (ph.inFile('illumina-pe-random-N100-n36-s0.stdout'),
                  ph.outFile('illumina-pe-random-N100-n36-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-pe-random-N100-n36-s0-sq.stdout'),
        args=['illumina', '-mp', '-N', '100', '-n', '36', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('illumina-pe-random-N100-n36-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-pe-random-N100-n36-s0-sq_1.fastq'),
                  ph.outFile('illumina-pe-random-N100-n36-s0-sq_1.fastq')),
                 (ph.inFile('illumina-pe-random-N100-n36-s0-sq_2.fastq'),
                  ph.outFile('illumina-pe-random-N100-n36-s0-sq_2.fastq')),
                 (ph.inFile('illumina-pe-random-N100-n36-s0-sq.fastq.sam'),
                  ph.outFile('illumina-pe-random-N100-n36-s0-sq.fastq.sam')),
                 (ph.inFile('illumina-pe-random-N100-n36-s0-sq.stdout'),
                  ph.outFile('illumina-pe-random-N100-n36-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-pe-random-N100-n100-s0.stdout'),
        args=['illumina', '-mp', '-N', '100', '-n', '100', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('illumina-pe-random-N100-n100-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-pe-random-N100-n100-s0_1.fasta'),
                  ph.outFile('illumina-pe-random-N100-n100-s0_1.fasta')),
                 (ph.inFile('illumina-pe-random-N100-n100-s0_2.fasta'),
                  ph.outFile('illumina-pe-random-N100-n100-s0_2.fasta')),
                 (ph.inFile('illumina-pe-random-N100-n100-s0.fasta.sam'),
                  ph.outFile('illumina-pe-random-N100-n100-s0.fasta.sam')),
                 (ph.inFile('illumina-pe-random-N100-n100-s0.stdout'),
                  ph.outFile('illumina-pe-random-N100-n100-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('illumina-pe-random-N100-n100-s0-sq.stdout'),
        args=['illumina', '-mp', '-N', '100', '-n', '100', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('illumina-pe-random-N100-n100-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('illumina-pe-random-N100-n100-s0-sq_1.fastq'),
                  ph.outFile('illumina-pe-random-N100-n100-s0-sq_1.fastq')),
                 (ph.inFile('illumina-pe-random-N100-n100-s0-sq_2.fastq'),
                  ph.outFile('illumina-pe-random-N100-n100-s0-sq_2.fastq')),
                 (ph.inFile('illumina-pe-random-N100-n100-s0-sq.fastq.sam'),
                  ph.outFile('illumina-pe-random-N100-n100-s0-sq.fastq.sam')),
                 (ph.inFile('illumina-pe-random-N100-n100-s0-sq.stdout'),
                  ph.outFile('illumina-pe-random-N100-n100-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    # ============================================================
    # Run Sanger Reads, Single-End
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('sanger-se-random-N100-nm400-ne40-s0.stdout'),
        args=['sanger', '-N', '100', '-nm', '400', '-ne', '40', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('sanger-se-random-N100-nm400-ne40-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('sanger-se-random-N100-nm400-ne40-s0.fasta'),
                  ph.outFile('sanger-se-random-N100-nm400-ne40-s0.fasta')),
                 (ph.inFile('sanger-se-random-N100-nm400-ne40-s0.fasta.sam'),
                  ph.outFile('sanger-se-random-N100-nm400-ne40-s0.fasta.sam')),
                 (ph.inFile('sanger-se-random-N100-nm400-ne40-s0.stdout'),
                  ph.outFile('sanger-se-random-N100-nm400-ne40-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('sanger-se-random-N100-nm400-ne40-s0-sq.stdout'),
        args=['sanger', '-N', '100', '-nm', '400', '-ne', '40', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('sanger-se-random-N100-nm400-ne40-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('sanger-se-random-N100-nm400-ne40-s0-sq.fastq'),
                  ph.outFile('sanger-se-random-N100-nm400-ne40-s0-sq.fastq')),
                 (ph.inFile('sanger-se-random-N100-nm400-ne40-s0-sq.fastq.sam'),
                  ph.outFile('sanger-se-random-N100-nm400-ne40-s0-sq.fastq.sam')),
                 (ph.inFile('sanger-se-random-N100-nm400-ne40-s0-sq.stdout'),
                  ph.outFile('sanger-se-random-N100-nm400-ne40-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('sanger-se-random-N100-nm200-ne20-s0.stdout'),
        args=['sanger', '-N', '100', '-nm', '200', '-ne', '20', '-s', '0', '-rnp', 'read',
              '-o', ph.outFile('sanger-se-random-N100-nm200-ne20-s0.fasta'),
              'random.fasta'],
        to_diff=[(ph.inFile('sanger-se-random-N100-nm200-ne20-s0.fasta'),
                  ph.outFile('sanger-se-random-N100-nm200-ne20-s0.fasta')),
                 (ph.inFile('sanger-se-random-N100-nm200-ne20-s0.fasta.sam'),
                  ph.outFile('sanger-se-random-N100-nm200-ne20-s0.fasta.sam')),
                 (ph.inFile('sanger-se-random-N100-nm200-ne20-s0.stdout'),
                  ph.outFile('sanger-se-random-N100-nm200-ne20-s0.stdout'),
                             transforms)])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('sanger-se-random-N100-nm200-ne20-s0-sq.stdout'),
        args=['sanger', '-N', '100', '-nm', '200', '-ne', '20', '-s', '0', '-sq', '-rnp', 'read',
              '-o', ph.outFile('sanger-se-random-N100-nm200-ne20-s0-sq.fastq'),
              'random.fasta'],
        to_diff=[(ph.inFile('sanger-se-random-N100-nm200-ne20-s0-sq.fastq'),
                  ph.outFile('sanger-se-random-N100-nm200-ne20-s0-sq.fastq')),
                 (ph.inFile('sanger-se-random-N100-nm200-ne20-s0-sq.fastq.sam'),
                  ph.outFile('sanger-se-random-N100-nm200-ne20-s0-sq.fastq.sam')),
                 (ph.inFile('sanger-se-random-N100-nm200-ne20-s0-sq.stdout'),
                  ph.outFile('sanger-se-random-N100-nm200-ne20-s0-sq.stdout'),
                             transforms)])
    conf_list.append(conf)

    # Execute the tests.
    failures = 0
    for conf in conf_list:
        print ' '.join(['mason'] + conf.args),
        sys.stdout.flush()
        res = app_tests.runTest(conf)
        # Output to the user.
        print ' '.join(['mason'] + 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
Example #33
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, "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, "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
Example #34
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

    path_to_indexer = app_tests.autolocateBinary(
      binary_base, 'bin', 'yara_indexer')

    path_to_mapper = app_tests.autolocateBinary(
      binary_base, 'bin', 'yara_mapper')

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run Indexer Tests
    # ============================================================

    for organism in ['adeno']:

        # Get file extensions for the fm index files
        exts = [os.path.basename(fname).split('.', 1)[-1]
                for fname in glob.glob(ph.inFile('gold/%s-genome.*' % organism))]

        conf = app_tests.TestConf(
            program=path_to_indexer,
            args=[ph.inFile('input/%s-genome.fa' % organism),
                  '-o', ph.outFile('%s-genome' % organism)],
            to_diff=[(ph.inFile('gold/%s-genome.%s' % (organism, ext)),
                     ph.outFile('%s-genome.%s' % (organism, ext)), 'md5') for ext in exts])
        conf_list.append(conf)

    # ============================================================
    # Run Single-End Mapper Tests
    # ============================================================

#    mapper_args = [
#                    ['--threads', '1' ]],
#                    ['--threads', '8' ]
#                  ]
#    mapper_suffix = ['t1', 't8']

    mapper_args = [[]]
    mapper_suffix = ['t1']

    for organism in ['adeno']:
        for i in range(0, len(mapper_args)):

            conf = app_tests.TestConf(
                program=path_to_mapper,
                args=[ph.inFile('gold/%s-genome' % organism),
                      ph.inFile('input/%s-reads_1.fa' % organism),
                      '-o', ph.outFile('%s-reads_1.%s.sam' % (organism, mapper_suffix[i]))] +
                      mapper_args[i],
                to_diff=[(ph.inFile('gold/%s-reads_1.%s.sam' % (organism, mapper_suffix[i])),
                          ph.outFile('%s-reads_1.%s.sam' % (organism, mapper_suffix[i])),
                          sam_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.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
Example #35
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
Example #36
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,
        'core/apps/snp_store/tests')  # tests dir

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

    path_to_program = app_tests.autolocateBinary(
      binary_base, 'core/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 = []

    # ============================================================
    # 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'),
              '-id', ph.outFile('indels_default.out'),
              '-o', ph.outFile('snps_default.out')],
        to_diff=[(ph.inFile('snp_store_default.stdout'),
                  ph.outFile('snp_store_default.stdout')),
#                 (ph.inFile('snps_default.out'),
#                  ph.outFile('snps_default.out')),
                 (ph.inFile('indels_default.out'),
                  ph.outFile('indels_default.out'))])
    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', '-if', str(1),
              '-id', ph.outFile('indels_realign.out'),
              '-o', ph.outFile('snps_realign.out')],
        to_diff=[(ph.inFile('snp_store_realign.stdout'),
                 ph.outFile('snp_store_realign.stdout')),
#                 (ph.inFile('snps_realign.out'),
#                  ph.outFile('snps_realign.out')),
                 (ph.inFile('indels_realign.out'),
                  ph.outFile('indels_realign.out'))])
    conf_list.append(conf)

    # test 3
    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.sam'),
              '-re', '-if', str(1), '-oa', '-hq', '-it', str(1), '-mp', str(1), '-m', str(1),
              '-id', ph.outFile('indels_realign_m0mp1oa.out'),
              '-o', ph.outFile('snps_realign_m0mp1oa.out')],
        to_diff=[(ph.inFile('snp_store_realign_m0mp1oa.stdout'),
                  ph.outFile('snp_store_realign_m0mp1oa.stdout')),
#                 (ph.inFile('snps_realign_m0mp1oa.out'),
#                  ph.outFile('snps_realign_m0mp1oa.out')),
                 (ph.inFile('indels_realign_m0mp1oa.out'),
                  ph.outFile('indels_realign_m0mp1oa.out'))])
    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
Example #37
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for dfi'
    print '======================'
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    paramsFile = open(ph.inFile("params.txt"), "r")

    # unzip datasets into test directory
    unzip_file_into_dir(ph.inFile("datasets.zip"), ph.outFile('', 'datasets'))
    unzip_file_into_dir(ph.inFile("results.zip"), ph.outFile('', 'expected'))

    # We run the following for all read lengths we have reads for.
    for paramLine in paramsFile.readlines():
        params = paramLine.split();
        # Run with options parsed from params file.
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile(params[0]),
            args=[ph.outFile(params[1], 'datasets'),
                  ph.outFile(params[2], 'datasets')] + params[3:],
            to_diff=[(ph.outFile(params[0], 'expected'),
                      ph.outFile(params[0]))])
        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(['dfi'] + 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
Example #38
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('out.stdout'),
        args=['-m', ph.inFile('ecoli.sam'), '-m', ph.inFile('ehec.sam'), '-r',
        ph.inFile('ecoli_0.50_ehec_0.50.fq'), '-rf', 'ecoli.fa', '-rf',
        'ehec.fa', '-o', ph.outFile('test_sam2matrix.tsv')],
        to_diff=[(ph.inFile('out.stdout'),
                  ph.outFile('out.stdout')),
                 (ph.inFile('gold.tsv'),
                  ph.outFile('test_sam2matrix.tsv'))])
    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(['sam2matrix'] + 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
Example #39
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,
        'apps/bs_tools/tests')  # tests dir

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

    path_to_bisar = app_tests.autolocateBinary(
      binary_base, 'apps/bs_tools', 'bisar')
    path_to_casbar = app_tests.autolocateBinary(
      binary_base, '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, '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

    if not (sys.platform.startswith('freebsd') or sys.platform.startswith('win')):
        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)
    else:
        print "One test not executed on FreeBSD, because of lower math precision."


    # ============================================================
    # Execute the tests.
    # ============================================================
    failures = 0
    for conf in conf_list:
        # Output to the user.
        print ' '.join([os.path.basename(conf.program)] + conf.args)
        res = app_tests.runTest(conf)
        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
Example #40
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
Example #41
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
Example #42
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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


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

        # test different min. match lengths
        for mml in range(16,26):
            # test different numbers of prefix errors
            for ep in range(0,2):
                # test different numbers of suffix errors
                for es in range(0,3):
                 
                    conf = app_tests.TestConf(
                        program=path_to_program,
                        redir_stdout=ph.outFile('se-adeno-reads%d_1_mml%d_ep%d_es%d.stdout' % (rl, mml, ep, es)),
                        args=['-sm', str(mml), '-ep', str(ep), '-es', str(es),
                              ph.inFile('adeno-genome.fa'),
                              ph.inFile('adeno-reads%d_1.fa' % rl),
                              '-o', ph.outFile('se-adeno-reads%d_1_mml%d_ep%d_es%d.out' % (rl, mml, ep, es))],
                        to_diff=[(ph.inFile('se-adeno-reads%d_1_mml%d_ep%d_es%d.out' % (rl, mml, ep, es)),
                                  ph.outFile('se-adeno-reads%d_1_mml%d_ep%d_es%d.out' % (rl, mml, ep, es))),
                                 (ph.inFile('se-adeno-reads%d_1_mml%d_ep%d_es%d.stdout' % (rl, mml, ep, es)),
                                  ph.outFile('se-adeno-reads%d_1_mml%d_ep%d_es%d.stdout' % (rl, mml, ep, es)))])
                    conf_list.append(conf)
                 
#                    # Allow indels.
#                    conf = app_tests.TestConf(
#                        program=path_to_program,
#                        redir_stdout=ph.outFile('se-adeno-reads%d_1_mml%d-id_ep%d_es%d.stdout' % (rl, mml, ep, es)),
#                        args=['-id', '-sm', str(mml), '-ep', str(ep), '-es', str(es),
#                              ph.inFile('adeno-genome.fa'),
#                              ph.inFile('adeno-reads%d_1.fa' % rl),
#                              '-o', ph.outFile('se-adeno-reads%d_1_mml%d-id_ep%d_es%d.out' % (rl, mml, ep, es))],
#                        to_diff=[(ph.inFile('se-adeno-reads%d_1_mml%d-id_ep%d_es%d.out' % (rl, mml, ep, es)),
#                                  ph.outFile('se-adeno-reads%d_1_mml%d-id_ep%d_es%d.out' % (rl, mml, ep, es))),
#                                 (ph.inFile('se-adeno-reads%d_1_mml%d-id_ep%d_es%d.stdout' % (rl, mml, ep, es)),
#                                  ph.outFile('se-adeno-reads%d_1_mml%d-id_ep%d_es%d.stdout' % (rl, mml, ep, es)))])
#                    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_mml20%s_ep1_es1.stdout' % (rl, o)),
                args=[ o, '-id', '-sm', str(20), '-ep', str(1), '-es', str(1),
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1_mml20%s_ep1_es1.out' % (rl, o))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1_mml20%s_ep1_es1.out' % (rl, o)),
                          ph.outFile('se-adeno-reads%d_1_mml20%s_ep1_es1.out' % (rl, o))),
                         (ph.inFile('se-adeno-reads%d_1_mml20%s_ep1_es1.stdout' % (rl, o)),
                          ph.outFile('se-adeno-reads%d_1_mml20%s_ep1_es1.stdout' % (rl, o)))])
            conf_list.append(conf)


        # Compute with different identity rates.
        for i in range(90, 100):
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('se-adeno-reads%d_1_mml20-i%d_ep1_es1.stdout' % (rl, i)),
                args=['-i', str(i), '-sm', str(20), '-ep', str(1), '-es', str(1),
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1_mml20-i%d_ep1_es1.out' % (rl, i))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1_mml20-i%d_ep1_es1.out' % (rl, i)),
                          ph.outFile('se-adeno-reads%d_1_mml20-i%d_ep1_es1.out' % (rl, i))),
                         (ph.inFile('se-adeno-reads%d_1_mml20-i%d_ep1_es1.stdout' % (rl, i)),
                          ph.outFile('se-adeno-reads%d_1_mml20-i%d_ep1_es1.stdout' % (rl, i)))])
            conf_list.append(conf)

        # Compute with different output formats.
        for of in [3, 4]:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('se-adeno-reads%d_1_mml20-of%d_ep1_es1.stdout' % (rl, of)),
                args=['-of', str(of),  '-sm', str(20), '-ep', str(1), '-es', str(1),
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1_mml20-of%d_ep1_es1.out' % (rl, of))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1_mml20-of%d_ep1_es1.out' % (rl, of)),
                          ph.outFile('se-adeno-reads%d_1_mml20-of%d_ep1_es1.out' % (rl, of))),
                         (ph.inFile('se-adeno-reads%d_1_mml20-of%d_ep1_es1.stdout' % (rl, of)),
                          ph.outFile('se-adeno-reads%d_1_mml20-of%d_ep1_es1.stdout' % (rl, of)))])
            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_mml20-so%d_ep1_es1.stdout' % (rl, so)),
                args=[ '-so', str(so),  '-sm', str(20), '-ep', str(1), '-es', str(1),
                      ph.inFile('adeno-genome.fa'),
                      ph.inFile('adeno-reads%d_1.fa' % rl),
                      '-o', ph.outFile('se-adeno-reads%d_1_mml20-so%d_ep1_es1.out' % (rl, so))],
                to_diff=[(ph.inFile('se-adeno-reads%d_1_mml20-so%d_ep1_es1.out' % (rl, so)),
                          ph.outFile('se-adeno-reads%d_1_mml20-so%d_ep1_es1.out' % (rl, so))),
                         (ph.inFile('se-adeno-reads%d_1_mml20-so%d_ep1_es1.stdout' % (rl, so)),
                          ph.outFile('se-adeno-reads%d_1_mml20-so%d_ep1_es1.stdout' % (rl, so)))])
            conf_list.append(conf)

        # Run in default anchored mode
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('anchored_adeno_example%d.stdout' % rl),
            args=['-an',
                  ph.inFile('adeno-genome.fa'),
                  ph.inFile('adeno-reads-pe.sam'), # % rl),
                  '-o', ph.outFile('anchored_adeno_example%d.out' % rl),
                  '-ll', '300', '-le', '90'],
            to_diff=[(ph.inFile('anchored_adeno_example%d.out' % rl),
                      ph.outFile('anchored_adeno_example%d.out' % rl)),
                     (ph.inFile('anchored_adeno_example%d.stdout' % rl),
                      ph.outFile('anchored_adeno_example%d.stdout' % rl))])
        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(['splazers'] + 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
Example #43
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for insegt'
    print '========================='
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(program=path_to_program,
                              args=[
                                  '-ro',
                                  ph.outFile('default_readOutput.gff'), '-ao',
                                  ph.outFile('default_annoOutput.gff'), '-to',
                                  ph.outFile('default_tupleOutput.gff'),
                                  ph.inFile('alignments.sam'),
                                  ph.inFile('annotations.gff')
                              ],
                              to_diff=[(ph.inFile('default_annoOutput.gff'),
                                        ph.outFile('default_annoOutput.gff')),
                                       (ph.inFile('default_readOutput.gff'),
                                        ph.outFile('default_readOutput.gff')),
                                       (ph.inFile('default_tupleOutput.gff'),
                                        ph.outFile('default_tupleOutput.gff'))
                                       ])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[
            '-c',
            str(2), '-ro',
            ph.outFile('threshold-count2_readOutput.gff'), '-ao',
            ph.outFile('threshold-count2_annoOutput.gff'), '-to',
            ph.outFile('threshold-count2_tupleOutput.gff'),
            ph.inFile('alignments.sam'),
            ph.inFile('annotations.gff')
        ],
        to_diff=[(ph.inFile('threshold-count2_annoOutput.gff'),
                  ph.outFile('threshold-count2_annoOutput.gff')),
                 (ph.inFile('threshold-count2_readOutput.gff'),
                  ph.outFile('threshold-count2_readOutput.gff')),
                 (ph.inFile('threshold-count2_tupleOutput.gff'),
                  ph.outFile('threshold-count2_tupleOutput.gff'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(program=path_to_program,
                              args=[
                                  '-n',
                                  str(3), '-ro',
                                  ph.outFile('ntuple3_readOutput.gff'), '-ao',
                                  ph.outFile('ntuple3_annoOutput.gff'), '-to',
                                  ph.outFile('ntuple3_tupleOutput.gff'),
                                  ph.inFile('alignments.sam'),
                                  ph.inFile('annotations.gff')
                              ],
                              to_diff=[(ph.inFile('ntuple3_annoOutput.gff'),
                                        ph.outFile('ntuple3_annoOutput.gff')),
                                       (ph.inFile('ntuple3_readOutput.gff'),
                                        ph.outFile('ntuple3_readOutput.gff')),
                                       (ph.inFile('ntuple3_tupleOutput.gff'),
                                        ph.outFile('ntuple3_tupleOutput.gff'))
                                       ])
    conf_list.append(conf)

    conf = app_tests.TestConf(program=path_to_program,
                              args=[
                                  '-m', '-ro',
                                  ph.outFile('max-tuple_readOutput.gff'),
                                  '-ao',
                                  ph.outFile('max-tuple_annoOutput.gff'),
                                  '-to',
                                  ph.outFile('max-tuple_tupleOutput.gff'),
                                  ph.inFile('alignments.sam'),
                                  ph.inFile('annotations.gff')
                              ],
                              to_diff=[
                                  (ph.inFile('max-tuple_annoOutput.gff'),
                                   ph.outFile('max-tuple_annoOutput.gff')),
                                  (ph.inFile('max-tuple_readOutput.gff'),
                                   ph.outFile('max-tuple_readOutput.gff')),
                                  (ph.inFile('max-tuple_tupleOutput.gff'),
                                   ph.outFile('max-tuple_tupleOutput.gff'))
                              ])
    conf_list.append(conf)

    conf = app_tests.TestConf(program=path_to_program,
                              args=[
                                  '-e', '-ro',
                                  ph.outFile('exact-ntuple_readOutput.gff'),
                                  '-ao',
                                  ph.outFile('exact-ntuple_annoOutput.gff'),
                                  '-to',
                                  ph.outFile('exact-ntuple_tupleOutput.gff'),
                                  ph.inFile('alignments.sam'),
                                  ph.inFile('annotations.gff')
                              ],
                              to_diff=[
                                  (ph.inFile('exact-ntuple_annoOutput.gff'),
                                   ph.outFile('exact-ntuple_annoOutput.gff')),
                                  (ph.inFile('exact-ntuple_readOutput.gff'),
                                   ph.outFile('exact-ntuple_readOutput.gff')),
                                  (ph.inFile('exact-ntuple_tupleOutput.gff'),
                                   ph.outFile('exact-ntuple_tupleOutput.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(['insegt'] + 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
Example #44
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
Example #45
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,
        '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')

    libcpp = (os.environ.has_key('CC') and 'gcc' in os.environ["CC"]) or sys.platform == "linux" or sys.platform == "linux2"

    # ============================================================
    # 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/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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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),
                 ])
    if libcpp:
        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
Example #46
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for samcat'
    print '========================='
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run on DNA (Adenoviruses).
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[ph.inFile('ex1_a1.sam'),
              ph.inFile('ex1_a2.sam'),
              ph.inFile('ex1_a3.sam'),
              '-o', ph.outFile('ex1_merged.sam')],
        to_diff=[(ph.inFile('ex1_merged.sam'),
                  ph.outFile('ex1_merged.sam'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program,
        args=[ph.inFile('ex1_a1.sam'),
              ph.inFile('ex1_a2.sam'),
              ph.inFile('ex1_a3.sam'),
              '-o', ph.outFile('ex1_merged.bam')],
        to_diff=[(ph.inFile('ex1_merged.bam'),
                  ph.outFile('ex1_merged.bam'), "gunzip")])
    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
Example #47
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run on Proteins (Balibase).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.stdout' % fname),
            args=['-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.fa' % fname)],
            to_diff=[(ph.inFile('%s_out.fa' % fname),
                      ph.outFile('%s.fa' % fname)),
                     (ph.inFile('%s.stdout' % fname),
                      ph.outFile('%s.stdout' % fname))])
        conf_list.append(conf)

    # Run with explicit alphabet.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-a', 'protein',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.protein.fa' % fname)],
            redir_stdout=ph.outFile('%s.protein.stdout' % fname),
            to_diff=[(ph.inFile('%s.protein_out.fa' % fname),
                      ph.outFile('%s.protein.fa' % fname)),
                     (ph.inFile('%s.protein.stdout' % fname),
                      ph.outFile('%s.protein.stdout' % fname))])
        conf_list.append(conf)

    # Run with different alignment methods.
    for fname in ['1aab', '1ad2', '2trx']:
        for m in ['nw', 'gotoh', 'sw', 'lcs']:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('%s.m%s.stdout' % (fname, m)),
                args=['-m', m,
                      '-s', ph.inFile('%s.fa' % fname),
                      '-o', ph.outFile('%s.m%s.fa' % (fname, m))],
                to_diff=[(ph.inFile('%s.m%s_out.fa' % (fname, m)),
                          ph.outFile('%s.m%s.fa' % (fname, m))),
                         (ph.inFile('%s.m%s.stdout' % (fname, m)),
                          ph.outFile('%s.m%s.stdout' % (fname, m)))])
            conf_list.append(conf)

    # Run with different scoring options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.g-20.stdout' % fname),
            args=['-g', '-20',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.g-20.fa' % fname)],
            to_diff=[(ph.inFile('%s.g-20_out.fa' % fname),
                      ph.outFile('%s.g-20.fa' % fname)),
                     (ph.inFile('%s.g-20.stdout' % fname),
                      ph.outFile('%s.g-20.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.e-5.stdout' % fname),
            args=['-e', '-5',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.e-5.fa' % fname)],
            to_diff=[(ph.inFile('%s.e-5_out.fa' % fname),
                      ph.outFile('%s.e-5.fa' % fname)),
                     (ph.inFile('%s.e-5.stdout' % fname),
                      ph.outFile('%s.e-5.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.ms10.stdout' % fname),
            args=['-ms', '10',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.ms10.fa' % fname)],
            to_diff=[(ph.inFile('%s.ms10_out.fa' % fname),
                      ph.outFile('%s.ms10.fa' % fname)),
                     (ph.inFile('%s.ms10.stdout' % fname),
                      ph.outFile('%s.ms10.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.mm-8.stdout' % fname),
            args=['-mm', '-8',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.mm-8.fa' % fname)],
            to_diff=[(ph.inFile('%s.mm-8_out.fa' % fname),
                      ph.outFile('%s.mm-8.fa' % fname)),
                     (ph.inFile('%s.mm-8.stdout' % fname),
                      ph.outFile('%s.mm-8.stdout' % fname))])
        conf_list.append(conf)

    # Run with matrix file.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.maVTML200.stdout' % fname),
            args=['-ma', ph.inFile('VTML200I'),
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.maVTML200.fa' % fname)],
            to_diff=[(ph.inFile('%s.maVTML200_out.fa' % fname),
                      ph.outFile('%s.maVTML200.fa' % fname)),
                     (ph.inFile('%s.maVTML200.stdout' % fname),
                      ph.outFile('%s.maVTML200.stdout' % fname))])
        conf_list.append(conf)

    # Run with different banded alignment options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.lo5.stdout' % fname),
            args=['-lo', '5',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.lo5.fa' % fname)],
            to_diff=[(ph.inFile('%s.lo5_out.fa' % fname),
                      ph.outFile('%s.lo5.fa' % fname)),
                     (ph.inFile('%s.lo5.stdout' % fname),
                      ph.outFile('%s.lo5.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.hi5.stdout' % fname),
            args=['-hi', '5',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.hi5.fa' % fname)],
            to_diff=[(ph.inFile('%s.hi5_out.fa' % fname),
                      ph.outFile('%s.hi5.fa' % fname)),
                     (ph.inFile('%s.hi5.stdout' % fname),
                      ph.outFile('%s.hi5.stdout' % fname))])
        conf_list.append(conf)

    # Run with different matrix configuraiton options.
    for fname in ['1aab', '1ad2', '2trx']:
        for c in ['ffff', 'tttt', 'ffft', 'fftf', 'ftff', 'tfff', 'fftt',
                  'fttf', 'ttff', 'tfft']:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('%s.c%s.stdout' % (fname, c)),
                args=['-c', c,
                      '-s', ph.inFile('%s.fa' % fname),
                      '-o', ph.outFile('%s.c%s.fa' % (fname, c))],
                to_diff=[(ph.inFile('%s.c%s_out.fa' % (fname, c)),
                          ph.outFile('%s.c%s.fa' % (fname, c))),
                         (ph.inFile('%s.c%s.stdout' % (fname, c)),
                          ph.outFile('%s.c%s.stdout' % (fname, c)))])
            conf_list.append(conf)

    # ============================================================
    # Run on DNA (Adenoviruses).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [1, 2, 3]:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-a', 'dna',
                  '-s', ph.inFile('adeno%d.fa' % i),
                  '-o', ph.outFile('adeno%d.fa' % i)],
            to_diff=[(ph.inFile('adeno%d_out.fa' % i),
                      ph.outFile('adeno%d.fa' % i))])
        conf_list.append(conf)

    # ============================================================
    # Run on RNA.
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [1, 2, 3]:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-a', 'rna',
                  '-s', ph.inFile('adeno%d-rna.fa' % i),
                  '-o', ph.outFile('adeno%d-rna.fa' % i)],
            to_diff=[(ph.inFile('adeno%d-rna_out.fa' % i),
                      ph.outFile('adeno%d-rna.fa' % i))])
        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(['pair_align'] + 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
Example #48
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    if platform.machine().startswith('mips') or platform.machine().startswith('s390'):
        print 'Skipping tests for seqan_tcoffee on mips* and s390*'
        print '==================================================='
        return 0

    print 'Executing test for seqan_tcoffee'
    print '================================'
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run on Proteins (Balibase).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.fasta' % fname)],
            to_diff=[(ph.inFile('%s.fasta' % fname),
                      ph.outFile('%s.fasta' % fname))])
        conf_list.append(conf)

    # Run with explicit alphabet.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-a', 'protein',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.protein.fasta' % fname)],
            to_diff=[(ph.inFile('%s.protein.fasta' % fname),
                      ph.outFile('%s.protein.fasta' % fname))])
        conf_list.append(conf)

        # Run with different segment match generation options.  We run
    # with with single values and combinations of neighbours
    for fname in ['1aab', '1ad2', '2trx']:
        
        for m in ['global', 'local', 'overlap', 'lcs']:
            conf = app_tests.TestConf(
                program=path_to_program,
                args=['-m', m,
                      '-s', ph.inFile('%s.fa' % fname),
                      '-o', ph.outFile('%s.m%s.fasta' % (fname, m))],
                to_diff=[(ph.inFile('%s.m%s.fasta' % (fname, m)),
                          ph.outFile('%s.m%s.fasta' % (fname, m)))])
            conf_list.append(conf)
        m1 = 'global'
        m2 = 'local'
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-m', m1,
                  '-m', m2,
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])
        conf_list.append(conf)
        m1 = 'local'
        m2 = 'overlap'
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-m', m1,
                  '-m', m2,
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])
        conf_list.append(conf)
        
        m1 = 'overlap'
        m2 = 'lcs'
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-m', m1,
                  '-m', m2,
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])
        m1 = 'global'
        m2 = 'lcs'        
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-m', m1,
                  '-m', m2,
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2))],
            to_diff=[(ph.inFile('%s.m%s.m%s.fasta' % (fname, m1, m2)),
                      ph.outFile('%s.m%s.m%s.fasta' % (fname, m1, m2)))])

    # Run with different match files variations.
    # TODO

    # Run with different scoring options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-g', '-20',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.g-20.fasta' % fname)],
            to_diff=[(ph.inFile('%s.g-20.fasta' % fname),
                      ph.outFile('%s.g-20.fasta' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-e', '-5',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.e-5.fasta' % fname)],
            to_diff=[(ph.inFile('%s.e-5.fasta' % fname),
                      ph.outFile('%s.e-5.fasta' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-ms', '10',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.ms10.fasta' % fname)],
            to_diff=[(ph.inFile('%s.ms10.fasta' % fname),
                      ph.outFile('%s.ms10.fasta' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-mm', '-8',
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.mm-8.fasta' % fname)],
            to_diff=[(ph.inFile('%s.mm-8.fasta' % fname),
                      ph.outFile('%s.mm-8.fasta' % fname))])
        conf_list.append(conf)

    # Run with matrix file.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-ma', ph.inFile('VTML200I'),
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.maVTML200.fasta' % fname)],
            to_diff=[(ph.inFile('%s.maVTML200.fasta' % fname),
                      ph.outFile('%s.maVTML200.fasta' % fname))])
        conf_list.append(conf)

    # Run with manual guide tree.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-u', ph.inFile('%s.newick' % fname),
                  '-s', ph.inFile('%s.fa' % fname),
                  '-o', ph.outFile('%s.u.fasta' % fname)],
            to_diff=[(ph.inFile('%s.u.fasta' % fname),
                      ph.outFile('%s.u.fasta' % fname))])
        conf_list.append(conf)

    # Run with different guide tree building options.
    for fname in ['1aab', '1ad2', '2trx']:
        for b in ['nj', 'min', 'max', 'avg', 'wavg']:
            conf = app_tests.TestConf(
                program=path_to_program,
                args=['-b', b,
                      '-s', ph.inFile('%s.fa' % fname),
                      '-o', ph.outFile('%s.b%s.fasta' % (fname, b))],
                to_diff=[(ph.inFile('%s.b%s.fasta' % (fname, b)),
                          ph.outFile('%s.b%s.fasta' % (fname, b)))])
            conf_list.append(conf)

    # Run alignment evaluation.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-i', ph.inFile('%s.fasta' % fname)],
            redir_stdout=ph.outFile('%s.i.fasta' % fname),
            to_diff=[(ph.inFile('%s.i.fasta' % fname),
                      ph.outFile('%s.i.fasta' % fname))])
        conf_list.append(conf)

    # ============================================================
    # Run on DNA (Adenoviruses).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [2, 3, 4]:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-a', 'dna',
                  '-s', ph.inFile('adeno%d.fa' % i),
                  '-o', ph.outFile('adeno%d.fasta' % i)],
            to_diff=[(ph.inFile('adeno%d.fasta' % i),
                      ph.outFile('adeno%d.fasta' % i))])
        conf_list.append(conf)

    # ============================================================
    # Run on RNA.
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [2, 3, 4]:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=['-a', 'rna',
                  '-s', ph.inFile('adeno%d-rna.fa' % i),
                  '-o', ph.outFile('adeno%d-rna.fasta' % i)],
            to_diff=[(ph.inFile('adeno%d-rna.fasta' % i),
                      ph.outFile('adeno%d-rna.fasta' % i))])
        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(['seqan_tcoffee'] + 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
Example #49
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run on Proteins (Balibase).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(program=path_to_program,
                                  redir_stdout=ph.outFile('%s.stdout' % fname),
                                  args=[
                                      '-s',
                                      ph.inFile('%s.fa' % fname), '-o',
                                      ph.outFile('%s.fa' % fname)
                                  ],
                                  to_diff=[(ph.inFile('%s_out.fa' % fname),
                                            ph.outFile('%s.fa' % fname)),
                                           (ph.inFile('%s.stdout' % fname),
                                            ph.outFile('%s.stdout' % fname))])
        conf_list.append(conf)

    # Run with explicit alphabet.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            args=[
                '-a', 'protein', '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.protein.fa' % fname)
            ],
            redir_stdout=ph.outFile('%s.protein.stdout' % fname),
            to_diff=[(ph.inFile('%s.protein_out.fa' % fname),
                      ph.outFile('%s.protein.fa' % fname)),
                     (ph.inFile('%s.protein.stdout' % fname),
                      ph.outFile('%s.protein.stdout' % fname))])
        conf_list.append(conf)

    # Run with different alignment methods.
    for fname in ['1aab', '1ad2', '2trx']:
        for m in ['nw', 'gotoh', 'sw', 'lcs']:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('%s.m%s.stdout' % (fname, m)),
                args=[
                    '-m', m, '-s',
                    ph.inFile('%s.fa' % fname), '-o',
                    ph.outFile('%s.m%s.fa' % (fname, m))
                ],
                to_diff=[(ph.inFile('%s.m%s_out.fa' % (fname, m)),
                          ph.outFile('%s.m%s.fa' % (fname, m))),
                         (ph.inFile('%s.m%s.stdout' % (fname, m)),
                          ph.outFile('%s.m%s.stdout' % (fname, m)))])
            conf_list.append(conf)

    # Run with different scoring options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.g-20.stdout' % fname),
            args=[
                '-g', '-20', '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.g-20.fa' % fname)
            ],
            to_diff=[(ph.inFile('%s.g-20_out.fa' % fname),
                      ph.outFile('%s.g-20.fa' % fname)),
                     (ph.inFile('%s.g-20.stdout' % fname),
                      ph.outFile('%s.g-20.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.e-5.stdout' % fname),
            args=[
                '-e', '-5', '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.e-5.fa' % fname)
            ],
            to_diff=[(ph.inFile('%s.e-5_out.fa' % fname),
                      ph.outFile('%s.e-5.fa' % fname)),
                     (ph.inFile('%s.e-5.stdout' % fname),
                      ph.outFile('%s.e-5.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.ms10.stdout' % fname),
            args=[
                '-ms', '10', '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.ms10.fa' % fname)
            ],
            to_diff=[(ph.inFile('%s.ms10_out.fa' % fname),
                      ph.outFile('%s.ms10.fa' % fname)),
                     (ph.inFile('%s.ms10.stdout' % fname),
                      ph.outFile('%s.ms10.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.mm-8.stdout' % fname),
            args=[
                '-mm', '-8', '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.mm-8.fa' % fname)
            ],
            to_diff=[(ph.inFile('%s.mm-8_out.fa' % fname),
                      ph.outFile('%s.mm-8.fa' % fname)),
                     (ph.inFile('%s.mm-8.stdout' % fname),
                      ph.outFile('%s.mm-8.stdout' % fname))])
        conf_list.append(conf)

    # Run with matrix file.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.maVTML200.stdout' % fname),
            args=[
                '-ma',
                ph.inFile('VTML200I'), '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.maVTML200.fa' % fname)
            ],
            to_diff=[(ph.inFile('%s.maVTML200_out.fa' % fname),
                      ph.outFile('%s.maVTML200.fa' % fname)),
                     (ph.inFile('%s.maVTML200.stdout' % fname),
                      ph.outFile('%s.maVTML200.stdout' % fname))])
        conf_list.append(conf)

    # Run with different banded alignment options.
    for fname in ['1aab', '1ad2', '2trx']:
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.lo5.stdout' % fname),
            args=[
                '-lo', '5', '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.lo5.fa' % fname)
            ],
            to_diff=[(ph.inFile('%s.lo5_out.fa' % fname),
                      ph.outFile('%s.lo5.fa' % fname)),
                     (ph.inFile('%s.lo5.stdout' % fname),
                      ph.outFile('%s.lo5.stdout' % fname))])
        conf_list.append(conf)
        conf = app_tests.TestConf(
            program=path_to_program,
            redir_stdout=ph.outFile('%s.hi5.stdout' % fname),
            args=[
                '-hi', '5', '-s',
                ph.inFile('%s.fa' % fname), '-o',
                ph.outFile('%s.hi5.fa' % fname)
            ],
            to_diff=[(ph.inFile('%s.hi5_out.fa' % fname),
                      ph.outFile('%s.hi5.fa' % fname)),
                     (ph.inFile('%s.hi5.stdout' % fname),
                      ph.outFile('%s.hi5.stdout' % fname))])
        conf_list.append(conf)

    # Run with different matrix configuraiton options.
    for fname in ['1aab', '1ad2', '2trx']:
        for c in [
                'ffff', 'tttt', 'ffft', 'fftf', 'ftff', 'tfff', 'fftt', 'fttf',
                'ttff', 'tfft'
        ]:
            conf = app_tests.TestConf(
                program=path_to_program,
                redir_stdout=ph.outFile('%s.c%s.stdout' % (fname, c)),
                args=[
                    '-c', c, '-s',
                    ph.inFile('%s.fa' % fname), '-o',
                    ph.outFile('%s.c%s.fa' % (fname, c))
                ],
                to_diff=[(ph.inFile('%s.c%s_out.fa' % (fname, c)),
                          ph.outFile('%s.c%s.fa' % (fname, c))),
                         (ph.inFile('%s.c%s.stdout' % (fname, c)),
                          ph.outFile('%s.c%s.stdout' % (fname, c)))])
            conf_list.append(conf)

    # ============================================================
    # Run on DNA (Adenoviruses).
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [1, 2, 3]:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-a', 'dna', '-s',
                                      ph.inFile('adeno%d.fa' % i), '-o',
                                      ph.outFile('adeno%d.fa' % i)
                                  ],
                                  to_diff=[(ph.inFile('adeno%d_out.fa' % i),
                                            ph.outFile('adeno%d.fa' % i))])
        conf_list.append(conf)

    # ============================================================
    # Run on RNA.
    # ============================================================

    # Run with defaults for all non-mandatory options.
    for i in [1, 2, 3]:
        conf = app_tests.TestConf(program=path_to_program,
                                  args=[
                                      '-a', 'rna', '-s',
                                      ph.inFile('adeno%d-rna.fa' % i), '-o',
                                      ph.outFile('adeno%d-rna.fa' % i)
                                  ],
                                  to_diff=[
                                      (ph.inFile('adeno%d-rna_out.fa' % i),
                                       ph.outFile('adeno%d-rna.fa' % i))
                                  ])
        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(['pair_align'] + 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
Example #50
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for breakpoint_calculator'
    print '========================='
    print

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

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

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

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Run breakpoint_calculator
    # ============================================================

    # pairwise counts, xmfa format
    conf = app_tests.TestConf(program=path_to_program,
                              redir_stdout=ph.outFile('d2_xmfa.stdout'),
                              args=['-d2', ph.inFile('alignment.xmfa')],
                              to_diff=[(ph.inFile('d2_xmfa.stdout'),
                                        ph.outFile('d2_xmfa.stdout'))])
    conf_list.append(conf)

    # pairwise counts, maf format, detailed list of all pairs
    conf = app_tests.TestConf(program=path_to_program,
                              redir_stdout=ph.outFile('d2_maf.stdout'),
                              args=['-d2', '-d',
                                    ph.inFile('alignment.maf')],
                              to_diff=[(ph.inFile('d2_maf.stdout'),
                                        ph.outFile('d2_maf.stdout'))])
    conf_list.append(conf)

    # threeway counts, xmfa format, format directly specified
    conf = app_tests.TestConf(
        program=path_to_program,
        redir_stdout=ph.outFile('d3_xmfa.stdout'),
        args=['-d3', '-f', 'xmfa',
              ph.inFile('alignment.xmfa')],
        to_diff=[(ph.inFile('d3_xmfa.stdout'), ph.outFile('d3_xmfa.stdout'))])
    conf_list.append(conf)

    # threeway counts, maf format, detailed list of all triplets
    conf = app_tests.TestConf(program=path_to_program,
                              redir_stdout=ph.outFile('d3_maf.stdout'),
                              args=['-d3', '-d',
                                    ph.inFile('alignment.maf')],
                              to_diff=[(ph.inFile('d3_maf.stdout'),
                                        ph.outFile('d3_maf.stdout'))])
    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(['breakpoint_calculator'] + 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
Example #51
0
def main(source_base, binary_base):
    """Main entry point of the script."""

    print 'Executing test for rabema'
    print '========================='
    print

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

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

    path_to_prepare = app_tests.autolocateBinary(binary_base, 'apps/rabema',
                                                 'rabema_prepare_sam')
    path_to_build = app_tests.autolocateBinary(binary_base, 'apps/rabema',
                                               'rabema_build_gold_standard')
    path_to_evaluate = app_tests.autolocateBinary(binary_base, 'apps/rabema',
                                                  'rabema_evaluate')

    # ============================================================
    # Copy Files To Temp Dir.
    # ============================================================

    # We copy over the genome because an FAI file will be created.
    shutil.copyfile(ph.inFile('adeno-genome.fa'),
                    ph.outFile('adeno-genome.fa'))

    # ============================================================
    # Build TestConf list.
    # ============================================================

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

    # ============================================================
    # Prepare SAM
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_prepare,
        args=[
            '-i',
            ph.inFile('gold-adeno-hamming-08.sam'), '-o',
            ph.outFile('gold-adeno-hamming-08.by_qname.sam')
        ],
        to_diff=[(ph.inFile('gold-adeno-hamming-08.by_qname.sam'),
                  ph.outFile('gold-adeno-hamming-08.by_qname.sam'))])
    conf_list.append(conf)
    conf = app_tests.TestConf(
        program=path_to_prepare,
        args=[
            '-i',
            ph.inFile('gold-adeno-edit-08.sam'), '-o',
            ph.outFile('gold-adeno-edit-08.by_qname.sam')
        ],
        to_diff=[(ph.inFile('gold-adeno-edit-08.by_qname.sam'),
                  ph.outFile('gold-adeno-edit-08.by_qname.sam'))])
    conf_list.append(conf)

    # ============================================================
    # Build Gold Standard
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_build,
        redir_stdout=ph.outFile('gold-adeno-hamming-08.stdout'),
        args=[
            '--distance-metric', 'hamming', '-e', '8', '-o',
            ph.outFile('gold-adeno-hamming-08.gsi'), '--reference',
            ph.outFile('adeno-genome.fa'), '--in-bam',
            ph.inFile('gold-adeno-hamming-08.by_coordinate.sam')
        ],
        to_diff=[(ph.inFile('gold-adeno-hamming-08.stdout'),
                  ph.outFile('gold-adeno-hamming-08.stdout')),
                 (ph.inFile('gold-adeno-hamming-08.gsi'),
                  ph.outFile('gold-adeno-hamming-08.gsi'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_build,
        redir_stdout=ph.outFile('gold-adeno-edit-08.stdout'),
        args=[
            '--distance-metric', 'edit', '-e', '8', '-o',
            ph.outFile('gold-adeno-edit-08.gsi'), '--reference',
            ph.outFile('adeno-genome.fa'), '--in-bam',
            ph.inFile('gold-adeno-edit-08.by_coordinate.sam')
        ],
        to_diff=[(ph.inFile('gold-adeno-edit-08.stdout'),
                  ph.outFile('gold-adeno-edit-08.stdout')),
                 (ph.inFile('gold-adeno-edit-08.gsi'),
                  ph.outFile('gold-adeno-edit-08.gsi'))])
    conf_list.append(conf)

    # ============================================================
    # Compare.
    # ============================================================

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-hamming-08.stdout'),
        args=[
            '--distance-metric', 'hamming', '-e', '8', '--reference',
            ph.outFile('adeno-genome.fa'), '--in-bam',
            ph.inFile('razers2-adeno-hamming-08.sam'), '--in-gsi',
            ph.inFile('gold-adeno-hamming-08.gsi')
        ],
        to_diff=[(ph.inFile('razers2-adeno-hamming-08.stdout'),
                  ph.outFile('razers2-adeno-hamming-08.stdout'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-hamming-04.stdout'),
        args=[
            '--distance-metric', 'hamming', '-e', '8', '--reference',
            ph.outFile('adeno-genome.fa'), '--in-bam',
            ph.inFile('razers2-adeno-hamming-04.sam'), '--in-gsi',
            ph.inFile('gold-adeno-hamming-08.gsi')
        ],
        to_diff=[(ph.inFile('razers2-adeno-hamming-04.stdout'),
                  ph.outFile('razers2-adeno-hamming-04.stdout'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-edit-08.stdout'),
        args=[
            '--distance-metric', 'edit', '-e', '8', '--reference',
            ph.outFile('adeno-genome.fa'), '--in-bam',
            ph.inFile('razers2-adeno-edit-08.sam'), '--in-gsi',
            ph.inFile('gold-adeno-edit-08.gsi')
        ],
        to_diff=[(ph.inFile('razers2-adeno-edit-08.stdout'),
                  ph.outFile('razers2-adeno-edit-08.stdout'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_evaluate,
        redir_stdout=ph.outFile('razers2-adeno-edit-04.stdout'),
        args=[
            '--distance-metric', 'edit', '-e', '8', '--reference',
            ph.outFile('adeno-genome.fa'), '--in-bam',
            ph.inFile('razers2-adeno-edit-04.sam'), '--in-gsi',
            ph.inFile('gold-adeno-edit-08.gsi')
        ],
        to_diff=[(ph.inFile('razers2-adeno-edit-04.stdout'),
                  ph.outFile('razers2-adeno-edit-04.stdout'))])

    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
Example #52
0
def main(source_base, binary_base):
    """Main entry point of the script."""

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

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

    path_to_program = []
    path_to_program.append(app_tests.autolocateBinary(
      binary_base, 'extras/apps/seqan_flexbar', 'sflexQC'))

    path_to_program.append(app_tests.autolocateBinary(
      binary_base, 'extras/apps/seqan_flexbar', 'sflexFilter'))
    
    path_to_program.append(app_tests.autolocateBinary(
      binary_base, 'extras/apps/seqan_flexbar', 'sflexAR'))

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

    # Build list with TestConf objects, analoguely to how the output
    # was generated in generate_outputs.sh.
    conf_list = []

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

    # App TestConf objects to conf_list, just like this for each
    # test you want to run.
    conf = app_tests.TestConf(
        program=path_to_program[0],
        redir_stdout=ph.outFile('out.stdout'),
        args=[ph.inFile('testsample.fq'), '-q', '20', '-o',
        ph.outFile('qc_test.fa'), '-t', '-ni'],
        to_diff=[(ph.inFile('qc_test.stdout'),
                  ph.outFile('out.stdout')),
                 (ph.inFile('gold_qc_test.fa'),
                  ph.outFile('qc_test.fa'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program[1],
        redir_stdout=ph.outFile('out.stdout'),
        args=[ph.inFile('testsample.fq'), '-tl', '3', '-tr', '4', '-ml',
        '70', '-u', '1', '-s', 'A', '-fl', '70', '-ni', '-o',
        ph.outFile('filter_test.fq')],
        to_diff=[(ph.inFile('filter_test.stdout'),
                  ph.outFile('out.stdout')),
                 (ph.inFile('gold_filter_test.fq'),
                  ph.outFile('filter_test.fq'))])
    conf_list.append(conf)

    conf = app_tests.TestConf(
        program=path_to_program[2],
        redir_stdout=ph.outFile('out.stdout'),
        args=[ph.inFile('testsample.fq'), '-a', 
        ph.inFile('adapter.fasta'), 
        '-o', ph.outFile('ar_test.fq'), '-ni'],
        to_diff=[(ph.inFile('ar_test.stdout'),
                  ph.outFile('out.stdout')),
                 (ph.inFile('gold_ar_test.fq'),
                  ph.outFile('ar_test.fq'))])
    conf_list.append(conf)


    # ============================================================
    # Execute the tests.
    # ============================================================
    failures = 0
    counter = 0
    for conf in conf_list:
        res = app_tests.runTest(conf)
        # Output to the user.
        print ' '.join([path_to_program[counter]] + conf.args),
        if res:
             print 'OK'
        else:
            failures += 1
            print 'FAILED'
        counter += 1

    # 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
Example #53
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