Skip to content
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

nextSpeciesBranchNumber < 0 #4

Closed
Anaphory opened this issue Mar 1, 2019 · 5 comments
Closed

nextSpeciesBranchNumber < 0 #4

Anaphory opened this issue Mar 1, 2019 · 5 comments

Comments

@Anaphory
Copy link

Anaphory commented Mar 1, 2019

After wondering why I get so many NullPointerExceptions,

	at speciesnetwork.GeneTreeInSpeciesNetwork.recurseCoalescentEvents(GeneTreeInSpeciesNetwork.java:158)
	at speciesnetwork.GeneTreeInSpeciesNetwork.recurseCoalescentEvents(GeneTreeInSpeciesNetwork.java:158)
	at speciesnetwork.GeneTreeInSpeciesNetwork.recurseCoalescentEvents(GeneTreeInSpeciesNetwork.java:158)
	at speciesnetwork.GeneTreeInSpeciesNetwork.recurseCoalescentEvents(GeneTreeInSpeciesNetwork.java:158)
	at speciesnetwork.GeneTreeInSpeciesNetwork.recurseCoalescentEvents(GeneTreeInSpeciesNetwork.java:158)
	at speciesnetwork.GeneTreeInSpeciesNetwork.recurseCoalescentEvents(GeneTreeInSpeciesNetwork.java:158)
	at speciesnetwork.GeneTreeInSpeciesNetwork.update(GeneTreeInSpeciesNetwork.java:117)
	at speciesnetwork.GeneTreeInSpeciesNetwork.computeCoalescentTimes(GeneTreeInSpeciesNetwork.java:96)
	at speciesnetwork.MultispeciesCoalescent.calculateLogP(MultispeciesCoalescent.java:90)
	at beast.core.util.CompoundDistribution.calculateLogP(CompoundDistribution.java:114)
	at beast.core.MCMC.propagateState(MCMC.java:496)
	at beast.core.MCMC.doLoop(MCMC.java:383)
	at beast.core.MCMC.run(MCMC.java:353)
	at beast.app.BeastMCMC.run(BeastMCMC.java:357)
	at beast.app.beastapp.BeastMain.<init>(BeastMain.java:113)
	at beast.app.beastapp.BeastMain.main(BeastMain.java:659)

I noticed the assertions in

assert (nextSpeciesBranchNumber >= 0);

and below and activated assertions in the JVM, which led to Exception in thread "main" java.lang.AssertionError at speciesnetwork.GeneTreeInSpeciesNetwork.recurseCoalescentEvents(GeneTreeInSpeciesNetwork.java:147).

I don't know how traversal numbers should behave and what the getDirection function is supposed to do,

        final int traversalNodeNumber = speciesNetworkNode.getTraversalNumber();
        final Integer nextSpeciesBranchNumber = geneTree.embedding.getDirection(geneTreeNodeNumber, traversalNodeNumber);

but the calls above that look reasonable.
@zhangchicool I sent you my XML files that produce this issue, in case that might help track down the problem because it's a user error.

@Anaphory
Copy link
Author

I just cloned the speciesnetwork repository, and that assertion fails even in the JUnit tests in snetworktests. I guess something is broken in the implementation?

@Anaphory
Copy link
Author

It looks to me (who still doesn't know anything about what's going on in the package) like the issue might have to do with the construction of Embeddings. When a new Embedding is created for a GeneTreeInSpeciesNetwork, that Embedding does not seem to be initialized unless the gene tree is loaded from XML. In that case, the setDirection method is called.

Other than that, setDirection is only called by a test helper, some simulation code, and one deep if-branch inside the RebuildEmbedding operator's recurseRebuild method, so I assume Embedding initialization is missing.

@zhangchicool
Copy link
Owner

I just cloned the speciesnetwork repository, and that assertion fails even in the JUnit tests in snetworktests. I guess something is broken in the implementation?

AllTests passed for me.
Screen Shot 2019-03-19 at 8 15 57 AM
The test_3s.xml also runs fine for me.

I guess you are using a modified xml which has some faulty elements inside. Usually it is error-prone to build one by hand. On the other hand, the package is not mature currently and it is likely to miss some specific functionality.

It is reasonable to build the embedding when both the gene tree and species network are available. Without the gene tree, there is no embedding exist. I guess this is reason you get this error.

@Anaphory
Copy link
Author

Hm, weird. Now I see the tests succed as well, but it appears the only changes I reverted were some tries related to #5 which were half-baked enough that they prevented compilation anyway…

Sorry to fill in this confusing issue.

Can you explain Embedding's initialization and getDirection to me so I can dig deeper and find out what is going on?

@zhangchicool
Copy link
Owner

I'm sorry for the lack of response. A lot of things have been going on, and some related code has been lost. Closing this issue anyway...

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

No branches or pull requests

2 participants