Question: Normalizing Tree Support Values From [0-1] To [0-100]
3
gravatar for Pappu
6.9 years ago by
Pappu1.9k
Pappu1.9k wrote:

I am trying to convert the tree support values like 0.555 to 55 in the tree file. For example:

(sp|P56726|SMO_MOUSE:0.00978,sp|P97698|SMO_RAT:0.00708,(sp|Q99835|SMO_HUMAN:0.03115,(sp|O42224|SMO_CHICK:0.13084,(sp|P91682|SMO_DROME:1.27659,(tr|Q90YY4|Q90YY4_DANRE:0.00055,tr|Q90X26|Q90X26_DANRE:0.00254)0.997:0.17060)0.982:0.11965)1.000:0.12313)0.990:0.03506);

0.99 will change to 99

(sp|P56726|SMO_MOUSE:0.00978,sp|P97698|SMO_RAT:0.00708,(sp|Q99835|SMO_HUMAN:0.03115,(sp|O42224|SMO_CHICK:0.13084,(sp|P91682|SMO_DROME:1.27659,(tr|Q90YY4|Q90YY4_DANRE:0.00055,tr|Q90X26|Q90X26_DANRE:0.00254)99:0.17060)0.982:0.11965)1.000:0.12313)99:0.03506);

Could you tell me about a good regular expression or software to do it?

Thanks.

python • 1.9k views
ADD COMMENTlink modified 6.9 years ago by a.zielezinski9.4k • written 6.9 years ago by Pappu1.9k
8
gravatar for a.zielezinski
6.9 years ago by
a.zielezinski9.4k
a.zielezinski9.4k wrote:

Here you go:

from ete2 import Tree

pappu_tree = "(sp|P56726|SMO_MOUSE:0.00978,sp|P97698|SMO_RAT:0.00708,(sp|Q99835|SMO_HUMAN:0.03115,(sp|O42224|SMO_CHICK:0.13084,(sp|P91682|SMO_DROME:1.27659,(tr|Q90YY4|Q90YY4_DANRE:0.00055,tr|Q90X26|Q90X26_DANRE:0.00254)0.997:0.17060)0.982:0.11965)1.000:0.12313)0.990:0.03506);"

t = Tree(pappu_tree)

for node in t.traverse():
    node.support *= 100.0

print t.write()

It will give you:

(sp|P56726|SMO_MOUSE:0.00978,sp|P97698|SMO_RAT:0.00708,(sp|Q99835|SMO_HUMAN:0.03115,(sp|O42224|SMO_CHICK:0.13084,(sp|P91682|SMO_DROME:1.27659,(tr|Q90YY4|Q90YY4_DANRE:0.00055,tr|Q90X26|Q90X26_DANRE:0.00254)99.7:0.1706)98.2:0.11965)100:0.12313)99:0.03506);
ADD COMMENTlink modified 6.9 years ago • written 6.9 years ago by a.zielezinski9.4k
1

note that you don't need to use the internal _set_support() function. float conversion occurs transparently if you just use the 'node.support *= 100.0' syntax

ADD REPLYlink modified 6.9 years ago • written 6.9 years ago by jhc2.9k

You're right. I updated my answer.

ADD REPLYlink written 6.9 years ago by a.zielezinski9.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: 1100 users visited in the last hour