How to convert (Newick) tree topology without branch length!
1
0
Entering edit mode
3.6 years ago
Info.shi ▴ 30

I need to compare tree topology pattern I don't care about differences in branch length.

I have thousands of files so hard to export one by one without branch length.

My file.

(Strain1_geneA.100.1:0.05252918,Strain2_geneA.100.1:0.00000000,(Strain3_geneA.100.1:0.00000000,(Strain4_geneA.100.1:0.00000000,Strain1_gene5.100.1:0.07301800):0.01361868):0.04626703);

The output I want.

(Strain1_geneA.100.1,Strain2_geneA.100.1,(Strain3_geneA.100.1,(Strain4_geneA.100.1,Strain5_geneA.100.1)));

Thankyou!

sed awk perl • 2.1k views
ADD COMMENT
3
Entering edit mode
3.6 years ago
shelkmike ★ 1.4k

This can be done with regular expressions. For example, if you need to remove branch lengths in a file tree.nwk, you can use the following command:

perl -ne '$_=~s/:[\d\.]+//g; print $_;' tree.nwk >output_tree.nwk
ADD COMMENT
0
Entering edit mode

Similar approach here which might be of interest:

Detect trees (newick) with specific topology

ADD REPLY

Login before adding your answer.

Traffic: 1343 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6