Exemplo n.º 1
0
doc = sbol.Document()
doc.read('gene_cassette.sbol')

# In this case, we know ahead of time the URI of the design.  In some cases, you may have to explore the doc's components to find the design you are looking for
design = doc.components['http://sbolstandard.org/examples/Design']
print design.display_id

# Create the DNAplotlib renderer
dr = dpl.DNARenderer()

# Instantiate rendered
part_renderers = dr.SBOL_part_renderers()

# Create the figure
fig = plt.figure()
ax = plt.gca()

# Render SBOL.  This function has parallel structure to renderDNA
start, end = dr.renderSBOL(ax, design, part_renderers)

# Give the figure a title
dpl.write_label(ax, design.display_id, (start+end)/2, { 'label_size' : 18, 'label_y_offset': 12 })

# Configure plot
ax.set_xlim([start, end])
ax.set_ylim([-18,18])
ax.set_aspect('equal')
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')
plt.show()
Exemplo n.º 2
0
def promoter_region(ax, type, num, start, end, prev_end, scale, linewidth,
                    opts):
    # Default parameters - these can be added to, but we usually use this style (probably should simplify in future)
    y_offset = 0.0
    color_35 = (0.5, 0.5, 0.5)
    color_10 = (0.5, 0.5, 0.5)
    color_connector = (0, 0, 0)
    linewidth_connector = 2.0
    len_35 = 4
    len_10 = 2
    y_extent = 4.0
    # Update default parameters if provided
    if opts != None:
        if 'y_extent' in opts.keys():
            y_extent = opts['y_extent']
        if 'y_offset' in opts.keys():
            y_offset = opts['y_offset']
        if 'linewidth' in opts.keys():
            linewidth = opts['linewidth']
        if 'color_35' in opts.keys():
            color_35 = opts['color_35']
        if 'color_10' in opts.keys():
            color_10 = opts['color_10']
        if 'color_connector' in opts.keys():
            color_connector = opts['color_connector']
        if 'linewidth_connector' in opts.keys():
            linewidth_connector = opts['linewidth_connector']
        if 'len_35' in opts.keys():
            len_35 = opts['len_35']
        if 'len_10' in opts.keys():
            len_10 = opts['len_10']
    # Check direction (we don't use at moment)
    fwd = True
    if start > end:
        fwd = False
    # Draw the -35 site (from start to start + length of -35 site)
    p35 = Polygon([(start, y_offset), (start, y_offset + y_extent),
                   (start + len_35, y_offset + y_extent),
                   (start + len_35, y_offset)],
                  edgecolor=(0, 0, 0),
                  facecolor=color_35,
                  linewidth=linewidth,
                  zorder=11,
                  path_effects=[Stroke(joinstyle="miter")])
    ax.add_patch(p35)
    # Draw the -10 site (from end-length of -10 site to end)
    p10 = Polygon([(end - len_10, y_offset),
                   (end - len_10, y_offset + y_extent),
                   (end, y_offset + y_extent), (end, y_offset)],
                  edgecolor=(0, 0, 0),
                  facecolor=color_10,
                  linewidth=linewidth,
                  zorder=11,
                  path_effects=[Stroke(joinstyle="miter")])
    ax.add_patch(p10)
    l1 = Line2D([start + len_35, end - len_10],
                [y_offset + (y_extent / 2.0), y_offset + (y_extent / 2.0)],
                linewidth=linewidth_connector,
                color=color_connector,
                zorder=10)
    ax.add_line(l1)

    # Add a label if needed
    if opts != None and 'label' in opts.keys():
        if final_start > final_end:
            dpl.write_label(ax,
                            opts['label'],
                            final_end + ((final_start - final_end) / 2.0),
                            opts=opts)
        else:
            dpl.write_label(ax,
                            opts['label'],
                            final_start + ((final_end - final_start) / 2.0),
                            opts=opts)
    # Return the final start and end positions to the DNA renderer
    return start, end
Exemplo n.º 3
0
def promoter_region (ax, type, num, start, end, prev_end, scale, linewidth, opts):
	# Default parameters - these can be added to, but we usually use this style (probably should simplify in future)
	y_offset = 0.0
	color_35 = (0.5,0.5,0.5)
	color_10 = (0.5,0.5,0.5)
	color_connector = (0,0,0)
	linewidth_connector = 2.0
	len_35 = 4
	len_10 = 2
	y_extent = 4.0
	# Update default parameters if provided
	if opts != None:
		if 'y_extent' in list(opts.keys()):
			y_extent = opts['y_extent']
		if 'y_offset' in list(opts.keys()):
			y_offset = opts['y_offset']
		if 'linewidth' in list(opts.keys()):
			linewidth = opts['linewidth']
		if 'color_35' in list(opts.keys()):
			color_35 = opts['color_35']
		if 'color_10' in list(opts.keys()):
			color_10 = opts['color_10']
		if 'color_connector' in list(opts.keys()):
			color_connector = opts['color_connector']
		if 'linewidth_connector' in list(opts.keys()):
			linewidth_connector = opts['linewidth_connector']
		if 'len_35' in list(opts.keys()):
			len_35 = opts['len_35']
		if 'len_10' in list(opts.keys()):
			len_10 = opts['len_10']
	# Check direction (we don't use at moment)
	fwd = True
	if start > end:
		fwd = False
	# Draw the -35 site (from start to start + length of -35 site)
	p35 = Polygon([(start, y_offset), 
		           (start, y_offset+y_extent),
		           (start+len_35,y_offset+y_extent),
		           (start+len_35,y_offset)],
		            edgecolor=(0,0,0), facecolor=color_35, linewidth=linewidth, zorder=11, 
		            path_effects=[Stroke(joinstyle="miter")])		
	ax.add_patch(p35)
	# Draw the -10 site (from end-length of -10 site to end)
	p10 = Polygon([(end-len_10, y_offset), 
		           (end-len_10, y_offset+y_extent),
		           (end,y_offset+y_extent),
		           (end,y_offset)],
		            edgecolor=(0,0,0), facecolor=color_10, linewidth=linewidth, zorder=11, 
		            path_effects=[Stroke(joinstyle="miter")])		
	ax.add_patch(p10)
	l1 = Line2D([start+len_35, end-len_10],
                [y_offset+(y_extent/2.0), y_offset+(y_extent/2.0)], linewidth=linewidth_connector, 
                color=color_connector, zorder=10)
	ax.add_line(l1)

	# Add a label if needed
	if opts != None and 'label' in list(opts.keys()):
		if final_start > final_end:
			dpl.write_label(ax, opts['label'], final_end+((final_start-final_end)/2.0), opts=opts)
		else:
			dpl.write_label(ax, opts['label'], final_start+((final_end-final_start)/2.0), opts=opts)
	# Return the final start and end positions to the DNA renderer
	return start, end
Exemplo n.º 4
0
# Create the DNAplotlib renderer
dr = dpl_sbol.SBOLRenderer()

# Instantiate rendered
part_renderers = dr.SBOL_part_renderers()

# Create the figure
fig = plt.figure()
ax = plt.gca()
start, end = dr.renderSBOL(
    ax, design, part_renderers
)  # Render SBOL.  This function has parallel structure to renderDNA

# Give the figure a title
dpl.write_label(ax, design.display_id, (start + end) / 2, {
    'label_size': 18,
    'label_y_offset': 12
})

# Configure plot
ax.set_xlim([start, end])
ax.set_ylim([-18, 18])
ax.set_aspect('equal')
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')

# Save the figure
fig.savefig('sbol_visual.pdf', transparent=True)
fig.savefig('sbol_visual.png', dpi=300)

# Clear the plotting cache