当前位置: 首页>>代码示例>>Python>>正文


Python Tree.get_tree_root方法代码示例

本文整理汇总了Python中ete3.Tree.get_tree_root方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.get_tree_root方法的具体用法?Python Tree.get_tree_root怎么用?Python Tree.get_tree_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ete3.Tree的用法示例。


在下文中一共展示了Tree.get_tree_root方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: treeorder

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_tree_root [as 别名]
def treeorder(treefile):
    from ete3 import Tree
    from ete3.treeview import faces, TreeStyle, NodeStyle, AttrFace
    t = Tree(treefile)
    rt = t.get_tree_root()
    nameorder = []
    for desc in rt.iter_descendants("preorder"):
        if not desc.is_leaf():
            continue
        nameorder.append(desc.name)
    return nameorder
开发者ID:JosephRyanPeterson,项目名称:clusterDbAnalysis,代码行数:13,代码来源:db_getPresenceAbsenceTable.py

示例2: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_tree_root [as 别名]
#!/homes/carlac/anaconda_ete/bin/python

# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# Copyright [2016-2019] EMBL-European Bioinformatics Institute
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#      http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys, os
from ete3 import Tree

infile = sys.argv[1]
if not os.path.isfile(infile):
	sys.stderr.write("File %s not found", infile)
	sys.exit(1)

t = Tree(infile)
root = t.get_tree_root()
root.unroot()
print(root.write(format=5))
开发者ID:Ensembl,项目名称:ensembl-compara,代码行数:31,代码来源:unroot_newick.py

示例3: defined

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_tree_root [as 别名]
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys, os, argparse
from ete3 import Tree

parser = argparse.ArgumentParser()
parser.add_argument('-t', '--tree')
parser.add_argument('-o', '--outgroup')
opts = parser.parse_args(sys.argv[1:])

# check arguments
if not os.path.isfile(opts.tree):
	sys.stderr.write("File %s not found", opts.tree)
	sys.exit(1)

try:
	opts.outgroup
except NameError:
	sys.stderr.write("Outgroup must be defined (--outgroup)")
	sys.exit(1)


t = Tree(opts.tree)
t.set_outgroup(opts.outgroup)
print(t.get_tree_root().write(format=5))
开发者ID:Ensembl,项目名称:ensembl-compara,代码行数:32,代码来源:reroot_newick.py

示例4: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_tree_root [as 别名]
from ete3 import Tree
t = Tree()
# We create a random tree topology
t.populate(15)
print t
print t.children
print t.get_children()
print t.up
print t.name
print t.dist
print t.is_leaf()
print t.get_tree_root()
print t.children[0].get_tree_root()
print t.children[0].children[0].get_tree_root()
# You can also iterate over tree leaves using a simple syntax
for leaf in t:
      print leaf.name
开发者ID:Tancata,项目名称:phylo,代码行数:19,代码来源:etetest.py

示例5: sorted

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_tree_root [as 别名]
        d = tree.get_distance(node, leaf)
        dists[leaf] = d
    sorted_dists = sorted(dists.items(), key=itemgetter(1))
    middle_node = sorted_dists[len(sorted_dists)/2][0]
    return middle_node

tree = Tree("((A:0.1,B:0.2):0.3,(C:0.5,D:0.1):0.05);") #or read in from a file
print tree
mean_root_to_tip = get_mean_root_to_tip(tree)

#divide mean distance into some number of contours
num_contours = 4
contours = []
for i in range(num_contours):
    print i+2
    contours.append(mean_root_to_tip/float(i+2))
print contours

#for each contour, print num of nodes for which one descendant will be picked
root = tree.get_tree_root()
for c in contours:
    to_keep = []
    for node in tree.traverse():
        if contour_node(root, node, c):
            node_to_keep = pick_average_tip(node)
            to_keep.append(node_to_keep)
    print "Contour at " + str(c) + ", " + str(len(to_keep)) + " in total."
    for taxon in to_keep:
        print taxon.name

开发者ID:Tancata,项目名称:phylo,代码行数:31,代码来源:subsample_tree_by_contours.py

示例6: str

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_tree_root [as 别名]
		year_dict[acc_str]=year_str
	no_n=re.search(r'_N\d+', line)
	if no_n:
		no_n_str= no_n.group()	
		no_n_str=re.sub('_N','',no_n_str)
		no_N_dict[acc_str]=no_n_str
	
log_file.write("The number of clusters are:" + str(cluster_cnt))
log_file.close()
cdhit_file.close()

#print "Tree from FastTree program is being used to calculate root to leaf distances..."
#Passing in the tree generated by FastTree
FastTree=Tree(args.input2)
#Getting the root of the tree
root=FastTree.get_tree_root()
#Loop through each leaf of the tree
for leaf in FastTree:
	#Convert 'leaf' to string to allow manipulation
	leaf_str=str(leaf)
	acc_nu=re.search(r'\w{2}\d+.\d{1}_\d{4}|\w{2}_\d+.\d{1}_\d{4}',leaf_str)
	acc_nu=str(acc_nu.group())
	acc_nu=re.sub('_\d{4}$','',acc_nu)
	rt_lf=FastTree.get_distance(root,leaf)
	#Make a dictionary using acc_nu as key 
	branlength_dict[acc_nu]=rt_lf
	#Using the generated dictionaries to print the relevant information to a tab delimited file
	tsv_file.write(acc_nu + "\t" + year_dict[acc_nu] + "\t" + str(rt_lf) + "\t" + clust_dict[acc_nu] + "\t" + no_N_dict[acc_nu] + "\n")
tsv_file.close

开发者ID:MarcNiebel,项目名称:GenRefSeq,代码行数:31,代码来源:Combo.py


注:本文中的ete3.Tree.get_tree_root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。