Question: get species names from newick phylogenetic tree file
0
gravatar for a.moner
5 days ago by
a.moner0
a.moner0 wrote:

Hi I have a newick phylogeny file has more than 1000 species. I want to extract just species name in different file. I appreciate your help

ADD COMMENTlink written 5 days ago by a.moner0
0
gravatar for jrj.healey
5 days ago by
jrj.healey9.7k
United Kingdom
jrj.healey9.7k wrote:

What have you tried?

Look at the ape package for instance. It'd be as simple as:

> library(ape)
> tree <- read.tree(text = "(((A,B),(C,D)),E);")  # or read.tree(file='path/to/file.tree') if using a file
> tree$tip.label
[1] "A" "B" "C" "D" "E"

A similar approach in python:

python -c 'import sys; from ete3 import Tree; t = Tree(sys.argv[1]);print(t.get_leaf_names());' treefile.nwk
ADD COMMENTlink modified 2 days ago • written 5 days ago by jrj.healey9.7k

I tried ape But the problem was importing the phylogenetic file it is too big for copy and paste and made error And I couldn't use it as import data

For python I got this error ete3 command not found

ADD REPLYlink modified 2 days ago • written 2 days ago by a.moner0

Then don't import it with copy and paste, read the file in directly. What I showed above was just an example of the functionality, you need to adapt it to what you are trying to do.

As for python, yes of course, ETE3 isn't a standard module - you need to install it.

ADD REPLYlink written 2 days ago by jrj.healey9.7k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1172 users visited in the last hour