END_TEST

START_TEST(test_store_load)
{
    int res;
    uproc_matrix *mat;
    size_t rows, cols;
    double data[] = {
        0.0, 0.1, 0.2, 0.3,
        1.0, 1.1, 1.2, 1.3 };

    mat = uproc_matrix_create(2, 4, data);

    res = uproc_matrix_store(mat, UPROC_IO_GZIP, TMPDATADIR "test.matrix");
    ck_assert_msg(res == 0, "storing failed");
    uproc_matrix_destroy(mat);

    mat = uproc_matrix_load(UPROC_IO_GZIP, TMPDATADIR "test.matrix");
    ck_assert_ptr_ne(mat, NULL);

    uproc_matrix_dimensions(mat, &rows, &cols);
    ck_assert_uint_eq(rows, 2);
    ck_assert_uint_eq(cols, 4);

    ck_assert(uproc_matrix_get(mat, 0, 0) == 0.0);
    ck_assert(uproc_matrix_get(mat, 0, 2) == 0.2);
    ck_assert(uproc_matrix_get(mat, 0, 3) == 0.3);
    ck_assert(uproc_matrix_get(mat, 1, 0) == 1.0);
    ck_assert(uproc_matrix_get(mat, 1, 2) == 1.2);
    ck_assert(uproc_matrix_get(mat, 1, 3) == 1.3);
}
Example #2
0
File: calib.c Project: gobics/uproc
static int choice(const uproc_matrix *p, size_t n)
{
    double sum, c;
    unsigned i;
    c = (double)rand() / RAND_MAX;
    for (sum = 0, i = 0; sum < c && i < n; ++i) {
        if (p) {
            sum += uproc_matrix_get(p, 0, i);
        } else {
            sum += 1.0 / n;
        }
    }
    return i - 1;
}
Example #3
0
static bool
prot_filter(const char *seq, size_t len, uproc_family family,
            double score, void *opaque)
{
    (void)seq;
    (void)family;
    unsigned long rows, cols;
    uproc_matrix *thresh = opaque;
    if (!thresh) {
        return score > UPROC_EPSILON;
    }
    uproc_matrix_dimensions(thresh, &rows, &cols);
    if (len >= rows) {
        len = rows - 1;
    }
    return score >= uproc_matrix_get(thresh, len, 0);
}
Example #4
0
static bool
orf_filter(const struct uproc_orf *orf, const char *seq, size_t seq_len,
           double seq_gc, void *opaque)
{
    unsigned long r, c, rows, cols;
    uproc_matrix *thresh = opaque;
    (void) seq;
    if (orf->length < 20) {
        return false;
    }
    if (!thresh) {
        return true;
    }
    uproc_matrix_dimensions(thresh, &rows, &cols);
    r = seq_gc * 100;
    c = seq_len;
    if (r >= rows) {
        r = rows - 1;
    }
    if (c >= cols) {
        c = cols - 1;
    }
    return orf->score >= uproc_matrix_get(thresh, r, c);
}