Change nexus textlabels
1
0
Entering edit mode
6.6 years ago
User000 ▴ 720

Dear all,

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

r nexus tree bash • 1.7k views
ADD COMMENT
0
Entering edit mode
6.6 years ago
Anima Mundi ★ 2.9k

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 COMMENT
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 2046 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