Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refseq update #1944

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions c/tests/test_file_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,47 @@ test_malformed_indexes(void)
free(ts);
}

static void
test_missing_reference_sequence(void)
{
int ret;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
tsk_table_collection_t t1, t2;
const char *cols[] = { "reference_sequence/data", "reference_sequence/url",
"reference_sequence/metadata_schema", "reference_sequence/metadata" };

CU_ASSERT_TRUE(tsk_treeseq_has_reference_sequence(ts));

ret = tsk_treeseq_copy_tables(ts, &t1, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);

copy_store_drop_columns(ts, 1, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_TRUE(tsk_table_collection_has_reference_sequence(&t2));
tsk_table_collection_free(&t2);

copy_store_drop_columns(ts, 2, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_TRUE(tsk_table_collection_has_reference_sequence(&t2));
tsk_table_collection_free(&t2);

copy_store_drop_columns(ts, 3, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_TRUE(tsk_table_collection_has_reference_sequence(&t2));
tsk_table_collection_free(&t2);

/* Dropping all the columns gives us a NULL reference_sequence, though */
copy_store_drop_columns(ts, 4, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_FALSE(tsk_table_collection_has_reference_sequence(&t2));
tsk_table_collection_free(&t2);

tsk_table_collection_free(&t1);
tsk_treeseq_free(ts);
free(ts);
}

static void
test_bad_column_types(void)
{
Expand Down Expand Up @@ -699,6 +740,18 @@ test_bad_column_types(void)
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_COLUMN_TYPE);
tsk_table_collection_free(&tables);

cols[0] = "reference_sequence/metadata";
copy_store_drop_columns(ts, 1, cols, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, cols[0], NULL, 0, KAS_FLOAT32, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_COLUMN_TYPE);
tsk_table_collection_free(&tables);

free(col_memory);
tsk_treeseq_free(ts);
free(ts);
Expand Down Expand Up @@ -760,6 +813,8 @@ test_metadata_schemas_optional(void)
const char *cols[] = {
"metadata",
"metadata_schema",
"reference_sequence/metadata",
"reference_sequence/metadata_schema",
"individuals/metadata_schema",
"populations/metadata_schema",
"nodes/metadata_schema",
Expand Down Expand Up @@ -1290,6 +1345,7 @@ main(int argc, char **argv)
{ "test_format_data_load_errors", test_format_data_load_errors },
{ "test_missing_indexes", test_missing_indexes },
{ "test_malformed_indexes", test_malformed_indexes },
{ "test_missing_reference_sequence", test_missing_reference_sequence },
{ "test_bad_column_types", test_bad_column_types },
{ "test_missing_required_columns", test_missing_required_columns },
{ "test_missing_optional_column_pairs", test_missing_optional_column_pairs },
Expand Down
Loading