Question: Change nexus textlabels
0
gravatar for User000
13 months ago by
User000270
User000270 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 • 345 views
ADD COMMENTlink modified 13 months ago by Anima Mundi2.4k • written 13 months ago by User000270
0
gravatar for Anima Mundi
13 months ago by
Anima Mundi2.4k
Italy
Anima Mundi2.4k 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 13 months ago by Anima Mundi2.4k
1

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

ADD REPLYlink written 13 months ago by Anima Mundi2.4k

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

ADD REPLYlink written 13 months ago by User000270

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 13 months ago by Anima Mundi2.4k
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: 923 users visited in the last hour