def check_results_relaxed_blastx(
    results, correct, formatter, delta=0.01, reformatCorrect=False, allowedLengthDiff=0, identityMin=0.6
):
    results = reformat_results(results, formatter)

    if reformatCorrect:  # reformat these data too
        correct = reformat_results(correct, formatter)
    else:
        correct.sort()

    # Length of output
    assert abs(len(results) - len(correct)) <= allowedLengthDiff

    # Format check
    for result in results:
        assert 3 * result[0] == result[2]
        assert 0.0 < result[3] and result[3] <= 1.0

    # High-identity comparison
    results_high = []
    correct_high = []
    for result in results:
        if result[3] > identityMin:
            results_high.append(result)
    for result in correct:
        if result[3] > identityMin:
            correct_high.append(result)
    assert testutil.approximate_cmp(correct_high, results_high, delta) == 0
def check_results(results, correct, formatter, delta=0.01, reformatCorrect=False, reformatResults=True):
    if reformatResults:
        results = reformat_results(results, formatter)

    if reformatCorrect:  # reformat these data too
        correct = reformat_results(correct, formatter)
    else:
        correct.sort()

    # this is to help troubleshooting the mismatches if there are any
    mismatch = [(a, b) for a, b in zip(correct, results) if testutil.approximate_cmp([a], [b], delta)]
    if mismatch:
        logger.warn("blast mismatches found")
        for m in mismatch:
            logger.warn("%s != %s" % m)

    # this is the actual test
    assert testutil.approximate_cmp(correct, results, delta) == 0
Esempio n. 3
0
def check_results(results, correct, formatter, delta=0.01):
    found = []
    for result in results:
        for t in result.edges():
            found.append(formatter(t))

    # order it identically
    correct.sort()
    found.sort()

    # this is to help troubleshooting the mismatches if there are any
    mismatch = [ (a, b) for a, b in zip(correct, found) if
                 testutil.approximate_cmp([a], [b], delta)]
    if mismatch:
        logger.warn('blast mismatches found')
        for m in mismatch:
            logger.warn('%s != %s' % m)

    # this is the actual test
    assert testutil.approximate_cmp(correct, found, delta) == 0
def check_results_relaxed_blastp(
    results,
    correct,
    formatter,
    delta=0.01,
    reformatCorrect=False,
    allowedLengthDiff=0,
    identityMin=0.6,
    reformatResults=True,
):
    if reformatResults:
        results = reformat_results(results, formatter)

    if reformatCorrect:  # reformat these data too
        correct = reformat_results(correct, formatter)
    else:
        correct.sort()

    # Length of output
    assert abs(len(results) - len(correct)) <= allowedLengthDiff

    # Format check
    key_re = re.compile("^[A-Z]{3}[A-Z0-9]?_[A-Z]{2,5}$")
    for result in results:
        assert key_re.search(result[0])
        assert key_re.search(result[1])
        assert 0.0 < result[2] and result[2] <= 1.0

    # High-identity comparison
    results_high = []
    correct_high = []
    for result in results:
        if result[2] > identityMin:
            results_high.append(result)
    for result in correct:
        if result[2] > identityMin:
            correct_high.append(result)
    assert testutil.approximate_cmp(correct_high, results_high, delta) == 0