Skip to content

Commit cd8d650

Browse files
committed
Merge branch 'master' into multitrait
2 parents b18cadf + 79e4bf2 commit cd8d650

7 files changed

Lines changed: 56 additions & 116 deletions

File tree

VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Note that not every commit will be logged here; that is what the Github commit h
77

88
development head (in the master branch):
99
add a rmultinom() function to draw from a multinomial distribution, matching rmultinom() in R
10+
update to tskit 1.0.3, kastore 0.3.5, to get final changes for the json_struct codec stuff (no longer directly supported in C)
1011

1112

1213
multitrait branch:

treerec/tskit/core.c

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -141,66 +141,6 @@ tsk_generate_uuid(char *dest, int TSK_UNUSED(flags))
141141
return ret;
142142
}
143143

144-
int
145-
tsk_json_struct_metadata_get_blob(char *metadata, tsk_size_t metadata_length,
146-
char **json, tsk_size_t *json_length, char **blob,
147-
tsk_size_t *blob_length)
148-
{
149-
int ret;
150-
uint8_t version;
151-
uint64_t json_length_u64;
152-
uint64_t binary_length_u64;
153-
uint64_t header_and_json_length;
154-
uint64_t total_length;
155-
uint8_t *bytes;
156-
char *blob_start;
157-
char *json_start;
158-
159-
if (metadata == NULL || json == NULL || json_length == NULL || blob == NULL
160-
|| blob_length == NULL) {
161-
ret = tsk_trace_error(TSK_ERR_BAD_PARAM_VALUE);
162-
goto out;
163-
}
164-
bytes = (uint8_t *) metadata;
165-
if (metadata_length < TSK_JSON_BINARY_HEADER_SIZE) {
166-
ret = tsk_trace_error(TSK_ERR_JSON_STRUCT_METADATA_TRUNCATED);
167-
goto out;
168-
}
169-
if (memcmp(bytes, _tsk_json_binary_magic, sizeof(_tsk_json_binary_magic)) != 0) {
170-
ret = tsk_trace_error(TSK_ERR_JSON_STRUCT_METADATA_BAD_MAGIC);
171-
goto out;
172-
}
173-
version = bytes[4];
174-
if (version != 1) {
175-
ret = tsk_trace_error(TSK_ERR_JSON_STRUCT_METADATA_BAD_VERSION);
176-
goto out;
177-
}
178-
json_length_u64 = tsk_load_u64_le(bytes + 5);
179-
binary_length_u64 = tsk_load_u64_le(bytes + 13);
180-
if (json_length_u64 > UINT64_MAX - (uint64_t) TSK_JSON_BINARY_HEADER_SIZE) {
181-
ret = tsk_trace_error(TSK_ERR_JSON_STRUCT_METADATA_INVALID_LENGTH);
182-
goto out;
183-
}
184-
header_and_json_length = (uint64_t) TSK_JSON_BINARY_HEADER_SIZE + json_length_u64;
185-
if (binary_length_u64 > UINT64_MAX - header_and_json_length) {
186-
ret = tsk_trace_error(TSK_ERR_JSON_STRUCT_METADATA_INVALID_LENGTH);
187-
goto out;
188-
}
189-
total_length = header_and_json_length + binary_length_u64;
190-
if ((uint64_t) metadata_length < total_length) {
191-
ret = tsk_trace_error(TSK_ERR_JSON_STRUCT_METADATA_TRUNCATED);
192-
goto out;
193-
}
194-
json_start = (char *) bytes + TSK_JSON_BINARY_HEADER_SIZE;
195-
blob_start = (char *) bytes + TSK_JSON_BINARY_HEADER_SIZE + json_length_u64;
196-
*json = json_start;
197-
*json_length = (tsk_size_t) json_length_u64;
198-
*blob = blob_start;
199-
*blob_length = (tsk_size_t) binary_length_u64;
200-
ret = 0;
201-
out:
202-
return ret;
203-
}
204144
static const char *
205145
tsk_strerror_internal(int err)
206146
{

treerec/tskit/haplotype_matching.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -572,15 +572,15 @@ static inline bool
572572
element_in(
573573
const uint64_t *restrict A, tsk_id_t u, const tsk_id_t state, tsk_size_t num_words)
574574
{
575-
tsk_size_t index = ((tsk_size_t) u) * num_words + (tsk_size_t)(state / 64);
575+
tsk_size_t index = ((tsk_size_t) u) * num_words + (tsk_size_t) (state / 64);
576576
return (A[index] & (1ULL << (state % 64))) != 0;
577577
}
578578

579579
static inline void
580580
set_optimal_value(
581581
uint64_t *restrict A, tsk_id_t u, const tsk_size_t num_words, tsk_id_t state)
582582
{
583-
tsk_size_t index = ((tsk_size_t) u) * num_words + (tsk_size_t)(state / 64);
583+
tsk_size_t index = ((tsk_size_t) u) * num_words + (tsk_size_t) (state / 64);
584584
tsk_bug_assert(((tsk_size_t) state) / 64 < num_words);
585585
A[index] |= 1ULL << (state % 64);
586586
}
@@ -815,7 +815,7 @@ tsk_ls_hmm_redistribute_transitions(tsk_ls_hmm_t *self)
815815
* iterating over the roots. See the existing parsimony implementations
816816
* for an example. */
817817
for (root = tsk_tree_get_left_root(&self->tree); root != TSK_NULL;
818-
root = right_sib[root]) {
818+
root = right_sib[root]) {
819819
stack[0].tree_node = root;
820820
stack[0].old_state = T_old[T_index[root]].value_index;
821821
stack[0].new_state
@@ -966,7 +966,7 @@ tsk_ls_hmm_run_forward(tsk_ls_hmm_t *self, int32_t *haplotype)
966966
}
967967

968968
for (t_ret = tsk_tree_first(&self->tree); t_ret == TSK_TREE_OK;
969-
t_ret = tsk_tree_next(&self->tree)) {
969+
t_ret = tsk_tree_next(&self->tree)) {
970970
ret = tsk_ls_hmm_update_tree(self, TSK_DIR_FORWARD);
971971
if (ret != 0) {
972972
goto out;
@@ -1166,7 +1166,7 @@ tsk_ls_hmm_run_backward(
11661166
}
11671167

11681168
for (t_ret = tsk_tree_last(&self->tree); t_ret == TSK_TREE_OK;
1169-
t_ret = tsk_tree_prev(&self->tree)) {
1169+
t_ret = tsk_tree_prev(&self->tree)) {
11701170
ret = tsk_ls_hmm_update_tree(self, TSK_DIR_REVERSE);
11711171
if (ret != 0) {
11721172
goto out;
@@ -1492,7 +1492,7 @@ tsk_compressed_matrix_decode(tsk_compressed_matrix_t *self, double *values)
14921492
}
14931493

14941494
for (t_ret = tsk_tree_first(&tree); t_ret == TSK_TREE_OK;
1495-
t_ret = tsk_tree_next(&tree)) {
1495+
t_ret = tsk_tree_next(&tree)) {
14961496
ret = tsk_tree_get_sites(&tree, &sites, &num_tree_sites);
14971497
if (ret != 0) {
14981498
goto out;

treerec/tskit/kastore/kastore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ to the API or ABI are introduced, i.e., the addition of a new function.
157157
The library patch version. Incremented when any changes not relevant to the
158158
to the API or ABI are introduced, i.e., internal refactors of bugfixes.
159159
*/
160-
#define KAS_VERSION_PATCH 1
160+
#define KAS_VERSION_PATCH 2
161161
/** @} */
162162

163163
#define KAS_HEADER_SIZE 64

treerec/tskit/tables.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ check_offset_overflow(tsk_size_t current_size, tsk_size_t additional_elements)
100100
|| current_size > (max_val - additional_elements);
101101
}
102102

103-
#define TSK_NUM_ROWS_UNSET ((tsk_size_t) -1)
103+
#define TSK_NUM_ROWS_UNSET ((tsk_size_t) - 1)
104104
#define TSK_MAX_COL_NAME_LEN 64
105105

106106
static int
@@ -8255,8 +8255,8 @@ pair_to_integer(tsk_id_t a, tsk_id_t b, tsk_size_t N)
82558255
static inline void
82568256
integer_to_pair(int64_t index, tsk_size_t N, tsk_id_t *a, tsk_id_t *b)
82578257
{
8258-
*a = (tsk_id_t)(index / (int64_t) N);
8259-
*b = (tsk_id_t)(index % (int64_t) N);
8258+
*a = (tsk_id_t) (index / (int64_t) N);
8259+
*b = (tsk_id_t) (index % (int64_t) N);
82608260
}
82618261

82628262
static int64_t
@@ -8997,7 +8997,7 @@ simplifier_check_state(simplifier_t *self)
89978997
for (j = 0; j < self->input_tables.nodes.num_rows; j++) {
89988998
last_position = -1;
89998999
for (list_node = self->node_mutation_list_map_head[j]; list_node != NULL;
9000-
list_node = list_node->next) {
9000+
list_node = list_node->next) {
90019001
tsk_bug_assert(
90029002
self->input_tables.mutations.node[list_node->mutation] == (tsk_id_t) j);
90039003
site = self->input_tables.mutations.site[list_node->mutation];
@@ -9028,7 +9028,7 @@ simplifier_check_state(simplifier_t *self)
90289028
child = self->buffered_children[j];
90299029
tsk_bug_assert(self->child_edge_map_head[child] != NULL);
90309030
for (int_list = self->child_edge_map_head[child]; int_list != NULL;
9031-
int_list = int_list->next) {
9031+
int_list = int_list->next) {
90329032
tsk_bug_assert(int_list->left < int_list->right);
90339033
if (int_list->next != NULL) {
90349034
tsk_bug_assert(int_list->right < int_list->next->left);
@@ -9108,7 +9108,7 @@ simplifier_print_state(simplifier_t *self, FILE *out)
91089108
child = self->buffered_children[j];
91099109
fprintf(out, "%lld -> ", (long long) j);
91109110
for (int_list = self->child_edge_map_head[child]; int_list != NULL;
9111-
int_list = int_list->next) {
9111+
int_list = int_list->next) {
91129112
fprintf(out, "(%f, %f), ", int_list->left, int_list->right);
91139113
}
91149114
fprintf(out, "\n");
@@ -9123,7 +9123,7 @@ simplifier_print_state(simplifier_t *self, FILE *out)
91239123
if (self->node_mutation_list_map_head[j] != NULL) {
91249124
fprintf(out, "%lld\t-> [", (long long) j);
91259125
for (list_node = self->node_mutation_list_map_head[j]; list_node != NULL;
9126-
list_node = list_node->next) {
9126+
list_node = list_node->next) {
91279127
fprintf(out, "%lld,", (long long) list_node->mutation);
91289128
}
91299129
fprintf(out, "]\n");
@@ -10187,7 +10187,7 @@ simplifier_insert_input_roots(simplifier_t *self)
1018710187
const double *node_time = self->tables->nodes.time;
1018810188

1018910189
for (input_id = 0; input_id < (tsk_id_t) self->input_tables.nodes.num_rows;
10190-
input_id++) {
10190+
input_id++) {
1019110191
x = self->ancestor_map_head[input_id];
1019210192
if (x != NULL) {
1019310193
output_id = self->node_id_map[input_id];
@@ -10736,11 +10736,11 @@ tsk_table_collection_check_individual_integrity(
1073610736

1073710737
for (j = 0; j < (tsk_size_t) num_individuals; j++) {
1073810738
for (k = individuals.parents_offset[j]; k < individuals.parents_offset[j + 1];
10739-
k++) {
10739+
k++) {
1074010740
/* Check parent references are valid */
1074110741
if (individuals.parents[k] != TSK_NULL
1074210742
&& (individuals.parents[k] < 0
10743-
|| individuals.parents[k] >= num_individuals)) {
10743+
|| individuals.parents[k] >= num_individuals)) {
1074410744
ret = tsk_trace_error(TSK_ERR_INDIVIDUAL_OUT_OF_BOUNDS);
1074510745
goto out;
1074610746
}
@@ -11250,20 +11250,20 @@ tsk_table_collection_equals(const tsk_table_collection_t *self,
1125011250
if (!(options & TSK_CMP_IGNORE_TABLES)) {
1125111251
ret = ret
1125211252
&& tsk_individual_table_equals(
11253-
&self->individuals, &other->individuals, options)
11253+
&self->individuals, &other->individuals, options)
1125411254
&& tsk_node_table_equals(&self->nodes, &other->nodes, options)
1125511255
&& tsk_edge_table_equals(&self->edges, &other->edges, options)
1125611256
&& tsk_migration_table_equals(
11257-
&self->migrations, &other->migrations, options)
11257+
&self->migrations, &other->migrations, options)
1125811258
&& tsk_site_table_equals(&self->sites, &other->sites, options)
1125911259
&& tsk_mutation_table_equals(&self->mutations, &other->mutations, options)
1126011260
&& tsk_population_table_equals(
11261-
&self->populations, &other->populations, options);
11261+
&self->populations, &other->populations, options);
1126211262
/* TSK_CMP_IGNORE_TABLES implies TSK_CMP_IGNORE_PROVENANCE */
1126311263
if (!(options & TSK_CMP_IGNORE_PROVENANCE)) {
1126411264
ret = ret
1126511265
&& tsk_provenance_table_equals(
11266-
&self->provenances, &other->provenances, options);
11266+
&self->provenances, &other->provenances, options);
1126711267
}
1126811268
}
1126911269
/* TSK_CMP_IGNORE_TS_METADATA is implied by TSK_CMP_IGNORE_METADATA */
@@ -11273,19 +11273,19 @@ tsk_table_collection_equals(const tsk_table_collection_t *self,
1127311273
if (!(options & TSK_CMP_IGNORE_TS_METADATA)) {
1127411274
ret = ret
1127511275
&& (self->metadata_length == other->metadata_length
11276-
&& self->metadata_schema_length == other->metadata_schema_length
11277-
&& tsk_memcmp(self->metadata, other->metadata,
11278-
self->metadata_length * sizeof(char))
11279-
== 0
11280-
&& tsk_memcmp(self->metadata_schema, other->metadata_schema,
11281-
self->metadata_schema_length * sizeof(char))
11282-
== 0);
11276+
&& self->metadata_schema_length == other->metadata_schema_length
11277+
&& tsk_memcmp(self->metadata, other->metadata,
11278+
self->metadata_length * sizeof(char))
11279+
== 0
11280+
&& tsk_memcmp(self->metadata_schema, other->metadata_schema,
11281+
self->metadata_schema_length * sizeof(char))
11282+
== 0);
1128311283
}
1128411284

1128511285
if (!(options & TSK_CMP_IGNORE_REFERENCE_SEQUENCE)) {
1128611286
ret = ret
1128711287
&& tsk_reference_sequence_equals(
11288-
&self->reference_sequence, &other->reference_sequence, options);
11288+
&self->reference_sequence, &other->reference_sequence, options);
1128911289
}
1129011290
return ret;
1129111291
}
@@ -12057,7 +12057,7 @@ tsk_table_collection_dumpf(
1205712057
{ "format/name", (const void *) &TSK_FILE_FORMAT_NAME,
1205812058
TSK_FILE_FORMAT_NAME_LENGTH, KAS_INT8 },
1205912059
{ "format/version",
12060-
(const void *) &(uint32_t[]){
12060+
(const void *) &(uint32_t[]) {
1206112061
TSK_FILE_FORMAT_VERSION_MAJOR, TSK_FILE_FORMAT_VERSION_MINOR },
1206212062
2, KAS_UINT32 },
1206312063
{ "sequence_length", (const void *) &self->sequence_length, 1, KAS_FLOAT64 },
@@ -13302,7 +13302,7 @@ tsk_table_collection_union(tsk_table_collection_t *self,
1330213302
/* Now we know the full individual map we can remap the parents of the new
1330313303
* individuals*/
1330413304
for (k = (tsk_id_t) self->individuals.parents_offset[num_individuals_self];
13305-
k < (tsk_id_t) self->individuals.parents_length; k++) {
13305+
k < (tsk_id_t) self->individuals.parents_length; k++) {
1330613306
if (self->individuals.parents[k] != TSK_NULL) {
1330713307
self->individuals.parents[k] = individual_map[self->individuals.parents[k]];
1330813308
}

treerec/tskit/tables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4607,7 +4607,7 @@ tsk_id_t tsk_table_collection_check_integrity(
46074607
/* Undocumented methods */
46084608

46094609
/* Flags for ibd_segments */
4610-
#define TSK_IBD_STORE_PAIRS (1 << 0)
4610+
#define TSK_IBD_STORE_PAIRS (1 << 0)
46114611
#define TSK_IBD_STORE_SEGMENTS (1 << 1)
46124612

46134613
/* TODO be systematic about where "result" should be in the params

0 commit comments

Comments
 (0)