Skip to content

updates to union, subset, and sort #1108

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

Merged
merged 6 commits into from
Feb 3, 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
11 changes: 11 additions & 0 deletions c/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@
- Add ``parents`` to the individual table to enable recording of pedigrees
(:user:`ivan-krukov`, :user:`benjeffery`, :issue:`852`, :pr:`1125`, :pr:`866`, :pr:`1153`, :pr:`1177`).

- Added a ``tsk_table_collection_canonicalse`` method, that allows checking for equality between
tables that are equivalent up to reordering (:user:`petrelharp`, :user:`mufernando`, :pr:`1108`).

- Removed a previous requirement on ``tsk_table_collection_union``, allowing for unioning of
new information both above and below shared history (:user:`petrelharp`, :user:`mufernando`, :pr:`1108`).

**Breaking changes**

- Method ``tsk_individual_table_add_row`` has an extra arguments ``parents`` and ``parents_length``.

**Breaking changes**

- Add an ``options`` argument to ``tsk_table_collection_subset`` (:user:`petrelharp`, :pr:`1108`),
to allow for retaining the order of populations.

**Bugfixes**

----------------------
Expand Down
444 changes: 421 additions & 23 deletions c/tests/test_tables.c

Large diffs are not rendered by default.

49 changes: 27 additions & 22 deletions c/tests/testlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ parse_mutations(const char *text, tsk_mutation_table_t *mutation_table)
double time;
char derived_state[MAX_LINE];

/* site, node, derived_state, [parent, time] */
c = 0;
while (text[c] != '\0') {
/* Fill in the line */
Expand Down Expand Up @@ -638,30 +639,34 @@ parse_individuals(const char *text, tsk_individual_table_t *individual_table)
q = strtok_r(NULL, ",", &q_cont);
}
CU_ASSERT_FATAL(q == NULL);

/* parents and name are optional */
p = strtok_r(NULL, whitespace, &p_cont);
// the parents are comma-separated
parents_len = 1;
q = p;
while (*q != '\0') {
if (*q == ',') {
parents_len++;
parents_len = 0;
name = "";
if (p != NULL) {
// the parents are comma-separated
parents_len = 1;
q = p;
while (*q != '\0') {
if (*q == ',') {
parents_len++;
}
q++;
}
CU_ASSERT_FATAL(parents_len >= 1);
strncpy(sub_line, p, MAX_LINE);
q = strtok_r(sub_line, ",", &q_cont);
for (k = 0; k < parents_len; k++) {
CU_ASSERT_FATAL(q != NULL);
parents[k] = atoi(q);
q = strtok_r(NULL, ",", &q_cont);
}
CU_ASSERT_FATAL(q == NULL);
p = strtok_r(NULL, whitespace, &p_cont);
if (p != NULL) {
name = p;
}
q++;
}
CU_ASSERT_FATAL(parents_len >= 1);
strncpy(sub_line, p, MAX_LINE);
q = strtok_r(sub_line, ",", &q_cont);
for (k = 0; k < parents_len; k++) {
CU_ASSERT_FATAL(q != NULL);
parents[k] = atoi(q);
q = strtok_r(NULL, ",", &q_cont);
}
CU_ASSERT_FATAL(q == NULL);
p = strtok_r(NULL, whitespace, &p_cont);
if (p == NULL) {
name = "";
} else {
name = p;
}
ret = tsk_individual_table_add_row(individual_table, flags, location,
location_len, parents, parents_len, name, strlen(name));
Expand Down
4 changes: 0 additions & 4 deletions c/tskit/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,6 @@ tsk_strerror_internal(int err)
case TSK_ERR_NONBINARY_MUTATIONS_UNSUPPORTED:
ret = "Only binary mutations are supported for this operation";
break;
case TSK_ERR_UNION_NOT_SUPPORTED:
ret = "Union is not supported for cases where there is non-shared"
"history older than the shared history of the two Table Collections";
break;

/* Stats errors */
case TSK_ERR_BAD_NUM_WINDOWS:
Expand Down
1 change: 0 additions & 1 deletion c/tskit/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ not found in the file.
#define TSK_ERR_SORT_OFFSET_NOT_SUPPORTED -803
#define TSK_ERR_NONBINARY_MUTATIONS_UNSUPPORTED -804
#define TSK_ERR_MIGRATIONS_NOT_SUPPORTED -805
#define TSK_ERR_UNION_NOT_SUPPORTED -806

/* Stats errors */
#define TSK_ERR_BAD_NUM_WINDOWS -900
Expand Down
Loading