标签: etetoolkit

如何从出租车获得王国,门,类,秩序,家庭,属和物种的分类学特定ID?

我有一个如下所示的出租车列表:

1204725
2162
1300163
420247
Run Code Online (Sandbox Code Playgroud)

我希望从上面的出租车中获取一个带有分类标准的文件:

kingdom_id      phylum_id       class_id        order_id        family_id       genus_id        species_id   
Run Code Online (Sandbox Code Playgroud)

我正在使用" ete3 " 包.我使用工具ete-ncbiquery来告诉你上面的id的谱系.(我使用下面的命令从我的linux笔记本电脑上运行它)

ete3 ncbiquery --search 1204725 2162 13000163 420247 --info 
Run Code Online (Sandbox Code Playgroud)

结果如下:

# Taxid Sci.Name    Rank    Named Lineage   Taxid Lineage
2162    Methanobacterium formicicum species root,cellular organisms,Archaea,Euryarchaeota,Methanobacteria,Methanobacteriales,Methanobacteriaceae,Methanobacterium,Methanobacterium formicicum   1,131567,2157,28890,183925,2158,2159,2160,2162
1204725 Methanobacterium formicicum DSM 3637    no rank root,cellular organisms,Archaea,Euryarchaeota,Methanobacteria,Methanobacteriales,Methanobacteriaceae,Methanobacterium,Methanobacterium formicicum,Methanobacterium formicicum DSM 3637  1,131567,2157,28890,183925,2158,2159,2160,2162,1204725
420247  Methanobrevibacter smithii ATCC 35061   no rank root,cellular organisms,Archaea,Euryarchaeota,Methanobacteria,Methanobacteriales,Methanobacteriaceae,Methanobrevibacter,Methanobrevibacter smithii,Methanobrevibacter smithii ATCC 350611,131567,2157,28890,183925,2158,2159,2172,2173,420247
Run Code Online (Sandbox Code Playgroud)

我不知道哪些项目(IDS)对应于我要找的东西(如果有的话)

bioinformatics taxonomy ncbi phylogeny etetoolkit

8
推荐指数
1
解决办法
2107
查看次数

将hcluster生成的ndarray转换为Newick字符串,以便与ete2包一起使用

我有一个通过运行创建的向量列表:

import hcluster
import numpy as np
from ete2 import Tree

vecs = [np.array(i) for i in document_list] 
Run Code Online (Sandbox Code Playgroud)

其中document_list是我正在分析的Web文档的集合.然后我执行分层聚类:

Z = hcluster.linkage(vecs, metric='cosine') 
Run Code Online (Sandbox Code Playgroud)

这会生成一个ndarray,例如:

[[ 12.          19.           0.           1.        ]
[ 15.          21.           0.           3.        ]
[ 18.          22.           0.           4.        ]
[  3.          16.           0.           7.        ]
[  8.          23.           0.           6.        ]
[  5.          27.           0.           6.        ]
[  1.          28.           0.           7.        ]
[  0.          21.           0.           2.        ]
[  5.          29.           0.18350472   2.        ]
[  2. …
Run Code Online (Sandbox Code Playgroud)

python numpy dendrogram hcluster etetoolkit

5
推荐指数
1
解决办法
2072
查看次数

如何给`ete3`树上的叶子上色?(蟒蛇 3)

我刚开始使用ete3,它很棒。

如何ete3使用颜色字典为Tree 对象的叶子着色?我做"c":None是因为我不想c出现。

我想更好地控制树渲染,但我无法弄清楚如何做到这一点。

我看到有NodeStyle对象,但我认为这是针对实际节点的。看起来这个TextFace对象是我需要的,但我不知道如何使用它。 所有的例子都是添加标签。

# Build Tree
tree = ete3.Tree( "((a,b),c);" )
# Leaf mapping
D_leaf_color = {"a":"r", "b":"g","c":None}
# Set up style for circular tree
ts = ete3.TreeStyle()
ts.mode = "c"
# Draw Tree
tree.render("tree_test.png", dpi=300, w=500, tree_style=ts)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我看着这个问题,但它非常令人困惑: 如何使用一组固定的颜色为树节点着色?

python tree colors etetoolkit ete3

3
推荐指数
1
解决办法
1642
查看次数

如何从滑行中获取分类学等级名称?

这个问题与以下内容有关: 如何从滑行中获取王国,门,阶级,顺序,家庭,属和物种的分类学特定ID?

那里给出的解决方案是可行的,但是我想为已定义等级的每个分类ID提供名称。我在ete3上发现了这一点,它可以完成这项工作:

names = ncbi.get_taxid_translator(lineage)
print [names[taxid] for taxid in lineage]
Run Code Online (Sandbox Code Playgroud)

但不是Python程序员,我无法将其合并到以上链接中给出的代码中。这是我尝试过的:

import csv
from ete3 import NCBITaxa

ncbi = NCBITaxa()

def get_desired_ranks(taxid, desired_ranks):
    lineage = ncbi.get_lineage(taxid)
    print lineage
    #[1, 131567, 2157, 28890, 183925, 2158, 2159, 2160, 2162, 1204725]
    names = ncbi.get_taxid_translator(lineage)
    print names
    #{1: u'root', 2157: u'Archaea', 2158: u'Methanobacteriales', 2159: u'Methanobacteriaceae', 2160: u'Methanobacterium', 2162: u'Methanobacterium formicicum', 183925: u'Methanobacteria', 28890: u'Euryarchaeota', 131567: u'cellular organisms', 1204725: u'Methanobacterium formicicum DSM 3637'}
    lineage2ranks = ncbi.get_rank(names)
    print lineage2ranks
    #{1: u'no rank', 2157: u'superkingdom', …
Run Code Online (Sandbox Code Playgroud)

python bioinformatics ncbi etetoolkit

2
推荐指数
1
解决办法
908
查看次数

使用Python 2.7的HTML解析树

我试图为下面的HTML表配置一个解析树,但是无法形成它.我想看看树结构是什么样的!有人可以帮助我吗?

# <html>
#  <head>
#   <title>
#    The Dormouse's story
#   </title>
#  </head>
#  <body>
#   <p class="title">
#    <b>
#     The Dormouse's story
#    </b>
#   </p>
#   <p class="story">
#    Once upon a time there were three little sisters; and their names were
#    <a class="sister" href="http://example.com/elsie" id="link1">
#     Elsie
#    </a>
#    ,
#    <a class="sister" href="http://example.com/lacie" id="link2">
#     Lacie
#    </a>
#    and
#    <a class="sister" href="http://example.com/tillie" id="link2">
#     Tillie
#    </a>
#    ; …
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup parse-tree python-2.7 etetoolkit

2
推荐指数
2
解决办法
5811
查看次数

ETE2 .phonehome()它是复活节彩蛋吗?

ETE2(用于系统发育树探索的Python环境)有一个.phonehome()可以在树/节点类对象上调用的方法.返回:

== Calling home... Got answer!

He11o alien,
How is everything in the Earth?
We miss you in Brodo Asogi.

I see you are in shape.
No updates are available.

== Do you want to leave any message?
(Press enter to finish)
Run Code Online (Sandbox Code Playgroud)

如果您想自己测试一下,请尝试:

from ete2 import Tree
t = Tree()      # generate random Tree
t.phonehome()   # communicate with Aliens!
Run Code Online (Sandbox Code Playgroud)

这是一个复活节彩蛋吗?

python messaging etetoolkit

-2
推荐指数
1
解决办法
247
查看次数