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


Python DndParser.getSubTree方法代码示例

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


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

示例1: test_getsubtree

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getSubTree [as 别名]
    def test_getsubtree(self):
        """testing getting a subtree
        """
        otu_names = ['NineBande', 'Mouse', 'HowlerMon', 'DogFaced']
        newick = '(((Human,HowlerMon),Mouse),NineBande,DogFaced);'
        newick_reduced = '((Mouse,HowlerMon),NineBande,DogFaced);'
        tree = DndParser(newick, constructor = PicrustNode) 

        subtree = tree.getSubTree(otu_names)
        new_tree = DndParser(newick_reduced, constructor = PicrustNode)       
        # check we get the same names
        self.assertEqual(*[len(t.Children) for t in (subtree,new_tree)])
        self.assertEqual(subtree.getNewick(), new_tree.getNewick())
开发者ID:cleme,项目名称:picrust,代码行数:15,代码来源:test_util.py

示例2: main

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getSubTree [as 别名]
def main():
    
    option_parser, opts, args = parse_command_line_parameters(**script_info)
    input_tree_fp = opts.input_tree_fp
    tips_fp = opts.tips_fp
    fasta_fp = opts.fasta_fp
    output_tree_fp = opts.output_tree_fp
    
    if tips_fp != None:
        tips_to_keep = get_seqs_to_keep_lookup_from_seq_id_file(open(tips_fp,'U'))
    elif fasta_fp != None:
        tips_to_keep = get_seqs_to_keep_lookup_from_fasta_file(open(fasta_fp,'U'))
    else:
        option_parser.error("Must provide either -t or -f.")
    
    tree = DndParser(open(input_tree_fp,'U'))
    
    if opts.negate:
        tips_to_keep = negate_tips_to_keep(tips_to_keep, tree)
    
    tree_out = tree.getSubTree(tips_to_keep)
   
    tree_out.writeToFile(output_tree_fp)
开发者ID:Ecogenomics,项目名称:FrankenQIIME,代码行数:25,代码来源:filter_tree.py

示例3: test_cospeciation

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getSubTree [as 别名]

#.........这里部分代码省略.........
                print "Analyzing pOTU # " + cotu_basename

                cotu_table_fp = cotu_basename + '_seqs_otu_table.txt'

                basename = cotu_basename + "_" + test

                # Read in cOTU file
                try:
                    cotu_file = open(cotu_table_fp, 'Ur')
                except:
                    print "is this a real file?"

                # Reconcile hosts in host DM and cOTU table
                filtered_cotu_file, host_dist_filtered = reconcile_hosts_symbionts(
                    cotu_file, host_dist)

                cotu_file.close()

                # Read in reconciled cOTU table
                sample_names, taxon_names, data, lineages = parse_otu_table(
                    filtered_cotu_file)
                filtered_cotu_file.close()

                # exit loop if less than three hosts or cOTUs
                if len(sample_names) < 3 or len(taxon_names) < 3:
                    print "Less than 3 hosts or cOTUs in cOTU table!"
                    continue

                # Import, filter, and root cOTU tree
                otu_tree_fp = cotu_basename + "_seqs_rep_set.tre"
                otu_tree_file = open(otu_tree_fp, 'r')
                otu_tree_unrooted = DndParser(otu_tree_file, PhyloNode)
                otu_tree_file.close()
                otu_subtree_unrooted = otu_tree_unrooted.getSubTree(
                    taxon_names)
                # root at midpoint
                # Consider alternate step to go through and find closest DB seq
                # to root?
                otu_subtree = otu_subtree_unrooted.rootAtMidpoint()

                # filter host tree
                host_subtree = host_tree.getSubTree(sample_names)

                # Load up and filter cOTU sequences
                aligned_otu_seqs = LoadSeqs(
                    cotu_basename + '_seqs_rep_set_aligned.fasta', moltype=DNA, label_to_name=lambda x: x.split()[0])
                filtered_seqs = aligned_otu_seqs.takeSeqs(taxon_names)

                result = False

                # Run recursive test on this pOTU:
                try:
                    # DEBUG:
                    # print 'in run_test_cospeciation'

                    # get number of hosts and cOTUs
                    htips = len(host_subtree.getTipNames())
                    stips = len(otu_subtree.getTipNames())

                    if test == 'unifrac':
                        print 'calling unifrac test'
                        results_dict, acc_dict = unifrac_recursive_test(host_subtree, otu_subtree, sample_names,
                                                                        taxon_names, data, permutations)
                        pvals = 'p_vals'

                    if test == 'hommola_recursive':
开发者ID:tanaes,项目名称:codiversification,代码行数:70,代码来源:cospeciation.py


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