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


Python Tree.write_to_path方法代码示例

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


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

示例1: Wrapper

# 需要导入模块: from dendropy import Tree [as 别名]
# 或者: from dendropy.Tree import write_to_path [as 别名]
class Wrapper(object):
    '''
    This class contains wrappers for all the tools used in this project
    '''


    def __init__(self, workDir, resultsFile, inFile, coreId, seqType, seedNum, bootNum, method, interLeaved):
        '''
        Data Fields:
        work_dir   = temproray directory
        inFile     = data file,
        id         = core id (int), 
        seqType    = d (dna); p (protein); r (rna), 
        bootNum    = number of replicates,
        seedNum    = Random number seed between 1 and 32767
        method     =b (Bootstrap) Default, 
                    j (Jackknife)
                    c (Permute species for each character)
                    o (Permute character order)
                    s (Permute within species)
                    r (Rewrite data)),
        interLeaved=True if sequence data is interleaved otherwise False
        '''
        self.work_dir       = workDir
        self.resultsFile    = resultsFile
        self.inFile         = inFile 
        self.coreId         = coreId
        self.seqType        = seqType
        self.seedNum        = seedNum
        self.bootNum        = bootNum
        self.method         = method
        self.n              = bootNum
        self.nt             = False
        self.interLeaved    = interLeaved
        self.outFile        = "bootstrap_"+str(coreId)+".out"
        self.newSpeciesTree = Tree()
        self.leafLabelStree = []
        self.internalExRootSpeceLabels= []
        
        if self.seqType in ['r', 'd']:
            self.nt = True
    
    def getSpeciesTree(self):
        return self.newSpeciesTree
    
    def setSpeceistree(self, stree):
        self.newSpeciesTree= stree

    def writeSpeciesTree(self):
        self.newSpeciesTree.write_to_path(self.resultsFile+'.speciestree.'+str(self.coreId), 'newick', suppress_internal_node_labels=False,annotations_as_nhx=True, extract_comment_metadata=True , suppress_annotations=False)
    
    def allLeafLabels(self, myTree):
        '''
        returns the list containing all the leaf nodes' label of this tree and the internal nodes without the root label
        '''
        leafLabels=[]
        internalLabelsExRoot=[]
        for i in myTree.leaf_nodes():
            leafLabels.append(i.get_node_str().replace("'", ""))
        for i in myTree.internal_nodes():
            if i.level() != 0:
                internalLabelsExRoot.append(i.label)
        return leafLabels, internalLabelsExRoot
    def onlyLeafLabels(self, myTree):
        '''
            returns the list containing labels of leaf nodes for this tree
        '''
        leafLabels=[]
        for i in myTree.leaf_nodes():
            leafLabels.append(i.get_node_str().replace("'", ""))
        return leafLabels
        
    def readTreeFromFile(self, treePath):
        '''
        input: path to the file containing newick tree
        return Tree object 
        '''
        print treePath
        myTree= Tree()
        myTree= Tree.get_from_path(treePath, 'newick', suppress_edge_lengths=False, annotations_as_nhx=True, extract_comment_metadata=True , suppress_annotations=False)
        return myTree

    def readTreeFromString(self, treeString):
        '''
        input: string containing newick tree
        return Tree object 
        '''
        myTree= Tree()
        myTree= Tree.get_from_string( treeString, 'newick', annotations_as_nhx=True, extract_comment_metadata=True , suppress_annotations=False)
        return myTree
           
    def checkExe(self, exePath):
        return os.path.isfile(exePath) and os.access(exePath, os.X_OK)
    
    def Where(self, program):
        '''
        input: name of executable
        output: path to executable
        '''
        fpath, fname = os.path.split(program)
#.........这里部分代码省略.........
开发者ID:malagori,项目名称:PhyloGenClust,代码行数:103,代码来源:wrappers.py


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