New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBOLv2 Stem-top glyphs #21

Merged
merged 4 commits into from Aug 24, 2018

Conversation

Projects
None yet
2 participants
@castillohair
Copy link
Contributor

castillohair commented Aug 18, 2018

This PR adds the "stem-top" class of glyphs specified in SBOL visual 2.0. This class of glyphs contains, at this moment, three types of glyphs:

  • Cleavage site
  • Biopolymer location
  • Stability element

The "top" portion of the glyph specifies one of these three, whereas the "stem" portion indicates whether the glyph refers to DNA, RNA, or Protein. These replace the previous "Ribonuclease site", "Protease site", "RNA stability element", and "Protein stability element" from SBOLv1. For more information, refer to the specification, pages 21-22, 29-31, and 44-45.

This PR defines the following new parts:

  • DNACleavageSite
  • RNACleavageSite
  • ProteinCleavageSite
  • DNALocation
  • RNALocation
  • ProteinLocation
  • DNAStability
  • RNAStability
  • ProteinStability
  • StemTop

The first 9 are self-explanatory given the specification (see example code below). The last one is a generic "StemTop" glyph where the stem and top can be manually chosen using options stem and top.

The current version of dnaplotlib includes 4 "stick figure" glyphs from SBOLv1. Three of these are redirected to the appropriate stem-top glyph in this PR (Ribonuclease, Protease, ProteinStability). The fourth one is called Ribozyme, however no ribozyme glyph is actually defined in SBOLv1 or v2. In fact, the Ribozyme part is mapped to the "RNA Stability Element" glyph from SBOLv1. I didn't know what to do with this, so rather than removing it I opted for leaving it unchanged. I can modify this if required.

As an example, the following code:

import dnaplotlib as dpl
import matplotlib.pyplot as plt

# Global line width
lw = 1.5

# Define design 1
c1 = {'type':'DNACleavageSite', 'name':'c1', 'fwd':True, 'opts':{'linewidth':lw}}
c2 = {'type':'RNACleavageSite', 'name':'c2', 'fwd':True, 'opts':{'linewidth':lw}}
c3 = {'type':'ProteinCleavageSite', 'name':'c3', 'fwd':True, 'opts':{'linewidth':lw}}
l1 = {'type':'DNALocation', 'name':'l1', 'fwd':True, 'opts':{'linewidth':lw}}
l2 = {'type':'RNALocation', 'name':'l2', 'fwd':True, 'opts':{'linewidth':lw}}
l3 = {'type':'ProteinLocation', 'name':'l3', 'fwd':True, 'opts':{'linewidth':lw}}
s1 = {'type':'DNAStability', 'name':'s1', 'fwd':True, 'opts':{'linewidth':lw}}
s2 = {'type':'RNAStability', 'name':'s2', 'fwd':True, 'opts':{'linewidth':lw}}
s3 = {'type':'ProteinStability', 'name':'s3', 'fwd':True, 'opts':{'linewidth':lw}}
design1 = [c1, c2, c3, l1, l2, l3, s1, s2, s3]

# Define design 2
c1r = {'type':'DNACleavageSite', 'name':'c1r', 'fwd':False, 'opts':{'linewidth':lw}}
c2r = {'type':'RNACleavageSite', 'name':'c2r', 'fwd':False, 'opts':{'linewidth':lw}}
c3r = {'type':'ProteinCleavageSite', 'name':'c3r', 'fwd':False, 'opts':{'linewidth':lw}}
l1r = {'type':'DNALocation', 'name':'l1r', 'fwd':False, 'opts':{'linewidth':lw}}
l2r = {'type':'RNALocation', 'name':'l2r', 'fwd':False, 'opts':{'linewidth':lw}}
l3r = {'type':'ProteinLocation', 'name':'l3r', 'fwd':False, 'opts':{'linewidth':lw}}
s1r = {'type':'DNAStability', 'name':'s1r', 'fwd':False, 'opts':{'linewidth':lw}}
s2r = {'type':'RNAStability', 'name':'s2r', 'fwd':False, 'opts':{'linewidth':lw}}
s3r = {'type':'ProteinStability', 'name':'s3r', 'fwd':False, 'opts':{'linewidth':lw}}
design2 = [c1r, c2r, c3r, l1r, l2r, l3r, s1r, s2r, s3r]

# Create matplotlib figure
plt.figure()
f, (ax1, ax2) = plt.subplots(1, 2)

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

# Redender the DNA to axis

start, end = dr.renderDNA(ax1, design1, dr.SBOL_part_renderers())
ax1.set_xlim([start, end])
ax1.set_ylim([-15,15])
ax1.set_aspect('equal')
ax1.set_xticks([])
ax1.set_yticks([])
ax1.axis('off')

start, end = dr.renderDNA(ax2, design2, dr.SBOL_part_renderers())
ax2.set_xlim([start, end])
ax2.set_ylim([-15,15])
ax2.set_aspect('equal')
ax2.set_xticks([])
ax2.set_yticks([])
ax2.axis('off')

plt.savefig('test_stem_top.png', dpi=200)

produces the following image:

test_stem_top

(Note that fixing issue #19, in addition to this PR, is required for this script to run in my computer).

I'm open to modify names, code organization, or other details if required.

@chofski chofski merged commit a382ec0 into VoigtLab:master Aug 24, 2018

@castillohair castillohair deleted the castillohair:stem-top branch Aug 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment