Exemple #1
0
def test_check_query_for_input_column():
    config = cfunk.get_defaults()
    config["query"] = os.path.join(thisdir, "test.csv")
    qcfunk.check_query_for_input_column(config)
    test_query_header = "name,display,HCW_status,care_home,sample_date,date_2,date_3,adm2,test,test2,outer_postcode,x_col,y_col,adm1_blah".split(
        ",")
    assert config["query_metadata_header"] == test_query_header
Exemple #2
0
def test_generate_query_from_metadata():
    config = cfunk.get_defaults()
    config["background_metadata"] = os.path.join(thisdir,
                                                 "test_background.csv")
    from_metadata = "adm2=Edinburgh sample_date=2020-10-01"

    query = qcfunk.generate_query_from_metadata("test_from_metadata.csv",
                                                from_metadata,
                                                config["background_metadata"],
                                                config)
    c = 0
    with open(query, "r") as f:
        for l in f:
            c += 1
    assert c == 5

    from_metadata = "adm2=Edinburgh sample_date=2020-10-01:2020-10-10"

    query = qcfunk.generate_query_from_metadata("test_from_metadata.csv",
                                                from_metadata,
                                                config["background_metadata"],
                                                config)
    c = 0
    with open(query, "r") as f:
        for l in f:
            c += 1
    assert c == 12
Exemple #3
0
def test_background_metadata_header():
    config = cfunk.get_defaults()
    config["background_metadata"] = os.path.join(thisdir,
                                                 "test_background.csv")
    test_header = "central_sample_id,biosample_source_id,sequence_name,secondary_identifier,sample_date,epi_week,country,adm1,is_surveillance,is_community,is_hcw,is_travel_history,travel_history,lineage,lineage_support,uk_lineage,acc_lineage,del_lineage,phylotype,adm2".split(
        ",")
    qcfunk.check_metadata_for_search_columns(config)
    assert test_header == config["background_metadata_header"]
Exemple #4
0
def test_max_ambig():
    config = cfunk.get_defaults()
    print(cwd)
    config["query"] = os.path.join(thisdir, "test.csv")
    config["fasta"] = os.path.join(thisdir, "test.fasta")
    config["outdir"] = thisdir
    config["background_metadata"] = os.path.join(thisdir,
                                                 "test_background.csv")
    num_seqs = qcfunk.input_file_qc(None, 0, config)
    assert num_seqs == 2
Exemple #5
0
def test_configure_update():
    config = cfunk.get_defaults()
    config["from_metadata"] = "sample_date=2020-10-04"
    cfunk.configure_update(True, config)
    assert config["colour_by"] == "new:Paired"
    assert config["tree_fields"] == "new"
    assert config[
        "table_fields"] == "central_sample_id,sequence_name,sample_date,uk_lineage,phylotype,tree,new"
    assert config["tempdir"] == ""
    assert config["outdir"] == ""
Exemple #6
0
def test_map_sequences_config():
    config = cfunk.get_defaults()
    config["background_metadata"] = os.path.join(thisdir,
                                                 "test_background.csv")
    qcfunk.check_metadata_for_search_columns(config)
    config[
        "query_metadata_header"] = "name,display,HCW_status,care_home,sample_date,date_2,date_3,adm2,test,test2,outer_postcode,x_col,y_col,adm1_blah".split(
            ",")
    config["map_info"] = "outer_postcode"
    config["map_sequences"] = True
    cfunk.map_sequences_config(config)
    assert config["input_crs"] == "EPSG:4326"
Exemple #7
0
def test_get_sequencing_centre_header():
    config = cfunk.get_defaults()
    qcfunk.get_outdir(None, None, cwd, config)
    config["sequencing_centre"] = "EDIN"
    cfunk.get_sequencing_centre_header(config)
    assert config["sequencing_centre_file"] == "./figures/EDIN.png"
Exemple #8
0
def test_configure_cluster():
    config = cfunk.get_defaults()
    cfunk.configure_cluster(config)
    assert config["down_distance"] == 100
Exemple #9
0
def test_outdir_and_prefix():
    config = cfunk.get_defaults()
    qcfunk.get_outdir("outdir_arg", "prefix", cwd, config)
    outdir = config["outdir"].split("/")[-1]
    assert outdir.startswith("outdir_arg")
Exemple #10
0
def test_outdir_arg():
    config = cfunk.get_defaults()
    qcfunk.get_outdir("input_arg", None, cwd, config)
    outdir = config["outdir"].split("/")[-1]
    assert outdir.startswith("input_arg")
Exemple #11
0
def test_outdir_default():
    config = cfunk.get_defaults()
    qcfunk.get_outdir(None, None, cwd, config)
    outdir = config["outdir"].split("/")[-1]
    assert outdir.startswith("civet")