Skip to content

tskit C API 1.0 and associated changes - #248

Merged
bhaller merged 14 commits into
masterfrom
tsk_one_point_oh
Dec 8, 2021
Merged

bhaller merged 14 commits into
masterfrom
tsk_one_point_oh

Conversation

@bhaller

@bhaller bhaller commented Nov 28, 2021

Copy link
Copy Markdown
Contributor

Fixes #247 (or will when it's done!).

At present, this merges in a prerelease commit of tskit, just to get the ball rolling and see how things go. I don't plan to merge this PR in until it has the final release version of tskit C API 1.0; until then, I'll just fix other bugs in this PR that depend upon the new tskit changes (see #247 for links to those bugs).

@bhaller

bhaller commented Nov 28, 2021 •

Copy link
Copy Markdown
Contributor Author

With this first commit, it builds fine except for one error: "No member named left_root in tsk_tree_t". This occurs in method SLiMSim::CheckCoalescenceAfterSimplification(), at line slim_sim.cpp:5594. That code is trying to determine whether our tree sequence has coalesced or not. Here's the context:

	for (; (ret == 1) && fully_coalesced; ret = tsk_tree_next(&t))
	{
#if 0
		// If we didn't keep first-generation lineages, or remember genomes, >1 root would mean not coalesced
		if (t.right_sib[t.left_root] != TSK_NULL)
		{
			fully_coalesced = false;
			break;
		}
#else
		// But we do have retained/remembered nodes in the tree, so we need to be smarter; nodes for the first gen
		// ancestors will always be present, giving >1 root in each tree even when we have coalesced, and the
		// remembered individuals may mean that more than one root node has children, too, even when we have
		// coalesced.  What we need to know is: how many roots are there that have >0 *extant* children?  This
		// is what we use the tracked samples for; they are extant individuals.
		for (tsk_id_t root = t.left_root; root != TSK_NULL; root = t.right_sib[root])
		{
			int64_t num_tracked = t.num_tracked_samples[root];
			
			if ((num_tracked > 0) && (num_tracked < extant_node_count))
			{
				fully_coalesced = false;
				break;
			}
		}
#endif
	}

Indeed, left_root no longer seems to exist. I'm guessing this has to do with the changes for the "virtual root"? I have no idea what the appropriate fix is. @petrelharp do you know what the deal is here? I believe you are the author of this coalescence checking code, I have no idea what it's doing. :->

[ EDIT: I commented out the entirety of CheckCoalescenceAfterSimplification() for now, so that things compile, so that I can proceed with other work on this branch that doesn't depend upon coalescence checking... ]

@bhaller

bhaller commented Nov 28, 2021

Copy link
Copy Markdown
Contributor Author

(I have no idea how the "ui icon tweaks for better quality" commit weaselled its way into this PR; I could swear I pushed that commit before I made this branch. Bizarre. Well, it isn't doing any harm hanging out in here until this gets merged...)

@bhaller

bhaller commented Nov 28, 2021

Copy link
Copy Markdown
Contributor Author

Just added a call to tsk_table_collection_set_time_units() to set the time unit, on save. I decided to set it to "tick" rather than "generation", in anticipation of planned changes for multispecies (when the general time unit will, in fact, be a "tick"), and because "generation" is a bit misleading for nonWF models anyway – SLiM should never have used that term, in hindsight, but that ship sailed long ago.

Anyhow, the orthogonal question is whether it should be "tick" or "ticks"; @benjeffery is there a stated preference for this, regarding singular vs. plural?

@petrelharp

petrelharp commented Nov 29, 2021 •

Copy link
Copy Markdown
Collaborator

For the first use of left_root, it looks like we're just checking whether there's more than one root, so we can use tree.get_num_roots() instead?, So, I think, instead of

		if (t.right_sib[t.left_root] != TSK_NULL)

do

		if (tsk_tree_get_num_roots(&t) > 1)

And, for the second one, I think we can do instead of

		for (tsk_id_t root = t.left_root; root != TSK_NULL; root = t.right_sib[root])

use get_left_root:

		for (tsk_id_t root = tsk_tree_get_left_root(&t); root != TSK_NULL; root = t.right_sib[root])

@bhaller

bhaller commented Nov 29, 2021

Copy link
Copy Markdown
Contributor Author

For the first use of left_root...

Yep, those fixes seem good, thanks @petrelharp.

@benjeffery

Copy link
Copy Markdown

@benjeffery is there a stated preference for this, regarding singular vs. plural?

Plural seems to be the way to go, as I've seen "generations" "seconds" etc suggested.

@bhaller

bhaller commented Dec 7, 2021

Copy link
Copy Markdown
Contributor Author

Just an update: the tskit_one_point_oh branch has been updated to tskit 0.99.15, and appropriate fixes have been put in to match the changes done on the tskit side with respect to reading/writing the reference sequence. Changes pushed to GitHub. Seems good so far; running the full test suite now, which takes several hours.

@bhaller

bhaller commented Dec 8, 2021

Copy link
Copy Markdown
Contributor Author

OK, all tests passed, including with crosscheck enabled. Good to go. I'm going to merge this branch in, since 0.99.15 is an official tskit release and there seem to be no problems with it. We'll merge in C API 1.0 in a separate pass when the time comes.

@bhaller
bhaller merged commit 1df1831 into master Dec 8, 2021
@bhaller
bhaller deleted the tsk_one_point_oh branch December 8, 2021 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pull in tskit C API 1.0

3 participants