Skip to content

Commit 4518db4

Browse files
authored
Merge pull request #28 from molpopgen/update_to_tskit_0_3_5
Update C files to tskit 0.3.5
2 parents e81aad0 + 8089356 commit 4518db4

File tree

8 files changed

+1229
-270
lines changed

8 files changed

+1229
-270
lines changed

subprojects/tskit/tskit/core.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ tsk_strerror_internal(int err)
281281
case TSK_ERR_MUTATION_PARENT_AFTER_CHILD:
282282
ret = "Parent mutation ID must be < current ID";
283283
break;
284-
case TSK_ERR_INCONSISTENT_MUTATIONS:
285-
ret = "Inconsistent mutations: state already equal to derived state";
284+
case TSK_ERR_MUTATION_PARENT_INCONSISTENT:
285+
ret = "Mutation parent references form a loop.";
286286
break;
287287
case TSK_ERR_UNSORTED_MUTATIONS:
288288
ret = "Mutations must be provided in non-decreasing site order and "
@@ -357,10 +357,6 @@ tsk_strerror_internal(int err)
357357
case TSK_ERR_NONBINARY_MUTATIONS_UNSUPPORTED:
358358
ret = "Only binary mutations are supported for this operation";
359359
break;
360-
case TSK_ERR_UNION_NOT_SUPPORTED:
361-
ret = "Union is not supported for cases where there is non-shared"
362-
"history older than the shared history of the two Table Collections";
363-
break;
364360

365361
/* Stats errors */
366362
case TSK_ERR_BAD_NUM_WINDOWS:
@@ -470,6 +466,25 @@ tsk_strerror_internal(int err)
470466
case TSK_ERR_DUPLICATE_SAMPLE_PAIRS:
471467
ret = "There are duplicate sample pairs.";
472468
break;
469+
470+
/* Simplify errors */
471+
case TSK_ERR_KEEP_UNARY_MUTUALLY_EXCLUSIVE:
472+
ret = "You cannot specify both KEEP_UNARY and KEEP_UNARY_IN_INDIVDUALS.";
473+
break;
474+
475+
/* Individual errors */
476+
case TSK_ERR_UNSORTED_INDIVIDUALS:
477+
ret = "Individuals must be provided in an order where children are after "
478+
"their parent individuals";
479+
break;
480+
481+
case TSK_ERR_INDIVIDUAL_SELF_PARENT:
482+
ret = "Individuals cannot be their own parents.";
483+
break;
484+
485+
case TSK_ERR_INDIVIDUAL_PARENT_CYCLE:
486+
ret = "Individuals cannot be their own ancestor.";
487+
break;
473488
}
474489
return ret;
475490
}

subprojects/tskit/tskit/core.h

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ to the API or ABI are introduced, i.e., the addition of a new function.
129129
The library patch version. Incremented when any changes not relevant to the
130130
to the API or ABI are introduced, i.e., internal refactors of bugfixes.
131131
*/
132-
#define TSK_VERSION_PATCH 9
132+
#define TSK_VERSION_PATCH 11
133133
/** @} */
134134

135135
/* Node flags */
@@ -144,7 +144,7 @@ to the API or ABI are introduced, i.e., internal refactors of bugfixes.
144144
#define TSK_FILE_FORMAT_NAME "tskit.trees"
145145
#define TSK_FILE_FORMAT_NAME_LENGTH 11
146146
#define TSK_FILE_FORMAT_VERSION_MAJOR 12
147-
#define TSK_FILE_FORMAT_VERSION_MINOR 3
147+
#define TSK_FILE_FORMAT_VERSION_MINOR 4
148148

