def test_create_event_request_with_missing_contiguity_metrics():
    app = app_helper.setup_app_state('quast', 'missing_g75_values')
    event = post.create_event_request(app, post.list_outputs(app))
    nose.assert_equal(event["success"], True)
    nose.assert_in("nga50", event["metrics"])
    nose.assert_equal(event["metrics"]["nga50"], 17378.0)
    nose.assert_equal(event["metrics"]["nga75"], 0.0)
def test_run_container():
    app = app_helper.setup_app_state('quast', 'execute')
    id_ = run.create_container(app)['Id']
    docker.client().start(id_)
    docker.client().wait(id_)
    nose.assert_equal(container.did_exit_succcessfully(id_), True)
    image_helper.clean_up_container(id_)
def test_gaet_complete_run_through():
    app = app_helper.setup_app_state('gaet', 'execute')
    image_helper.execute_image(app)
    file_helper.assert_is_file(
        fs.get_task_file_path(app, 'outputs/assembly_metrics/d70c163200'))
    file_helper.assert_is_file(
        fs.get_task_file_path(app, 'outputs/container_log/1661337965'))
def test_quast_complete_run_through():
    app = app_helper.setup_app_state('quast', 'execute')
    image_helper.execute_image(app)
    file_helper.assert_is_file(
        fs.get_task_file_path(app, 'outputs/assembly_metrics/684281f282'))
    file_helper.assert_is_file(
        fs.get_task_file_path(app, 'outputs/container_log/86bbc499b0'))
コード例 #5
0
def test_copy_container_output_files_with_no_files():
    app = app_helper.setup_app_state('quast', 'execute')
    input_files = {
        'container_log': 'meta/log.txt',
        'assembly_metrics': 'tmp/combined_quast_output/report.tsv'
    }
    fs.copy_container_output_files(app, input_files)
コード例 #6
0
def test_get_task_metadata_with_existing_metadata_json():
    import json, shutil
    app = app_helper.setup_app_state('sra')
    shutil.copy('example_data/tasks/short_read_assembler.json', app['path'] + '/metadata.json')
    app["api"] = None # Ensure data is not collected from the API
    metadata = util.get_task_metadata("1", app)
    nose.assert_in("id", metadata)
コード例 #7
0
def test_complete_run_through():
    app = app_helper.setup_app_state('sra', 'inputs')
    image_helper.execute_image(app)

    file_helper.assert_is_file(fs.get_task_file_path(app, 'outputs/contig_fasta/01eb7cec61'))
    file_helper.assert_is_file(fs.get_task_file_path(app, 'outputs/container_runtime_metrics/metrics.json.gz'))
    file_helper.assert_is_file(fs.get_task_file_path(app, 'outputs/container_log/1099992390'))
コード例 #8
0
def test_upload_output_file():
    app  = app_helper.setup_app_state('sra', 'task')
    url  = "s3://nucleotides-testing/upload/"
    path = file_helper.create_benchmark_file(app, '/outputs/contig_fasta/d1b2a59fbe', 'contents')
    post.upload_output_file(app, post.output_file_metadata(url, path))
    expected_path = "upload/d1/d1b2a59fbea7e20077af9f91b27e95e865061b270be03ff539ab3b73587882e8"
    s3_helper.assert_s3_file_exists("nucleotides-testing", expected_path)
    s3_helper.delete_s3_file("nucleotides-testing", expected_path)
コード例 #9
0
def test_fetch_short_read_assembler_input_files():
    db_helper.reset_database()
    app = app_helper.setup_app_state('sra', 'task')
    fetch.create_input_files(app)
    file_helper.assert_is_file(
        app["path"] +
        "/inputs/short_read_fastq/24b5b01b08482053d7d13acd514e359fb0b726f1e8ae36aa194b6ddc07335298.fq.gz"
    )
コード例 #10
0
def test_short_read_assembler_successful_event_with_incomplete_cgroup_data():
    app  = app_helper.setup_app_state('sra', 'incomplete_cgroup')
    outputs = [{
        "type"     : "contig_fasta",
        "location" : "/local/path",
        "sha256"   : "digest_1",
        "url"      : "s3://url/dir/file"}]
    event = post.create_event_request(app, outputs)
    nose.assert_equal(event['metrics']['total_rss_in_mibibytes'], 0.0)
def test_assembly_benchmark_unsuccessful_event():
    app = app_helper.setup_app_state('quast', 'task')  # No tmp/biobox.yaml
    event = post.create_event_request(app, post.list_outputs(app))
    nose.assert_equal(event, {
        "task": 6,
        "success": False,
        "files": [],
        "metrics": {}
    })
def test_create_event_request_with_a_successful_quast_event():
    app = app_helper.setup_app_state('quast', 'outputs')
    event = post.create_event_request(app, post.list_outputs(app))
    nose.assert_equal(event["task"], 6)
    nose.assert_equal(event["success"], True)
    nose.assert_equal(event["files"][0]["type"], "assembly_metrics")
    nose.assert_in("total_aligned_length", event["metrics"])
    nose.assert_in("lga75", event["metrics"])
    nose.assert_equal(event["metrics"]["lga75"], 70.0)
    nose.assert_equal(event["metrics"]["total_aligned_length"], 679979.0)
