neherlab / treetime

Maximum likelihood inference of time stamped phylogenies and ancestral reconstruction
MIT License
222 stars 55 forks source link

Binary Sequence Alignement #245

Open adrienlemeur opened 1 year ago

adrienlemeur commented 1 year ago

Hello, Do you consider adding binary alignement / models ? Thanks,

Adrien

rneher commented 1 year ago

this is possible in a script when using TreeTime as a library. But it is currently not exposed to the command line. If this is an option for you, I can give you a few pointers.

adrienlemeur commented 1 year ago

Oh thank you ! I was afraid that treetime was a C library but I should be fine with Python ! Is is straightforward ?

rneher commented 1 year ago

when you use TreeTime as a library, you set it up like this (for ancestral sequence reconstruction, time trees follow a similar pattern with with TreeTime instead of TreeAnc):

https://github.com/neherlab/treetime_examples/blob/master/scripts/ancestral_sequence_inference.py#L15

Instead of Jukes-Cantor, you can feed the gtr argument a GTR model. to make a binary model, you should be able to do

from treetime import GTR

myGTR = GTR.custom(alphabet=['a', 'b'])

see the constructor here:

https://github.com/neherlab/treetime/blob/master/treetime/gtr.py#L278