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


Python TreeStyle.arc_span方法代码示例

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


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

示例1: ETETree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
def ETETree(seqs, ref, metric):
    """Tree showing bola alleles covered by tepitope"""
    from ete2 import Tree,PhyloTree,TreeStyle,NodeStyle
    aln = Genome.clustalAlignment(seqs=seqs)
    t = Tree('temp.dnd')
    #t.set_outgroup(t&ref)
    ts = TreeStyle()
    ts.show_leaf_name = True
    ts.mode = "c"
    ts.arc_start = -180
    ts.arc_span = 180
    cutoff=0.25
    def func(node):
        if node.name=='NoName' or not node.name in metric:
            return False
        if metric[node.name]<=cutoff:
            return True
    matches = filter(func, t.traverse())
    print len(matches), "nodes have distance <=%s" %cutoff
    nst1 = NodeStyle()
    nst1["bgcolor"] = "Yellow"
    for n in matches:
        n.set_style(nst1)
    nst2 = NodeStyle()
    nst2["bgcolor"] = "LightGreen"
    hlanodes = [t.get_leaves_by_name(name=r)[0] for r in refalleles]
    for n in hlanodes:
        n.set_style(nst2)
    t.show(tree_style=ts)
    return
开发者ID:dmnfarrell,项目名称:epitopemap,代码行数:32,代码来源:sequtils.py

示例2: showTreeInGrid

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
def showTreeInGrid(gid,biome,grid_level=14,taxonomic_level='sp'):
    """
    Performs a selection, spatial filter and returns an image.
    grid_level is the grid layer.
    taxonomic_level is the taxonomic level to be shown. Options are:
    sp, gns, fam, ord, cls, phy, king
    """
    
    mesh = initMesh(grid_level)
    try:
        cell = mesh.objects.get(id=id)
    except:
        logger.error("Selected id does not exist in selected grid")
        return None
    
    gb=GriddedTaxonomy(biome,cell,generate_tree_now=True)
    forest = gb.taxonomies[0].forest

    ts = TreeStyle()
    ts.show_leaf_name = True
    ts.mode = "c"
    ts.arc_start = -180 # 0 degrees = 3 o'clock
    ts.arc_span = 360

    forest[taxonomic_level].show(tree_style=ts)
    return 'Parece que se tiene que ver algo'
开发者ID:molgor,项目名称:biospatial,代码行数:28,代码来源:actionsQGIS.py

示例3: build_vis

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
def build_vis():
	ts = TreeStyle()
	ts.mode = "c"
	ts.arc_start = 0 # 0 degrees = 3 o'clock
	ts.arc_span = 360
	ts.layout_fn = my_layout # Use custom layout
	return ts
开发者ID:WebValley2014,项目名称:DataViz,代码行数:9,代码来源:import.py

示例4: showTreeInGrid

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
def showTreeInGrid(request):
    """
    .. showTreeInGrid:
    
    Performs a selection, spatial filter and returns an image.
    
    Parameters in GET variable
    ===========================
    grid_level : int
        The grid layer.
    taxonomic_level : string
        The taxonomic level to be shown. 
        Options are: sp, gns, fam, ord, cls, phy, king
        
    Returns
    =======
    HTTP RESPONSE
    with an image showing the tree.
    
    See figure: 
    .. image:: 
    """
    from ete2.treeview import drawer
    from PyQt4 import QtCore
    import ipdb
    
    response = HttpResponse()
    get = request.GET
    try:
        
        gid = int(get['gid'])
        grid_level = int(get['g_l'])
        taxonomic_level = get['tax_lvl']
    except:
        response.content='Bad request. Check GET variable definitions'
        response.status_code = 500
        return response
    
    biome = Occurrence.objects.all() 
    mesh = initMesh(grid_level)
    try:
        cell = mesh.objects.get(id=gid)
    except:
        logger.error("Selected id does not exist in selected grid")
        return None
    
    import os.path
    
    head_path = settings.PATH_IMAGES
    filename = "%s-%s-%s.png" %(grid_level,gid,taxonomic_level)
    file_ = head_path+filename
    logger.info('Writing in: %s'%file_)    
    if not os.path.isfile(file_):
        logger.info("The image doens't exist") 
        gb=GriddedTaxonomy(biome,cell,generate_tree_now=True)
        forest = gb.taxonomies[0].forest

        ts = TreeStyle()
        ts.show_leaf_name = True
        ts.mode = "c"
        ts.arc_start = -180 # 0 degrees = 3 o'clock
        ts.arc_span = 360
        try:
            #ipdb.set_trace()
            forest[taxonomic_level].render(file_, w=100, units="mm",tree_style=ts)
            #drawer.exit_gui(1, 1)
            
            #logger.info(QtCore.QThreadPool)
            del(forest[taxonomic_level])
        except:
            logger.error('Something went wrong with the image rendering')
        #del(forest)
    #ipdb.set_trace()
    template = get_template('base.html')
    html = template.render(Context({'gid':gid,'taxonomic_level':taxonomic_level,'grid_level':grid_level,'image_path':filename}))
    response.content=(html)
    #response.content=str(forest[taxonomic_level])
    response.status_code = 200
    
    return response
