Skip to content

Commit

Permalink
Add tree_pos to tsk_tree_t struct
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanMR committed Dec 5, 2023
1 parent 77faade commit bf2f3ac
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
6 changes: 6 additions & 0 deletions c/tskit/trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -4565,6 +4565,11 @@ tsk_tree_init(tsk_tree_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t
goto out;
}
}

ret = tsk_tree_position_init(&self->tree_pos, tree_sequence, 0);
if (ret != 0) {
goto out;

Check warning on line 4571 in c/tskit/trees.c

View check run for this annotation

Codecov / codecov/patch

c/tskit/trees.c#L4571

Added line #L4571 was not covered by tests
}
ret = tsk_tree_clear(self);
out:
return ret;
Expand Down Expand Up @@ -4613,6 +4618,7 @@ tsk_tree_free(tsk_tree_t *self)
tsk_safe_free(self->next_sample);
tsk_safe_free(self->num_children);
tsk_safe_free(self->edge);
tsk_tree_position_free(&self->tree_pos);
return 0;
}

Expand Down
48 changes: 23 additions & 25 deletions c/tskit/trees.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ typedef struct {
tsk_table_collection_t *tables;
} tsk_treeseq_t;

typedef struct {
tsk_id_t index;
struct {
double left;
double right;
} interval;
struct {
tsk_id_t start;
tsk_id_t stop;
const tsk_id_t *order;
} in;
struct {
tsk_id_t start;
tsk_id_t stop;
const tsk_id_t *order;
} out;
tsk_id_t left_current_index;
tsk_id_t right_current_index;
int direction;
const tsk_treeseq_t *tree_sequence;
} tsk_tree_position_t;

/**
@brief A single tree in a tree sequence.
Expand Down Expand Up @@ -256,6 +278,7 @@ typedef struct {
int direction;
tsk_id_t left_index;
tsk_id_t right_index;
tsk_tree_position_t tree_pos;
} tsk_tree_t;

/****************************************************************************/
Expand Down Expand Up @@ -1823,31 +1846,6 @@ bool tsk_tree_equals(const tsk_tree_t *self, const tsk_tree_t *other);
int tsk_diff_iter_init_from_ts(
tsk_diff_iter_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t options);

/* Temporarily putting this here to avoid problems with doxygen. Will need to
* move up the file later when it gets incorporated into the tsk_tree_t object.
*/
typedef struct {
tsk_id_t index;
struct {
double left;
double right;
} interval;
struct {
tsk_id_t start;
tsk_id_t stop;
const tsk_id_t *order;
} in;
struct {
tsk_id_t start;
tsk_id_t stop;
const tsk_id_t *order;
} out;
tsk_id_t left_current_index;
tsk_id_t right_current_index;
int direction;
const tsk_treeseq_t *tree_sequence;
} tsk_tree_position_t;

int tsk_tree_position_init(
tsk_tree_position_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t options);
int tsk_tree_position_free(tsk_tree_position_t *self);
Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ sphinx:
["c:identifier", "FILE"],
["c:identifier", "bool"],
# This is for the anonymous interval struct embedded in the tsk_tree_t.
["c:identifier", "tsk_tree_t.@1"],
["c:identifier", "tsk_tree_t.@4"],
["c:type", "int32_t"],
["c:type", "uint32_t"],
["c:type", "uint64_t"],
Expand Down

0 comments on commit bf2f3ac

Please sign in to comment.