Question: Change nexus textlabels
0
gravatar for User000
2.0 years ago by
User000370
User000370 wrote:

Dear all,

Any suggestion how to change the tip labels of a phylogenetic tree in nexus format? in R? bash script?

bash tree nexus R • 506 views
ADD COMMENTlink modified 2.0 years ago by Anima Mundi2.7k • written 2.0 years ago by User000370
0
gravatar for Anima Mundi
2.0 years ago by
Anima Mundi2.7k
Italy
Anima Mundi2.7k wrote:

Hi, if you want to try replacing headers, this should do the job (Python 2.7 script, takes the two list filenames as arguments):

import sys

listA = []
listB = []

for line in open(sys.argv[1]):
    listA.append(line.replace('\n',''))

for line in open(sys.argv[2]):
    listB.append(line.replace('\n',''))

for line in listA:
    id = ''
    for char in line:
        if char != '.':
            id += char
        else:
            break
    for linej in listB:
        if id in linej:
            print linej
ADD COMMENTlink written 2.0 years ago by Anima Mundi2.7k
1

Well, this was meant to reply to an original question, now missing -.-''

ADD REPLYlink written 2.0 years ago by Anima Mundi2.7k

thanks! this prints me the headers but is not replacing in the original file...

ADD REPLYlink written 2.0 years ago by User000370

Yep, indeed the script was simply meant to help you re-format your list IDs, as you originally requested. If you want to get some help then... you should help people to help you! For instance, in the original question at least you were pointing out to one example ID. That said, unfortunately I am not familiar with NEXUS files, so I am not the best person to assist you any further. On general terms, in your place I would try to figure out where those tip labels are taken from, to know what to replace in your NEXUS text file.

ADD REPLYlink written 2.0 years ago by Anima Mundi2.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: 1078 users visited in the last hour