def test_execution_with_empty_contig_file():
    app = app_helper.setup_app_state('quast', 'execute')
    input_contigs = fs.get_task_file_path(app,
                                          "inputs/contig_fasta/de3d9f6d31.fa")
    open(input_contigs, "w").truncate()

    image_helper.execute_image(app)
    file_helper.assert_is_empty_directory(
        fs.get_task_file_path(app, 'outputs/assembly_metrics/'))
    file_helper.assert_is_empty_directory(
        fs.get_task_file_path(app, 'outputs/container_log/'))
コード例 #14
0
def test_list_outputs():
    app = app_helper.setup_app_state('sra', 'outputs')
    app["s3-upload"] = "s3://url/"
    outputs = post.list_outputs(app)
    nose.assert_equal(len(outputs), 3)
    nose.assert_in({
        "type"     : "contig_fasta",
        "location" : fs.get_task_path_file_without_name(app, "outputs/contig_fasta"),
        "sha256"   : "de3d9f6d31285985139aedd9e3f4b4ad04dadb4274c3c0ce28261a8e8e542a0f",
        "url"      : "s3://url/de/de3d9f6d31285985139aedd9e3f4b4ad04dadb4274c3c0ce28261a8e8e542a0f"},
        outputs)
コード例 #15
0
def test_post_event():
    db_helper.reset_database()
    event = {
        "task": 1,
        "success": False,
        "files": [{
            "url": "s3://url",
            "sha256": "adef5c",
            "type": "container_log"
        }]
    }
    app = app_helper.setup_app_state('sra')
コード例 #16
0
def test_fetch_reference_assembler_input_files():
    db_helper.reset_database()
    app = app_helper.setup_app_state('quast', 'task')
    fetch.create_input_files(app)
    file_helper.assert_is_file(
        app["path"] +
        "/inputs/reference_fasta/6bac51cc35ee2d11782e7e31ea1bfd7247de2bfcdec205798a27c820b2810414.fa.gz"
    )
    file_helper.assert_is_file(
        app["path"] +
        "/inputs/contig_fasta/57601ff10b7faf7fcf53a7268e3615db58088db34eb8e8bf31cb475c24381451.fa"
    )
コード例 #17
0
def test_copy_container_output_files_with_intermediates():
    app = app_helper.setup_app_state('quast', 'intermediates')
    input_files = {
        'container_log': 'meta/log.txt',
        'assembly_metrics': 'tmp/report.tsv'
    }
    output_files = ['assembly_metrics/63d2a18fa1', 'container_log/e0e8af3790']

    fs.copy_container_output_files(app, input_files)
    for f in output_files:
        loc = fs.get_task_file_path(app, "outputs/" + f)
        assert os.path.isfile(loc), "Output file should be copied: {}".format(
            loc)
コード例 #18
0
def test_failing_image_with_no_outputs():
    image = {
        "name": "bioboxes/crash-test-biobox",
        "sha256":
        "eaf1ab35314712db9d3fff0d265613629fe628ed9b058a9a4fe94424184f8c41",
        "task": "exit-1",
        "type": "short_read_assembler"
    }
    app = app_helper.setup_app_state('sra', 'inputs')
    app["task"]["image"] = image
    app_helper.rewrite_app_task(app)
    image_helper.execute_image(app)
    file_helper.assert_is_file(
        fs.get_task_file_path(
            app, 'outputs/container_runtime_metrics/metrics.json.gz'))
def test_create_event_request_with_non_numeric_quast_values():
    app = app_helper.setup_app_state('quast', 'outputs')

    import fileinput
    for line in fileinput.input(app['path'] +
                                '/outputs/assembly_metrics/67ba437ffa',
                                inplace=True):
        if 'NGA50' in line:
            print line.replace("6456", "-"),
        else:
            print line.replace("\n", "")

    event = post.create_event_request(app, post.list_outputs(app))
    nose.assert_equal(event["success"], True)
    nose.assert_in("nga50", event["metrics"])
    nose.assert_equal(event["metrics"]["nga50"], 0.0)
def test_create_event_request_with_a_successful_gaet_event():
    app = app_helper.setup_app_state('gaet', 'outputs')
    event = post.create_event_request(app, post.list_outputs(app))
    nose.assert_equal(event["task"], 6)
    nose.assert_equal(event["success"], True)
    nose.assert_equal(event["files"][0]["type"], "assembly_metrics")

    nose.assert_in("comparison.gene_type_distance.cds.n_symmetric_difference",
                   event["metrics"])
    nose.assert_equal(
        event["metrics"]
        ["comparison.gene_type_distance.cds.n_symmetric_difference"], 7.0)

    nose.assert_in("assembly.minimum_gene_set.single_copy", event["metrics"])
    nose.assert_equal(
        event["metrics"]["assembly.minimum_gene_set.single_copy"], 0.0)
