本文整理汇总了Python中ete3.Tree.split方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.split方法的具体用法?Python Tree.split怎么用?Python Tree.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.Tree
的用法示例。
在下文中一共展示了Tree.split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tree
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import split [as 别名]
def get_tree(n, keys, wscaf, wsta, wsto, seq, outg, fnw, fout, lgi, vb, kali=kali, notree=notree):
# increment tree number
n += 1
# prepare ali
desc = "%s:%s-%s" % (wscaf, wsta, wsto)
if kali:
fnom = "%s/%s.%s-%s.fasta" % (prefali, wscaf, wsta, wsto)
else:
fnom = "%s/ali.temp.fasta" % (prefali)
with open(fnom, "w") as o:
for k in keys:
record = SeqRecord(Seq(seq[k], IUPAC.ambiguous_dna),
id=k, description=desc)
if vb: print record.format("fasta").strip()
o.write(record.upper().format("fasta"))
if notree:
return n
# compute and retrieve tree using seaview...
cmd = "seaview -build_tree -distance observed -NJ -o - %s" % fnom
print cmd
tr = os.popen(cmd).read().strip()
if tr == '':
n -= 1
cmd = "rm %s" % fnom
os.system(cmd)
return n
tr = Tree(tr.split("] ")[1])
# root tree
if outg:
tr.set_outgroup(outg)
# write tree in a gz file
tr = tr.write(format=1)
fnw.write(tr + "\n")
fout.write("\t".join([ str(x) for x in [wscaf, wsta, wsto, (int(wsta)+int(wsto))/2,
int(wsto)-int(wsta), lgi ] ]) + "\n")
return n