Import color scheme file format?

3,139 views
Skip to first unread message

Terry Jones

unread,
Jan 26, 2017, 10:06:30 AM1/26/17
to FigTree Discussion
Has anyone figured our the file format to use to provide a file for the File / Import Colour Scheme menu item? FigTree seems to give no hint as to what this might be, and there's no export of a colour scheme. One solution I could take is to write some code to edit the Nexus file FigTree saves, but it seems there must be a simpler option. I've looked in this group and see this question has been asked multiple times but never received an answer.... :-(  Surely it can't be that hard to give us a hint?  I tried making a simple file with a taxon name and a hex color string after it, but Import Colour Scheme gives an error popup: "Error reading characters file: DATA or CHARACTERS block is missing". I tried making a Nexus file with just a taxa block. The node annotations file is apparently TAB-separated text, so maybe a colour scheme file is too (but then why the error about the missing "block"?).

I don't mean to complain, because I write a lot of code myself and don't like writing docs, but it would probably take someone about one minute to paste in a self-explanatory colour scheme file here... I just spent 30 mins googling around and trying things, and got nowhere. Others have obviously done the same. I'm happy to write and release a tool to help people re-colour FigTree Nexus files. But a tiny bit of input from those in the know could really help here :-)

Thanks in any case!

Terry

Andrew Rambaut

unread,
Jan 26, 2017, 10:15:56 AM1/26/17
to figtree...@googlegroups.com
Hi Terry,

I am sorry for the confusion but the Import Colour Scheme function hasn’t been implemented yet. I added it as a menu item in my development version, didn’t finish it, and forgot to hide it for the last release. It is on my list for future releases (either to remove the option or implement it).

The colours in the Nexus file are given as a 32-bit integer where bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue. Because bit 31 is used this can be a negative number. This is how Java exports it and I hadn’t intended it to be editable when I originally did it. It would
be useful if these were in standard RGB hex format and I will try to switch to that in a future release.

Best,
Andrew

--
You received this message because you are subscribed to the Google Groups "FigTree Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to figtree-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Terry Jones

unread,
Jan 26, 2017, 10:23:57 AM1/26/17
to figtree...@googlegroups.com
Hi Andrew

Thanks for the reply, that's great :-)

I noticed that when I color a node in FigTree and then use Save, a Nexus file is created (my original file is just Newick) and it has a taxa section that looks (in part) like

begin taxa;
        dimensions ntax=154;
        taxlabels
        DA119[&!color=#ff0000]
        'DA119_10_2803_AY233280.1'
        'DA119_2_2861_KP234052.1'

Those are RGB values (I coloured that node red).  So it seems that one easy option for people would be to use Save, and then they could re-colour the Nexus file and reload it. It's a bit of a hack, but it's easy to do.  I just started to write a quick script to do that - shouldn't take long. When/if it works I'll post it here.

Thanks again!
Terry


To unsubscribe from this group and stop receiving emails from it, send an email to figtree-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "FigTree Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to figtree-discuss+unsubscribe@googlegroups.com.

Andrew Rambaut

unread,
Jan 26, 2017, 10:27:01 AM1/26/17
to figtree...@googlegroups.com, Terry Jones
You are right these are RGB hexcode values. Ignore the bit about the 32-bit integer - I obviously sensibly changed it to hexcodes and forgot I had done it.

Best,
Andrew

To unsubscribe from this group and stop receiving emails from it, send an email to figtree-discu...@googlegroups.com.

Terry Jones

unread,
Jan 26, 2017, 12:45:17 PM1/26/17
to FigTree Discussion, te...@jon.es, a.ra...@ed.ac.uk
OK, here's a quick Python script that makes it pretty easy to re-color the Nexus file saved by FigTree: https://github.com/acorg/figtree-recolor

It's probably not bullet-proof. Normally I'd write tests etc., but I have a bunch of other stuff to get done (typical dinosaur programmer justification for cutting corners). Anyway, it seems to work.

Terry

Terry Jones

unread,
Jan 26, 2017, 12:57:42 PM1/26/17
to FigTree Discussion, te...@jon.es, a.ra...@ed.ac.uk
BTW, I embedded all the color names directly into the script because I didn't want to make a formal Python package, didn't want dependencies, etc. I wanted something standalone that people could just download directly from GitHub and run with no fuss.


Terry Jones

unread,
Jan 26, 2017, 6:07:17 PM1/26/17
to figtree...@googlegroups.com, Terry Jones, Andrew Rambaut (a.rambaut@ed.ac.uk)
I just added the ability to specify taxa regular expressions in the color specification file, and to allow for matching/ignoring case in taxa names. That's probably it from me for now. With a 6-line specification file and a color default I can now specify and color my FigTree nodes super easily.

Terry


On Thu, Jan 26, 2017 at 5:57 PM, Terry Jones <terry...@gmail.com> wrote:
BTW, I embedded all the color names directly into the script because I didn't want to make a formal Python package, didn't want dependencies, etc. I wanted something standalone that people could just download directly from GitHub and run with no fuss.


Andrew Rambaut

unread,
Jan 27, 2017, 4:10:56 AM1/27/17
to figtree...@googlegroups.com
Thanks Terry,

Looks like a very useful tool. Hope to add additional functionality to FigTree for colours at some point but never seem to have time.

Andrew

To unsubscribe from this group and stop receiving emails from it, send an email to figtree-discu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages