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


Python Tree.check_monophyly方法代码示例

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


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

示例1: len

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import check_monophyly [as 别名]
        leaf.add_features(domain="Eukaryote")
        eukaryote_seqs.append(leaf.name)
        target_leaf = leaf
    else:
        leaf.add_features(domain="Other")
#print eukaryote_seqs
#test the various phylogenetic criteria for LGT.

#euk sequence is a singleton nested within a clade of bacteria, and there is only one eukaryote sequence in the tree
if len(eukaryote_seqs) == 1: #this is, I guess, an LGT candidate
    print sys.argv[1] + "\tSingleton"
#euk sequence is a singleton nested within a clade of bacteria, and the eukaryotes are not monophyletic in the tree
#print len(eukaryote_seqs)
else:
    try:
        answer = tree.check_monophyly(values=eukaryote_seqs, target_attr="name")
        if answer[0] == True:
            ca = tree.get_common_ancestor(eukaryote_seqs)
            print sys.argv[1] + "\tEuks monophyletic\t" + str(len(eukaryote_seqs)) + "\t" + str(ca.support) 
        elif answer[0] == False:
            mono_groups = []
            target_group = ''
            for node in tree.get_monophyletic(values=['Eukaryote'], target_attr="domain"):
                if target_leaf in node:
                    target_group = node
                else:
                    mono_groups.append(node)
            size_target_group = len(target_group)
            #get distance
            shortest_distance = 999999999999999.0
            closest_other_group = ''
开发者ID:Tancata,项目名称:phylo,代码行数:33,代码来源:test_monophyly_microsporidia.py

示例2: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import check_monophyly [as 别名]
tree = Tree(sys.argv[1])
print tree

archaea = [] #make a list of archaea that are in the tree
bacteria = []
#check the domain of each taxon in the tree
for taxon in tree:
	print taxon.name + "\t" + id_to_domain[taxon.name]
	if id_to_domain[taxon.name] == 'Archaea':
		archaea.append(taxon.name)
	else:
		bacteria.append(taxon.name)

#first, check if archaea are monophyletic in the tree

if tree.check_monophyly(values=archaea, target_attr="name")[0] == True:

	#find the branch separating archaea and bacteria, and reroot the tree on that
	archaea_ancestor = tree.get_common_ancestor(archaea) 
	tree.set_outgroup(archaea_ancestor)
elif tree.check_monophyly(values=bacteria, target_attr="name")[0] == True:
	bacteria_ancestor = tree.get_common_ancestor(bacteria)
	tree.set_outgroup(bacteria_ancestor)
else:
	#neither archaea nor bacteria were monophyletic, so print some error and quit
	print sys.argv[1] + ": neither A nor B monophyletic."
	quit()

outfile_name = sys.argv[1] + "_rerooted"
tree.write(outfile=outfile_name)
开发者ID:Tancata,项目名称:phylo,代码行数:32,代码来源:reroot_between_AB.py

示例3: clades

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import check_monophyly [as 别名]
#read the ML tree, set up the taxonomy stuff, and calculate the number of clades per label, and the sizes of those clades (to report at the end)
#might need to alter taxonomy assignment so that we check for the presence of the believed groups at all levels of the taxonomy.
ml_tree = Tree(sys.argv[1])
for leaf in ml_tree:
    taxonomy = check_for_favourite_taxonomy(leaf.name)
    taxa_names.append(leaf.name)
    leaf.add_feature("tax", taxonomy) #this needs to label with the favoured group, or else "none" or something. TODO.
    if taxonomy == "none":
        continue
    else:
        labels[taxonomy] = 1
groups = labels.keys()
#need to add something above to get a list of the believed labels which are actually found in the tree. For the moment, we'll use groups (=labels.keys()).
#for each of our favourite believed groups, ask whether all sequences from that group are monophyletic.

total_believed_groups = len(groups)
mono_believed_groups = 0
for label in groups:
    val = ml_tree.check_monophyly(values=[label], target_attr="tax", unrooted=True)
    #print(val)
    print(label + "\t" + str(val[0]) + "\t" + str(val[1]))
    if val[0] == True:
        mono_believed_groups += 1
    else:
        for ele in val[2]:
            print(ele.get_ascii())
    #    mono_believed_groups += 1
    #    print(label)

print(sys.argv[1] + " score: " + str(float(mono_believed_groups)/float(total_believed_groups)))
开发者ID:Tancata,项目名称:phylo,代码行数:32,代码来源:score_trusted_monophyly.py

示例4: ClusterIdentification

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import check_monophyly [as 别名]

#.........这里部分代码省略.........
            del self.dictClusters[k]
        try:
            if len(self.dictClusters) > 0:
                del self.dictClusters[0]
        except:
            pass
        ValLengths = []
        ItemNumber = []

        for k, v in self.dictClusters.iteritems():
            ValLengths.append(int(len(set(v))))
            for i in v:
                if not i in ItemNumber:
                    ItemNumber.append(i)
        ValLengths[:] = []
        for k, v in self.dictClusters.iteritems():
            vset = set(v)
            v[:] = []
            vset = list(vset)
            self.dictClusters[k] = str(vset)
        return self.dictClusters

    # Retrieve common ancestors
    def CommonAncestor(self, nodes):
        ancestors = []
        ancestor = self.t.get_common_ancestor(nodes)
        for i in ancestor:
            ancestors.append(i.name)
        return ancestors

    # Identify poly- , para-, and monophyletic pairs of variants
    def CheckMono(self, ncomb, PhyloVarRemoval, Rejects, monoFinal):
        monoResult = str(
            self.t.check_monophyly(values=PhyloVarRemoval, ignore_missing=True, target_attr="name", unrooted=True)
        )
        monoResultSp = monoResult.split(",")
        mR = monoResultSp[1].replace("'", "").replace(")", "").replace(" ", "")
        if "monophyletic" in mR:
            if not ncomb in monoFinal:
                monoFinal[ncomb] = []
            monoFinal[ncomb].append(mR)
            if not ncomb in self.monoFinalRes:

                self.monoFinalRes.append(ncomb)

            return True
        elif "paraphyletic" in mR:
            if not ncomb in monoFinal:
                monoFinal[ncomb] = []
            monoFinal[ncomb].append(mR)
            if not ncomb in self.monoFinalRes:

                self.monoFinalRes.append(ncomb)
        elif not ncomb in Rejects:

            Rejects.append(ncomb)

    ##Analysis identifies all ancestors to variants passing the required percentile thresholds
    # Following the removal of outliers, it parses through every combination of these variants to determine whether the pair is polyphyletic or not
    def variantAnalysis(self):
        monoFinal = {}
        self.variantCollection()
        if outlierFlag == "TRUE":
            OutlierFile = open(outputPath + TreeShort + "." + percentile + "." + supportInput + ".Outlier.txt", "w")
        try:
            self.intraComb(IntraFile)
开发者ID:vmon588,项目名称:Intra-Clust,代码行数:70,代码来源:ete.DeepSequencingClusterID.py

示例5: CheckMonophyly

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import check_monophyly [as 别名]
 def CheckMonophyly(self,PDlist):
     t = Tree(filePath+TreeFile)
     monoShort=[]
     x=0
     for item in PDlist:
         cluster=[]
         pairL=[]
         flag = 0
         y=0
         clusterRaw=str(item).replace("[","").replace("]","").replace('"',"").replace(" ","").replace("'",'').split(',')
         for i in clusterRaw:
             if not i in cluster:
                 cluster.append(i)
         monoResult = str(t.check_monophyly(values=cluster, ignore_missing=True,target_attr="name",unrooted=True))
         #Identify poly- , para-, and monophyletic relationships for clusters
         if 'monophyletic' in monoResult:
             for pair in itertools.combinations(cluster,2):
                 m = list(pair)
                 if not m in self.monoPairs:
                     self.monoPairs.append(m)
                 
         elif 'paraphyletic' in monoResult:
             for pair in itertools.combinations(cluster,2):
                 m = list(pair)
                 if not m in self.monoPairs:
                     self.monoPairs.append(m)
         else:
             cluster2 = []
             for pair in itertools.combinations(cluster,2):
                 n = list(pair)  
                 monoResult = str(t.check_monophyly(values=n, ignore_missing=True,target_attr="name",unrooted=True))
                 if not 'polyphyletic' in monoResult:
                     if not n in cluster:
                         cluster.append(n)
                         for i in n:
                             if i in cluster:
                                 cluster.remove(i)
                     if not n in self.monoPairs:
                         self.monoPairs.append(n)
             #Breaksdown large clusters to identify poly- , para-, and monophyletic sub-clusters
             while y < 2:
                 y+=1
                 for pair in itertools.combinations(cluster,2):
                     pairL = list(pair)
                     cluster2 = []
                     if type(pairL[0]) is list:
                         if type(pairL[1]) is list:
                             cluster2 = pairL[0]+pairL[1]
                         else:
                             for i in pairL[0]:
                                 if not i in cluster2:
                                     cluster2.append(i)
                             if not pairL[1] in cluster2:
                                 cluster2.append(pairL[1])
                     elif type(pairL[1]) is list:
                         for i in pairL[1]:
                             if not i in cluster2:
                                 cluster2.append(i)
                         if not type(pairL[0]) is list:
                             if not pairL[0] in cluster2:
                                 cluster2.append(pairL[0])
                     else:
                         if not pairL[0] in cluster2:
                             cluster2.append(pairL[0])
                         if not pairL[1] in cluster2:
                             cluster2.append(pairL[1])
                     monoResult = str(t.check_monophyly(values=cluster2, ignore_missing=True,target_attr="name",unrooted=True))
                     if not 'polyphyletic' in monoResult:
                         x+=1
                         if not cluster2 in cluster:
                             cluster.append(cluster2)
                         for item in cluster2:
                             for i in item:
                                 if i in cluster:
                                     cluster.remove(i)
                         if not cluster2 in self.monoPairs:
                             self.monoPairs.append(cluster2)
     return self.monoPairs
开发者ID:vmon588,项目名称:Intra-Clust,代码行数:80,代码来源:ete.ConsensusSequencingClusterID.py


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