开发者ID:molgor,项目名称:biospatial,代码行数:82,代码来源:views.py

示例5: showAllLevelsInTreeInGrid

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
def showAllLevelsInTreeInGrid(request):
    """
    Performs a selection, spatial filter and returns an image.
    grid_level is the grid layer.
    taxonomic_level is the taxonomic level to be shown. Options are:
    sp, gns, fam, ord, cls, phy, king
    """

    import ipdb
    
    response = HttpResponse()
    get = request.GET
    try:
        
        gid = int(get['gid'])
        grid_level = int(get['g_l'])
        names = int(get['names'])
        if names > 0:
            only_id = False
        else:
            only_id = True
        #taxonomic_level = get['tax_lvl']
    except:
        response.content='Bad request. Check GET variable definitions'
        response.status_code = 500
        return response
    
    biome = Occurrence.objects.all() 
    mesh = initMesh(grid_level)
    try:
        cell = mesh.objects.get(id=gid)
    except:
        logger.error("Selected id does not exist in selected grid")
        return None
    
    import os.path
    tax_levels = ['sp','gns','fam','cls','ord','phy','kng']
    tax_keys = {'sp':'1.Species','gns':'2. Genera','fam':'3. Families','ord':'4. Orders','cls':'5. Classes','phy':'6. Phyla','kng':'7. Kingdoms'}
    rich_keys = { 'oc':'occurrences','sp' :'species','gns':'genera','fam':'families','cls':'classes','ord':'orders','phy':'phyla','kng':'kingdoms'}
    img_paths = {}
    #THIS IS VERY VERY WRONG AND I WOULD SUGGEST A REFACTORING like the use of a binary written copy in disk about the object in question (cached)
    gb=GriddedTaxonomy(biome,cell,generate_tree_now=True,use_id_as_name=only_id)
    taxonomy = gb.taxonomies[0]
    #ipdb.set_trace()
    mat_complex = taxonomy.calculateIntrinsicComplexity()
    for taxonomic_level in tax_levels:
        head_path = settings.PATH_IMAGES
        filename = "%s-%s-%s.png" %(grid_level,gid,taxonomic_level)
        file_ = head_path+filename
        logger.info('Writing in: %s'%file_)    
        if not os.path.isfile(file_):
            logger.info("The image doens't exist") 
            try:
                if gb not in locals():
                    #gb=GriddedTaxonomy(biome,cell,generate_tree_now=True)
                    logger.info("Gridded taxonomy doesn't found")
            except:
                gb=GriddedTaxonomy(biome,cell,generate_tree_now=True,use_id_as_name=only_id)
            forest = taxonomy.forest

            ts = TreeStyle()
            ts.show_leaf_name = True
            ts.mode = "c"
            ts.arc_start = -180 # 0 degrees = 3 o'clock
            ts.arc_span = 360
            ts.show_scale = False
            try:
                #ipdb.set_trace()
                forest[taxonomic_level].render(file_,h=500, w=500, units="px",tree_style=ts)
                #drawer.exit_gui(1, 1)
                
                #logger.info(QtCore.QThreadPool)
                #del(forest[taxonomic_level])
            except:
                logger.error('Something went wrong with the image rendering')
                
                
            img_paths[taxonomic_level] = {'name': tax_keys[taxonomic_level],'path':filename,'richness':taxonomy.richness[rich_keys[taxonomic_level]]}
        else:
            img_paths[taxonomic_level] = {'name': tax_keys[taxonomic_level],'path':filename,'richness':taxonomy.richness[rich_keys[taxonomic_level]]}
        #del(forest)
    #
    
    
    #dic_richness = gb.taxonomies[0].richness
    det_complex = gb.taxonomies[0].vectorIntrinsic 
    template = get_template('base.html')

    submatrices = map(lambda i : mat_complex[0:i,0:i],range(1,len(mat_complex)))
    #ipdb.set_trace()
    import numpy as np
    tras = map(lambda mat : np.linalg.eigvals(mat),submatrices)
    #ipdb.set_trace()
    try:
        eigenv = np.linalg.eigvals(mat_complex).tolist()
        svd = np.linalg.svd(mat_complex)
        
    except:
        eigenv =[]
        svd = [[],[],[]]
#.........这里部分代码省略.........
开发者ID:molgor,项目名称:biospatial,代码行数:103,代码来源:views.py

