本文整理汇总了Python中ete3.Tree.rank_FR方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.rank_FR方法的具体用法?Python Tree.rank_FR怎么用?Python Tree.rank_FR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.Tree
的用法示例。
在下文中一共展示了Tree.rank_FR方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTheTrees
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import rank_FR [as 别名]
#.........这里部分代码省略.........
TRANS[sciname] = Trans()
if (line.split("\t")[19]!=''):
TRANS[sciname].common_name_FR.append(comnameFR)
#get translation of ranks
print "\nGetting rank names in french..."
RANKS = {}
with open("ranks.txt") as f:
for line in f:
rank_en = line.split("\t")[0]
rank_fr = line.split("\t")[1].rstrip() ##to remove \n
RANKS[rank_en] = rank_fr
class Taxid:
def __init__(self):
self.sci_name = ""
self.authority = ""
self.synonym = ""
# self.common_name = ""
self.common_name = []
# self.common_name_FR = ""
self.common_name_FR = []
cpt = 0
cptfr = 0
ATTR = {} ##here we will list attribute of each species per taxid
print "Reading NCBI taxonomy..."
with open("taxo/names.dmp") as f:
for line in f:
taxid = line.split("|")[0].replace("\t","")
tid_val = line.split("|")[1].replace("\t","")
tid_type = line.split("|")[3].replace("\t","")
if (ATTR.has_key(taxid)==False):
ATTR[taxid] = Taxid()
if (tid_type=="scientific name"):
ATTR[taxid].sci_name = tid_val
#and get translation in french (if any)
if TRANS.has_key(tid_val):
ATTR[taxid].common_name_FR = TRANS[tid_val].common_name_FR
cptfr += 1
if (tid_type=="authority"):
if (ATTR[taxid].authority!=""):
ATTR[taxid].authority = ATTR[taxid].authority + ", " + tid_val
else:
ATTR[taxid].authority = tid_val
if (tid_type=="synonym"):
if (ATTR[taxid].synonym!=""):
ATTR[taxid].synonym = ATTR[taxid].synonym + ", " + tid_val
else:
ATTR[taxid].synonym = tid_val
if (tid_type=="common name"):
cpt +=1
ATTR[taxid].common_name.append(tid_val)
# if (ATTR[taxid].common_name!=""):
# ATTR[taxid].common_name = ATTR[taxid].common_name + ", " + tid_val
# else:
# ATTR[taxid].common_name = tid_val
T = {}
###New gettrees
from ete3 import Tree
filepath = 'taxo/nodes.dmp'
print "Building the NCBI taxonomy tree..."
with open(filepath) as fp:
first_line = fp.readline() ## remove the 1 | 1 edge
for line in fp:
dad = line.split("|")[1].replace("\t","")
son = line.split("|")[0].replace("\t","")
rank = line.split("|")[2].replace("\t","")
if (T.has_key(dad)==False):
T[dad] = Tree()
T[dad].name = dad
# T[dad].rank = rank
# T[dad].rank_FR = RANKS[rank]
T[dad].taxid = dad
T[dad].sci_name = ATTR[dad].sci_name
T[dad].common_name = ATTR[dad].common_name
T[dad].synonym = ATTR[dad].synonym
T[dad].authority = ATTR[dad].authority
T[dad].common_name_FR = ATTR[dad].common_name_FR
if (T.has_key(son)==False):
T[son] = Tree()
T[son].name = son
T[son].rank = rank
T[son].rank_FR = RANKS[rank]
T[son].taxid = son
T[son].sci_name = ATTR[son].sci_name
T[son].common_name = ATTR[son].common_name
T[son].synonym = ATTR[son].synonym
T[son].authority = ATTR[son].authority
T[son].common_name_FR = ATTR[son].common_name_FR
else:
if (hasattr(T[son], 'rank')==False):
T[son].rank = rank
T[son].rank_FR = RANKS[rank]
T[dad].add_child(T[son])
return T
示例2: open
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import rank_FR [as 别名]
###New gettrees
from ete3 import Tree
filepath = 'taxo/nodes.dmp'
print "Building the NCBI taxonomy tree..."
with open(filepath) as fp:
first_line = fp.readline() ## remove the 1 | 1 edge
for line in fp:
dad = line.split("|")[1].replace("\t","")
son = line.split("|")[0].replace("\t","")
rank = line.split("|")[2].replace("\t","")
if (T.has_key(dad)==False):
T[dad] = Tree()
T[dad].name = dad
T[dad].rank = rank
T[dad].rank_FR = RANKS[rank]
T[dad].taxid = dad
T[dad].sci_name = ATTR[dad].sci_name
T[dad].common_name = ATTR[dad].common_name
T[dad].synonym = ATTR[dad].synonym
T[dad].authority = ATTR[dad].authority
T[dad].common_name_FR = ATTR[dad].common_name_FR
if (T.has_key(son)==False):
T[son] = Tree()
T[son].name = son
T[son].rank = rank
T[son].rank_FR = RANKS[rank]
T[son].taxid = son
T[son].sci_name = ATTR[son].sci_name
T[son].common_name = ATTR[son].common_name
T[son].synonym = ATTR[son].synonym