"translate" in trees block (nexus format)

119 views
Skip to first unread message

Michael Dunn

unread,
Nov 11, 2012, 11:25:40 AM11/11/12
to dendrop...@googlegroups.com
Is it possible to write a tree to nexus format with a translation table? i.e.

begin trees;
  translate
    1 T1,
    2 T2,
    3 T3,
    4 T4;
  TREE 0 = ((1,2),(3,4));
end;

instead of

begin trees;
  TREE 0 = ((T1,T2),(T3,T4));
end;

I've looked in the docs, and in the source, but can't see where this might be done. The nexus reader copes with translate tables fine.



Jeet Sukumaran

unread,
Nov 14, 2012, 2:29:25 PM11/14/12
to DendroPy Users
Not at present. It should be straightforward to implement, though.
Submit an issue on GitHub, and hopefully we'll get around to
incorporating this in the next release.

Michael Dunn

unread,
Nov 15, 2012, 3:34:17 PM11/15/12
to dendrop...@googlegroups.com
Thanks Jeet. I've written some code myself to do this, and submitted a pull request for review on GitHub.

Jason Ladner

unread,
Jun 4, 2015, 2:45:24 PM6/4/15
to dendrop...@googlegroups.com
Was this function ever implemented? And if so, how can I use it? 

Thanks.

Jeet Sukumaran

unread,
Jun 4, 2015, 5:03:33 PM6/4/15
to dendrop...@googlegroups.com
It is in DendroPy 4, by specifying "``translate_tree_taxa=True`` to the
"``write()``" or "``as_string()``" method::

>>> import dendropy
>>> tree = dendropy.Tree.get(data="(A,(B,(C,(D,E))));",
schema="newick")
>>> print(tree.as_string("nexus", translate_tree_taxa=True))
#NEXUS

BEGIN TAXA;
DIMENSIONS NTAX=5;
TAXLABELS
A
B
C
D
E
;
END;

BEGIN TREES;
Translate
1 A,
2 B,
3 C,
4 D,
5 E
;
TREE 1 = (1,(2,(3,(4,5))));
END;

DendroPy 4 is going to be publically released in the next 24-48 hrs, but
you can check out the current revision on GitHub to get the current
development snapshot if you want.

-- jeet

On 6/4/15 2:45 PM, Jason Ladner wrote:
> Was this function ever implemented? And if so, how can I use it?
>
> Thanks.
>
> On Thursday, November 15, 2012 at 3:34:17 PM UTC-5, Michael Dunn wrote:
>
> Thanks Jeet. I've written some code myself to do this, and submitted
> a pull request for review on GitHub.
>
>
> On 14 November 2012 20:29, Jeet Sukumaran <jeetsu...@gmail.com
> <javascript:>> wrote:
>
> Not at present. It should be straightforward to implement, though.
> Submit an issue on GitHub, and hopefully we'll get around to
> incorporating this in the next release.
>
> On Nov 11, 11:25 am, Michael Dunn <misha.d...@gmail.com> wrote:
> > Is it possible to write a tree to nexus format with a
> translation table?
> > i.e.
> >
> > begin trees;
> > translate
> > 1 T1,
> > 2 T2,
> > 3 T3,
> > 4 T4;
> > TREE 0 = ((1,2),(3,4));
> > end;
> >
> > instead of
> >
> > begin trees;
> > TREE 0 = ((T1,T2),(T3,T4));
> > end;
> >
> > I've looked in the docs, and in the source, but can't see
> where this might
> > be done. The nexus reader copes with translate tables fine.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "DendroPy Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to dendropy-user...@googlegroups.com
> <mailto:dendropy-user...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--



--------------------------------------
Jeet Sukumaran
--------------------------------------
jeetsu...@gmail.com
--------------------------------------
Blog/Personal Pages:
http://jeetworks.org/
GitHub Repositories:
http://github.com/jeetsukumaran
Photographs (as stream):
http://www.flickr.com/photos/jeetsukumaran/
Photographs (by galleries):
http://www.flickr.com/photos/jeetsukumaran/sets/
--------------------------------------

Reply all
Reply to author
Forward
0 new messages