149149
/**
150150
@defgroup GENERAL_ERROR_GROUP General errors.
@@ -246,13 +246,13 @@ not found in the file.
246246
#define TSK_ERR_MUTATION_PARENT_DIFFERENT_SITE -500
247247
#define TSK_ERR_MUTATION_PARENT_EQUAL -501
248248
#define TSK_ERR_MUTATION_PARENT_AFTER_CHILD -502
249-
#define TSK_ERR_INCONSISTENT_MUTATIONS -503
250-
#define TSK_ERR_UNSORTED_MUTATIONS -505
251-
#define TSK_ERR_NON_SINGLE_CHAR_MUTATION -506
252-
#define TSK_ERR_MUTATION_TIME_YOUNGER_THAN_NODE -507
253-
#define TSK_ERR_MUTATION_TIME_OLDER_THAN_PARENT_MUTATION -508
254-
#define TSK_ERR_MUTATION_TIME_OLDER_THAN_PARENT_NODE -509
255-
#define TSK_ERR_MUTATION_TIME_HAS_BOTH_KNOWN_AND_UNKNOWN -510
249+
#define TSK_ERR_MUTATION_PARENT_INCONSISTENT -503
250+
#define TSK_ERR_UNSORTED_MUTATIONS -504
251+
#define TSK_ERR_NON_SINGLE_CHAR_MUTATION -505
252+
#define TSK_ERR_MUTATION_TIME_YOUNGER_THAN_NODE -506
253+
#define TSK_ERR_MUTATION_TIME_OLDER_THAN_PARENT_MUTATION -507
254+
#define TSK_ERR_MUTATION_TIME_OLDER_THAN_PARENT_NODE -508
255+
#define TSK_ERR_MUTATION_TIME_HAS_BOTH_KNOWN_AND_UNKNOWN -509
256256

257257
/* Sample errors */
258258
#define TSK_ERR_DUPLICATE_SAMPLE -600
@@ -274,7 +274,6 @@ not found in the file.
274274
#define TSK_ERR_SORT_OFFSET_NOT_SUPPORTED -803
275275
#define TSK_ERR_NONBINARY_MUTATIONS_UNSUPPORTED -804
276276
#define TSK_ERR_MIGRATIONS_NOT_SUPPORTED -805
277-
#define TSK_ERR_UNION_NOT_SUPPORTED -806
278277

279278
/* Stats errors */
280279
#define TSK_ERR_BAD_NUM_WINDOWS -900
@@ -320,6 +319,14 @@ not found in the file.
320319
#define TSK_ERR_NO_SAMPLE_PAIRS -1500
321320
#define TSK_ERR_DUPLICATE_SAMPLE_PAIRS -1501
322321

322+
/* Simplify errors */
323+
#define TSK_ERR_KEEP_UNARY_MUTUALLY_EXCLUSIVE -1600
324+
325+
/* Individual errors */
326+
#define TSK_ERR_UNSORTED_INDIVIDUALS -1700
327+
#define TSK_ERR_INDIVIDUAL_SELF_PARENT -1701
328+
#define TSK_ERR_INDIVIDUAL_PARENT_CYCLE -1702
329+
323330
// clang-format on
324331

325332
/* This bit is 0 for any errors originating from kastore */

subprojects/tskit/tskit/genotypes.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ tsk_vargen_init(tsk_vargen_t *self, const tsk_treeseq_t *tree_sequence,
159159
memset(self, 0, sizeof(tsk_vargen_t));
160160

161161
if (samples == NULL) {
162+
self->samples = tsk_treeseq_get_samples(tree_sequence);
162163
self->num_samples = tsk_treeseq_get_num_samples(tree_sequence);
163164
self->sample_index_map = tsk_treeseq_get_sample_index_map(tree_sequence);
164165
num_samples_alloc = self->num_samples;
@@ -171,6 +172,7 @@ tsk_vargen_init(tsk_vargen_t *self, const tsk_treeseq_t *tree_sequence,
171172
if (ret != 0) {
172173
goto out;
173174
}
175+
self->samples = samples;
174176
self->num_samples = num_samples;
175177
self->sample_index_map = self->alt_sample_index_map;
176178
}
@@ -319,10 +321,7 @@ tsk_vargen_update_genotypes_i8_sample_list(
319321
if (index != TSK_NULL) {
320322
stop = list_right[node];
321323
while (true) {
322-
if (genotypes[index] == (int8_t) derived) {
323-
ret = TSK_ERR_INCONSISTENT_MUTATIONS;
324-
goto out;
325-
}
324+
326325
ret += genotypes[index] == TSK_MISSING_DATA;
327326
genotypes[index] = (int8_t) derived;
328327
if (index == stop) {
@@ -331,7 +330,7 @@ tsk_vargen_update_genotypes_i8_sample_list(
331330
index = list_next[index];
332331
}
333332
}
334-
out:
333+
335334
return ret;
336335
}
337336

@@ -352,10 +351,7 @@ tsk_vargen_update_genotypes_i16_sample_list(
352351
if (index != TSK_NULL) {
353352
stop = list_right[node];
354353
while (true) {
355-
if (genotypes[index] == (int16_t) derived) {
356-
ret = TSK_ERR_INCONSISTENT_MUTATIONS;
357-
goto out;
358-
}
354+
359355
ret += genotypes[index] == TSK_MISSING_DATA;
360356
genotypes[index] = (int16_t) derived;
361357
if (index == stop) {
@@ -364,7 +360,7 @@ tsk_vargen_update_genotypes_i16_sample_list(
364360
index = list_next[index];
365361
}
366362
}
367-
out:
363+
368364
return ret;
369365
}
370366

@@ -420,13 +416,10 @@ tsk_vargen_visit_i8(tsk_vargen_t *self, tsk_id_t sample_index, tsk_id_t derived)
420416

421417
tsk_bug_assert(derived < INT8_MAX);
422418
tsk_bug_assert(sample_index != -1);
423-
if (genotypes[sample_index] == (int8_t) derived) {
424-
ret = TSK_ERR_INCONSISTENT_MUTATIONS;
425-
goto out;
426-
}
419+
427420
ret = genotypes[sample_index] == TSK_MISSING_DATA;
428421
genotypes[sample_index] = (int8_t) derived;
429-
out:
422+
430423
return ret;
431424
}
432425

@@ -438,13 +431,10 @@ tsk_vargen_visit_i16(tsk_vargen_t *self, tsk_id_t sample_index, tsk_id_t derived
438431

439432
tsk_bug_assert(derived < INT16_MAX);
440433
tsk_bug_assert(sample_index != -1);
441-
if (genotypes[sample_index] == (int16_t) derived) {
442-
ret = TSK_ERR_INCONSISTENT_MUTATIONS;
443-
goto out;
444-
}
434+
445435
ret = genotypes[sample_index] == TSK_MISSING_DATA;
446436
genotypes[sample_index] = (int16_t) derived;
447-
out:
437+
448438
return ret;
449439
}
450440

subprojects/tskit/tskit/genotypes.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ typedef struct {
5252
size_t num_samples;
5353
size_t num_sites;
5454
const tsk_treeseq_t *tree_sequence;
55-
const tsk_id_t *sample_index_map;
56-
tsk_id_t *alt_samples;
57-
tsk_id_t *alt_sample_index_map;
55+
const tsk_id_t *samples; /* samples being used */
56+
const tsk_id_t *sample_index_map; /* reverse index map being used */
5857
bool user_alleles;
5958
char *user_alleles_mem;
6059
size_t tree_site_index;
@@ -63,6 +62,9 @@ typedef struct {
6362
tsk_tree_t tree;
6463
tsk_flags_t options;
6564
tsk_variant_t variant;
65+
// private: the following data members are not intended to be used externally
66+
tsk_id_t *alt_samples; /* alternative subset of samples to use */
67+
tsk_id_t *alt_sample_index_map;
6668
} tsk_vargen_t;
6769

6870
int tsk_vargen_init(tsk_vargen_t *self, const tsk_treeseq_t *tree_sequence,

0 commit comments

Comments
 (0)