veg / hyphy

HyPhy: Hypothesis testing using Phylogenies
http://www.hyphy.org
Other
209 stars 69 forks source link

Segmentation fault when attempting to print a model #685

Closed halabikeren closed 6 years ago

halabikeren commented 6 years ago

Dear team,

Thank you for providing us with the relax simulator (relaxSim.bf). We have modified the code a little bit for our needs. In addition, we run the code using HyPhy version 2.3.4, and we encounter some problems concerning the load of a model to the tree. When debugging this, we tried to print out the Test model (denoted FG) and a segmentation fault occurred. This is following lines that are originally from relaxSim.bf

Model FG = ("Exp(MGMatrix1)*p1+Exp(MGMatrix2)*(1-p1)*p2+Exp(MGMatrix3)*(1-p1)*(1-p2)",codon3x4,EXPLICIT_FORM_MATRIX_EXPONENTIAL); fprintf(stdout, "FG model: ", FG, "\n"); // debug

Please find attached the full TraitRELAX simulator, including the print statement that results in a segmentation fault (line 595).

TraitRELAX_simulator.txt

Could you please help us understand the source of this issue?

Thank you very much, Eli and Keren

spond commented 6 years ago

Dear @halabikeren,

This error is due to the fact that models are not first-class objects in the current version of HBL. Try using this code instead

replace

fprintf(stdout, "FG model: ", FG, "\n");

with

Export (serialized_model, FG);
fprintf (stdout, serialized_model, "\n");

Best, Sergei

halabikeren commented 6 years ago

Thank you, Sergei!

I did as you suggested and was able to print out the model.

Unfortunately, now receive another segmentation fault as a result of creating a tree instance after setting a mixture model. Specifically, the following lines trigger the error:

Model BG = ("Exp(MGMatrixBG1)*p1+Exp(MGMatrixBG2)*(1-p1)*p2+Exp(MGMatrixBG3)*(1-p1)*(1-p2)",codon3x4,EXPLICIT_FORM_MATRIX_EXPONENTIAL);

Tree T = "((S1:1,S2:1)N1:1,S3:1,S4:2);";

Please find attached the code I used to reproduce the issue (simulator.txt) and an additional, reduced, code segment in which the error is not reproducible (reproduce_fail.txt). I'm don't know which difference between the two causes the segmentation fault.

simulator.txt reproduce_fail.txt

Thanks! Keren

spond commented 6 years ago

Dear @halabikeren,

This issue has been resolved via commit 969da2f to the beta branch. It had to do with HyPhy trying to obtain a branch length expression from the explicit exponential form model for automatic branch length conversion, which can't be done with the current implementation.

Best, Sergei