Exemple #1
0
def test_ncbi_stockholm(
    namespace_base,
    path_ncbi_stockholm,
    path_ncbi_stockholm_targets,
    tmp_path,
):
    """ncfp collects correct coding sequences for NCBI/Stockholm input.

    This test was added as a check for the fix in issue 31.
    """
    # Modify default arguments
    infile = path_ncbi_stockholm
    outdir = tmp_path / "ncbi_stockholm"
    args = modify_namespace(namespace_base,
                            infname=infile,
                            outdirname=outdir,
                            stockholm=True)

    # Run ersatz command-line
    ncfp.run_main(args)

    # Compare output (should be no skipped files)
    check_files(
        outdir,
        path_ncbi_stockholm_targets,
        ("ncfp_aa.fasta", "ncfp_nt.fasta"),
    )
Exemple #2
0
def test_small_stockholm_use_protein_id(
    namespace_base,
    path_uniprot_stockholm_small,
    path_uniprot_stockholm_small_use_proteinid_targets,
    tmp_path,
):
    """ncfp collects correct coding sequences for small UniProt/Stockholm input."""
    # Modify default arguments
    infile = path_uniprot_stockholm_small
    outdir = tmp_path / "small_stockholm_use_proteinid"
    args = modify_namespace(
        namespace_base,
        infname=infile,
        outdirname=outdir,
        stockholm=True,
        use_protein_ids=True,
    )

    # Run ersatz command-line
    ncfp.run_main(args)

    # Compare output (should be no skipped files)
    check_files(
        outdir,
        path_uniprot_stockholm_small_use_proteinid_targets,
        ("ncfp_aa.fasta", "ncfp_nt.fasta"),
    )
Exemple #3
0
def test_bad_infile(args_bad_infile):
    """ncfp stops if CLI input file does not exist.

    Validates that ncfp throws correct error, does not check output
    """
    with pytest.raises(NCFPException):
        ncfp.run_main(args_bad_infile)
Exemple #4
0
def test_download_and_log(args_validate_and_log,
                          mock_uniprot_download_and_log):
    """ncfp downloads coding sequences and logs output from CLI.

    Validates that ncfp runs without error, does not check output. Calls to UniProt
    are mocked for use with cloud CI.
    """
    ncfp.run_main(args_validate_and_log)
Exemple #5
0
def test_create_and_keep_cache(args_create_reuse_cache,
                               mock_entrez_create_and_keep_cache):
    """ncfp creates named cache from CLI and keeps it when rerunning.

    This calls ncfp twice and expects both calls run without error. Output
    is not checked.
    """
    # Create local cache
    ncfp.run_main(args_create_reuse_cache)
    # Reuse created cache
    ncfp.run_main(args_create_reuse_cache + ["--keepcache"])
Exemple #6
0
def test_basic_ncbi(namespace_base, path_ncbi, path_ncbi_targets, tmp_path):
    """ncfp collects correct coding sequences for basic NCBI input."""
    # Modify default arguments
    infile = path_ncbi
    outdir = tmp_path / "basic_ncbi"
    args = modify_namespace(namespace_base, infname=infile, outdirname=outdir)

    # Run ersatz command-line
    ncfp.run_main(args)

    # Compare output
    check_files(outdir, path_ncbi_targets, ("ncfp_aa.fasta", "ncfp_nt.fasta"))
Exemple #7
0
def test_alternative_start(namespace_base, path_altstart,
                           path_altstart_targets, tmp_path):
    """ncfp collects correct coding sequences for NCBI input with alternative start codon."""
    infile = path_altstart
    outdir = tmp_path / "alternative_start"
    args = modify_namespace(namespace_base,
                            infname=infile,
                            outdirname=outdir,
                            alternative_start_codon=True)

    # Run ersatz command-line
    ncfp.run_main(args)

    # Compare output
    check_files(outdir, path_altstart_targets,
                ("ncfp_aa.fasta", "ncfp_nt.fasta"))
Exemple #8
0
def test_basic_uniprot(namespace_base, path_uniprot, path_uniprot_targets,
                       tmp_path, mock_basic_uniprot):
    """ncfp collects correct coding sequences for basic UniProt input."""
    # Modify default arguments
    infile = path_uniprot
    outdir = tmp_path / "basic_uniprot"
    args = modify_namespace(namespace_base, infname=infile, outdirname=outdir)

    # Run ersatz command-line
    ncfp.run_main(args)

    # Compare output
    check_files(
        outdir,
        path_uniprot_targets,
        ("ncfp_aa.fasta", "ncfp_nt.fasta", "skipped.fasta"),
    )
Exemple #9
0
def test_basic_stockholm(namespace_base, path_stockholm,
                         path_stockholm_targets, tmp_path):
    """ncfp collects correct coding sequences for basic UniProt/Stockholm input."""
    # Modify default arguments
    infile = path_stockholm
    outdir = tmp_path / "basic_stockholm"
    args = modify_namespace(namespace_base,
                            infname=infile,
                            outdirname=outdir,
                            stockholm=True)

    # Run ersatz command-line
    ncfp.run_main(args)

    # Compare output (should be no skipped files)
    check_files(
        outdir,
        path_stockholm_targets,
        ("ncfp_aa.fasta", "ncfp_nt.fasta"),
    )