コード例 #21
0
def test_fetch_reference_assembler_input_files_with_short_contigs():
    db_helper.reset_database()
    app = app_helper.setup_app_state('quast_short_contigs', 'task')
    fetch.create_input_files(app)

    # If the short contig are filtered as part of the download process, the input
    # file should have the same SHA256 as the contig.fa without the short contigs.
    file_helper.assert_is_file(
        app["path"] +
        "/inputs/contig_fasta/de3d9f6d31285985139aedd9e3f4b4ad04dadb4274c3c0ce28261a8e8e542a0f.fa"
    )
    file_helper.assert_is_not_file(
        app["path"] +
        "/inputs/contig_fasta/1ff29bcb6940b7d629d2d070fd67b23604e3459c9fd0167cdb6d1dcb26966c87.fa"
    )
    file_helper.assert_is_not_file(
        app["path"] +
        "/inputs/contig_fasta/1ff29bcb6940b7d629d2d070fd67b23604e3459c9fd0167cdb6d1dcb26966c87.fa.fai"
    )
コード例 #22
0
def test_short_read_assembler_successful_event_without_cgroup_data():
    """
    It is possible that an assembler could finish before the first set of cgroup
    metrics are collected. In this case, we would not want the task to be considered
    failed as long as contig files have been produced.
    """
    app  = app_helper.setup_app_state('sra', 'missing_cgroup')
    outputs = [{
        "type"     : "contig_fasta",
        "location" : "/local/path",
        "sha256"   : "digest_1",
        "url"      : "s3://url/dir/file"}]
    event = post.create_event_request(app, outputs)
    nose.assert_equal({
        "task" : 4,
        "success" : True,
        "metrics" : {},
        "files" : [
            {"url"    : "s3://url/dir/file",
             "sha256" : "digest_1",
             "type"   : "contig_fasta"}]}, event)
コード例 #23
0
def test_short_read_assembler_successful_event_with_cgroup_data():
    app  = app_helper.setup_app_state('sra', 'outputs')
    outputs = [{
        "type"     : "contig_fasta",
        "location" : "/local/path",
        "sha256"   : "digest_1",
        "url"      : "s3://url/dir/file"}]
    event = post.create_event_request(app, outputs)
    nose.assert_equal({
        "task" : 4,
        "success" : True,
        "metrics" : {
            "total_cpu_usage_in_seconds"               : 53.546,
            "total_cpu_usage_in_seconds_in_kernelmode" : 1.75,
            "total_cpu_usage_in_seconds_in_usermode"   : 11.11,
            "total_memory_usage_in_mibibytes"          : 175.348,
            "total_rss_in_mibibytes"                   : 80.543,
            "total_read_io_in_mibibytes"               : 38.641,
            "total_write_io_in_mibibytes"              : 0.0,
            "total_wall_clock_time_in_seconds"         : 0.0},
        "files" : [
            {"url"    : "s3://url/dir/file",
             "sha256" : "digest_1",
             "type"   : "contig_fasta"}]}, event)
コード例 #24
0
def test_create_container():
    app = app_helper.setup_app_state('sra', 'inputs')
    cnt = run.create_container(app)
    assert "Id" in cnt
    image_helper.clean_up_container(cnt["Id"])
コード例 #25
0
def test_output_file_paths():
    app = app_helper.setup_app_state('sra', 'intermediates')
    paths = task().output_file_paths(app)
    for (_, f) in paths.items():
        location = fs.get_task_file_path(app, "tmp/" + f)
        nose.assert_true(os.path.isfile(location))
コード例 #26
0
def test_copy_output_files():
    app = app_helper.setup_app_state('sra', 'intermediates')
    run.copy_output_files(app)
    file_helper.assert_is_file(fs.get_task_file_path(app, 'outputs/container_log/e0e8af3790'))
    file_helper.assert_is_file(fs.get_task_file_path(app, 'outputs/contig_fasta/de3d9f6d31'))
def test_create_container():
    app = app_helper.setup_app_state('quast', 'execute')
    cnt = run.create_container(app)
    assert "Id" in cnt
    image_helper.clean_up_container(cnt["Id"])
コード例 #28
0
def test_fetch_task_from_invalid_url():
    app = app_helper.setup_app_state('sra')
    app["api"] = "localhost:98765"
    response = api.fetch_task("1", app)
コード例 #29
0
def test_fetch_task_from_valid_url():
    db_helper.reset_database()
    app = app_helper.setup_app_state('sra')
    response = api.fetch_task("1", app)
    nose.assert_in("id", response)
    nose.assert_equal(response["id"], 1)
def test_create_event_request_with_missing_alignment_values():
    app = app_helper.setup_app_state('quast', 'missing_alignment')
    event = post.create_event_request(app, post.list_outputs(app))
    nose.assert_equal(event["success"], False)
    nose.assert_equal(event["metrics"], {})