Example #1
0
def test_Vsearch_fastas_cmd():
    """Vsearch_fastas instantiates and returns correct form of cmd-line"""
    cluster = vsearch.Vsearch_fastas("vsearch")
    target = ' '.join([
        "vsearch", "--cluster_fast", INFILE_CLUSTER, "--id", THRESHOLD,
        "--centroids",
        os.path.join(OUTDIR,
                     PREFIX + THRESHOLD + '.centroids.fasta'), "--msaout",
        os.path.join(OUTDIR,
                     PREFIX + THRESHOLD + '.alignedclusters.fasta'), "--uc",
        os.path.join(OUTDIR,
                     PREFIX + THRESHOLD + '.fast.clusters.uc'), "--consout",
        os.path.join(OUTDIR, PREFIX + THRESHOLD + '.consensus_cls_seq.fasta'),
        "--db", DB, "--threads", THREADS, "--blast6out",
        os.path.join(OUTDIR, PREFIX + THRESHOLD + '.clusterfast.blast6')
    ])
    # fasta_in, outdir, prefix, db, threads, threshold)
    assert_equal(
        cluster.run(INFILE_CLUSTER,
                    OUTDIR,
                    PREFIX,
                    DB,
                    THREADS,
                    THRESHOLD,
                    dry_run=True), target)
Example #2
0
def test_Vsearch_fastas_notexec():
    """Error thrown if vsearch not executable"""
    try:
        cluster = vsearch.Vsearch_fastas("LICENSE")
    except NotExecutableError:
        return True
    else:
        return False
Example #3
0
def test_Vsearch_fastas_exec_notexist():
    """Error thrown if Vsearch_fastas executable does not exist"""
    try:
        cluster = vsearch.Vsearch_fastas(os.path.join(".", "vsearch"))
    except NotExecutableError:
        return True
    else:
        return False
Example #4
0
def test_vsearch_exec():
    """Run vsearch on test data

    TODO: finer option could be passed??
    """
    cluster = vsearch.Vsearch_fastas("vsearch")

    # results are defined in the class:
    # factory class for vsearch class returned values
    # Results = namedtuple("Results", "command fastaout " +
    # "stdout stderr")
    # fasta_in, outdir, prefix, db, threads, threshold=0.99
    result2 = cluster.run(INFILE_CLUSTER, OUTDIR, PREFIX, DB, THREADS,
                          THRESHOLD)
    # use the named tuple to get the clustering results file
    # compare the blast6 output, convert them to sorted lists first
    target_blast = get_sorted_list(TARGET_C_FAST_B6)
    result_blast = get_sorted_list(result2.blast6)
    assert_equal(result_blast, target_blast)

    # UC outfiles
    target_uc = get_sorted_list(TARGET_C_FAST_UC)
    result_uc = get_sorted_list(result2.uc_clusters)
    assert_equal(result_uc, target_uc)

    # centroids outfiles
    target_cent = get_sorted_fa(TARGET_CENTROIDS)
    result_cent = get_sorted_fa(result2.centroids)
    assert_equal(target_cent, result_cent)

    # TARGET_ALIGNED
    target_alig = get_sorted_fa(TARGET_ALIGNED)
    result_alig = get_sorted_fa(result2.aligned)
    assert_equal(target_alig, result_alig)

    # TARGET_CONCENSUS
    target_conc = get_sorted_fa(TARGET_CONCENSUS)
    result_conc = get_sorted_fa(result2.consensus_cls)
    assert_equal(target_conc, result_conc)
Example #5
0
def test_Vsearch_fastas():
    """Vsearch_fastas instantiates with cmd-line if cd-hit is in $PATH"""
    cluster = vsearch.Vsearch_fastas("vsearch")