DNAplotlib is a library that enables highly customizable visualization of individual genetic constructs and libraries of design variants.
This forked repository is updated by Sunwoo Kang as a part of Google's Summer of Code 2018 project. The updated visualization follows the latest standard of Synthetic Biology Open Language (SBOL) version 2.2 . This library allows both import/export, and creation of SBOL2 files. The original repository was developed under Voigt Lab in the following link:
My [Sunwoo Kang’s] task was to help the main developer of DNAplotlib, Tom Gorochowski, provide ways to render SVG files on Matplotlib canvas (svgpath2mpl.py), and develop a new datatype to store the genetic circuit design data (datatype.py) that is compatible with SBOL standard. The previous DNAplotlib rendered each part by raw coordinates, but with the updated version having more part glyphs we decided to standardize parts by having different parts saved as svg files, then using same drawing function to render them.
To develop these features, I helped Tom producing parametric SVG files of SBOL Visual glyph. There are nine clean SVG files, which includes a few new glyphs from the SBOL Visual 2 such as macromolecules and RNA strand. Since the svg files provided on the website were created by software, they came with properties that was hard to extract path values. For the sake of time, I moved on to the next step of the project. I created rendering function (render.py) to render these glyphs at a user-specified position or automatically position the genetic circuit design in the canvas. The main challenge was coming up with the best default rendering convention. This included aspects such as altering the datatype to accommodate the overall extent of a glyph and specifying the position of the origin in each glyph to be lower left corner of the SVG image. The functions automatically position and align parts on a DNA strand. In addition user can adjust size, positioning, and angle of the visual glyphs.
I also wrote functions that would automatically position and draw parts not associated to a DNA strand (e.g. a protein), modules, submodules, and interactions. This involved writing recursive functions to fully visualize complex hierarchies and the interactions between components at various levels. Furthermore, I abstracted the interaction rendering in a way that allows easier differentiation of interactions by their arrowhead and colors. To avoid multiple interactions causing confusion, I added random positioning to arrow path heights so that no two or more arrows have the height values.
The final step of the project was to import and export the design data into SBOL files. DNAplotlib now allows import/export and rendering of simple genetic design consisted of parts and modules. It also supports the creation and rendering of complex genetic design with modular hierarchies and interactions. The example test design files can be found under dnaplotlib/design directory. However, when writing this code, I ran into backend problems with the pySBOL library, such as StopIteration errors, which I was unable to debug in the time I had available. However, I did have some success importing and exporting simple genetic circuit designs (see ie.py).
Here are some example visualization by the updated DNAplotlib.
More visualization example scripts can be found under the dnaplotlib/examples directory.
doc = sbol.Document()
doc.read('test_design.xml')
design = dt.Design('design')
design.add_module(extract_module_and_components(doc, design, doc.moduleDefinitions))
design.print_design() # optional - check whether design properly imported
m_frames = draw.get_module_frames(design.modules)
fig, ax = plt.subplots(1, figsize=(8,10))
ax.set_xlim(XMIN, XMAX)
ax.set_ylim(YMIN, YMAX)
ax.set_axis_off()
draw.draw_all_modules(ax, m_frames, design.modules)
draw_all_interaction(ax, design.interactions)
plt.show()
document = sbol.Document()
document.addNamespace('http://dnaplotlib.org#', 'dnaplotlib')
datatype.save_design_into_doc(document, design)
document.write('test_design_updated.xml')
Commit period: May 16, 2018 - Now
- ac58dd3 : setup for rendering sbol files
- e38ccd1 : sanity check for componentDefinition & targer promoter file
- 605bbfa : pysbol not available in ijupyter
- 1e2836d : nonsense sbol compliant files
- 5d7f395 : three level hierarchy file
- 21a8d57 : script for specifying primary structure of all component definitions
- 4be3f05 : cleanup nonsense primary structure script
- b571ccc : fetch components in order of primary structure & render glyphs
- 87cbd8f : draw glyph function from render.py is now drawn on position
- 1fc6b4b : sbol2plotlib plays with matplotlib drawing
- 69c34f8 : glyph resized to given frame
- 6e29311 : promoter svg file updated, bug found with glyph render func
- 1175460 : finished promoter svg file cleanup & started ori cleanup
- c70c803 : strandrenderer added (draw dna backbone)
- 53b9217 : sanity file & rotate fuc
- e06b23d : example added & rotation func
- dd26852, 970bae2 : struggle commiting to original repo
- b6ac1db : ori svg file & draw_glyph can render circle
- cc9b26d : python syntax
- b6bd28e : hierarchy module box rendering func
- 6ae7137 : macromolecule svg attempt
- a302260 : unspecified svg & cds attempt
- 9499f68 : glyph rendering y correction func added
- f2c6769 : datatype test case first created
- 7ee4415 : positioning func for design & modules
- 12ba693 : bug fix for module positioning
- 64aaf63 : origin coordinate tuple changed to list
- c0997fc : promoter frame bug fix
- 0a576b9 : interaction arrow body rendering func
- 10b13a2 : arrowhead for interaction added
- dfdc00b : finished recursive rendering of modules
- 7429ad9 : coordinate property added to datatype interaction class
- 3bd80f4 : Interaction Render class
- 44e5871 : other part RNA rendering
- ff71af6 : save before submodule render fix
- 24dcba2 : submodule render spacing bug fix
- 99a9238 : run into bug while importing sbol file
- fad5f32 : test_design5 import and export modules & components
- 6deec09 : bug fix & func decomposition
- e7ec582, bbe6214, fe994fb, 8695653, f821381, 419d435, 4adf901 : readme edit for final submission
The DNAplotlib library is contained within the dnaplotlib.py file in the lib directory and requires Python 2.6 and matplotlib 1.2 or newer and pySBOL package. To install follow instructions below and: import dnaplotlib
Get setuptools if you don't have it: https://pypi.org/project/setuptools/2.0/#installation-instructions
Install the Dnaplotlib package on your system in a contained development environment: python setup.py develop --user
You should now be able to import Dnaplotlib from any directory on your system and import it into other projects. Edits to source code in your development repository will be reflected in the behavior of the package without reinstalling it.
To clean the development package from your system: python setup.py develop --user --uninstall
Note some issue importing matplotlib dependency on Mac OS X Yosemite and later
DNAplotlib would be useful if it can also handle simple CSV files with genetic design definitions. Also it should allow more visualization options (e.g. customization of basic visual properties like color) and save back the visual properties generated by my functions to SBOL files as an extension. Finally, the StopIteration Error during recursive reading of submodules need debugging.
I would like to thank my mentors, Thomas Gorochowski, PhD (University of Bristol) and Bryan Bartley, PhD (Raytheon BBN Technologies), for their guidance and support. I would further like thank NRNB and SBOL community for their warm welcome, and National Science Foundation for generous support to attend the COMBINE 2018 conference. Lastly, I express my gratitude to Google for hosting Code for Summer program.