示例6: Tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
if __name__ == "__main__":
    full_tree = Tree('swisstree_speciestree.nhx')

    for leaf in full_tree:
        fields = leaf.name.split("__")
        name = fields[1].replace('_', ' ')
        code = "%s" %fields[0].strip()
        leaf.orig_name = leaf.name
        leaf.name = code
       
   
    # basic tree styling 
    ts = TreeStyle()
    ts.show_leaf_name = False
    ts.layout_fn = layout
    ts.arc_span = 340
    ts.show_scale = False

    # Make a pruned version of the tree
    pruned_tree = full_tree.copy()
    valid_codes = set(['CANAL', 'CHLAA', 'KORCO', 'IXOSC', 'ORNAN', 'BACTN',
                       'RHOBA', 'GLOVI', 'PSEAE', 'METJA', 'DICTD', 'METAC', 'MYCTX', 'PHANO',
                       'HALSA', 'TRIVA', 'XENTR', 'MONBE', 'ASPFU', 'BACSU', 'GIAIC', 'CIOIN',
                       'ECOLI', 'SCHPO', 'RAT', 'USTMA', 'HUMAN', 'MONDO', 'SCHMA', 'DANRE',
                       'MOUSE', 'THEKO', 'STRCO', 'CAEEL', 'THEMA', 'BOVIN', 'GEOSL', 'NEUCR',
                       'CANFA', 'BRADU', 'MACMU', 'ARATH', 'PHYPA', 'SYNY3', 'NEMVE', 'DROME',
                       'PLAF7', 'CHICK', 'BRAFL', 'YARLI', 'LEIMA', 'PANTR', 'FUSNN', 'TAKRU',
                       'LEPIN', 'DEIRA', 'SCLS1', 'DICDI', 'YEAST', 'CRYNJ', 'SULSO', 'THAPS',
                       'THEYD', 'AQUAE', 'ANOGA', 'CHLTR'])
    target_codes = (set(full_tree.get_leaf_names()) & valid_codes)
    pruned_tree.prune(target_codes)
开发者ID:qfo,项目名称:utils,代码行数:33,代码来源:render_swisstree_images.py

示例7: exit

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
#!/usr/bin/python

# drawunrootedcircular.py
# Use ete2 to render an unrooted tree from an input Newick formatted tree file.
# Render the tree as circular.

# sys.argv[1] -- filename for tree file
# sys.argv[2] -- filename for output .png file

import sys
from ete2 import Tree, TreeStyle

if( len(sys.argv) != 3 ):
  print "Usage: python drawunrootedcircular.py <Newick_file> <Tree_png>"
  exit(-1)

t = Tree(sys.argv[1])
c = TreeStyle()
c.mode = "c"
c.scale = 50
c.arc_start = -90
c.arc_span = 360

t.render(sys.argv[2], w=720, units="px", tree_style=c)
开发者ID:kmcnamara,项目名称:sstrees,代码行数:26,代码来源:drawunrootedcircular.py

示例8: Tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
#from models import Count,Sum,Avg
from django.contrib.gis.db.models import Extent, Union, Collect,Count,Min
from gbif.models import Specie,Genus,Family,Order,Class,Phylum,Kingdom
from mesh.models import NestedMesh
from django.contrib.gis.db.models.query import GeoQuerySet
logger = logging.getLogger('biospatial.gbif.general_test')
import biospatial.settings as settings 
# Create your tests here.

from ete2 import Tree, TreeStyle
t = Tree()
ts = TreeStyle()
ts.show_leaf_name = True
ts.mode = "c"
ts.arc_start = -180 # 0 degrees = 3 o'clock
ts.arc_span = 360



    
from gbif.taxonomy import Taxonomy,embedTaxonomyInGrid,embedTaxonomyInNestedGrid,NestedTaxonomy    
    
def createShapefile(taxonomy_list,name='default_name',store='out_maps'):
    """
    This function creates a shapefile for a given list of Taxonomies.
    Do note that the list of taxonomies is a mapping to the cells in a mesh.
    """
    #Method for generating the shapefile object
    from osgeo import ogr
    #from shapely.geometry import Polygon    
    # Now convert it to a shapefile with OGR    
开发者ID:molgor,项目名称:biospatial,代码行数:33,代码来源:tests.py

示例9: sum

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import arc_span [as 别名]
        for e in old_edges:
                to = e[1]
                dist = e[2]["weight"]
                if dist < r:
                        RadiusGraph.add_edge(n, to, weight=dist )


nodes = RadiusGraph.nodes()
total_radius = sum(map(lambda x: RadiusGraph.node[x]["weight"], nodes))

average_radius = total_radius/float(len(nodes))
partgraph =  partition(RadiusGraph)
print json.dumps(partgraph)


source = str(partgraph)+";"
t = Tree(source)
ts = TreeStyle()
ts.show_leaf_name = True
ts.mode = "c"
ts.arc_start = -180 # 0 degrees = 3 o'clock
ts.arc_span = 180
t.show(tree_style=ts)
#pos = nx.spring_layout(partgraph,weight="weight")
#nx.draw(partgraph,pos)
#nx.draw(RadiusGraph,pos)
#end = time.time()
#print end-start
#plt.show()

开发者ID:csc8630Spring2014,项目名称:Clusterizer,代码行数:31,代码来源:prototype.py


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