This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to convert (Newick) tree topology without branch length!

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

1 answer

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

Log in to answer this question.