Package: scadnano
scadnano Python packagescadnano("scriptable-cadnano") is a program for designing synthetic DNA structures such as DNA origami.
The scadnano Python package
(source code repository here)
is a library for programmatically creating and editing these nanostructures.
The scadnano project is developed and maintained by the UC Davis Molecular Computing group.
Note thatcadnanois a separate project, developed and maintained by theDouglas labat UCSF.If you find scadnano useful in a scientific project, please cite its associated paper:scadnano: A browser-based, scriptable tool for designing DNA nanostructures.David Doty, Benjamin L Lee, and Tristan Stérin.DNA 2020:Proceedings of the 26th International Conference on DNA Computing and Molecular Programming[paper|BibTeX]Note:If you are reading this on the PyPI website, some of the links below won't work. Many are relative links intended to be read on theGitHub README page.Table of contentsOverviewReporting issuesInstallationExampleAbbreviated syntax with chained methodsStrandBuilder object for iteratively building up strands with many domainsTutorialAPI documentationOther examplesContributingOverviewThis package is used to write Python scripts outputting.scfiles readable byscadnano, a web application useful for displaying and manually editing these structures. The purpose of this module is to help automate some of the task of creating DNA designs, as well as making large-scale changes to them that are easier to describe programmatically than to do by hand in the scadnano web interface.We will try to announce breaking changes (and possibly new features) under theGitHub releases page. The version numbers in this Python library repo and theweb interface repowon't always advance at the same time, and sometimes a feature is supported in one before the other.Followingsemantic versioning, version numbers are major.minor.patch, i.e., version 0.9.2 has minor version number 9. Prior to version 1.0.0, when a breaking change is made, this will increment the minor version (for example, going from 0.9.4 to 0.10.0). After version 1.0.0, breaking changes will increment the major version.Reporting issuesPlease report issues in the web interface at thescadnano web interface GitHub repository, and report issues in the Python scripting library at thescadnano Python package GitHub repository.InstallationShort version: type this at the command line:pip install scadnanoRead below for troubleshooting suggestions if that didn't work.Getting PythonThe scadnano Python package requires Python version 3.7 or later.To check your current version of Python, open a command line and typepython --versionIf it is version 2.7 or below, typepython3 --versionIf that fails, or reports Python version 3.6 or below, you will have to install a later version of Python. Followthis linkto install Python. You may also use an alternative Python distribution, such asAnaconda.Installing the scadnano Python packageOnce Python is installed, there are two ways you can install the scadnano Python package:pip (recommended)Usepipto install the package by executing the following at the command line:pip install scadnanoIf it worked, you should be able to open a Python interpreter and import the scadnano module:Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information.>>> import scadnano as sc>>> print(sc.Domain(helix=1, forward=True, start=0, end=8))Domain(, helix=1, forward=True, start=0, end=8)>>>TroubleshootingIf the above does not work for you, here are some things to try.If your Python installation does not already have pip installed, you may have to install it.
Executingthis Python scriptshould work;
see alsohttps://docs.python.org/3/installing/index.htmlorhttps://www.liquidweb.com/kb/install-pip-windows/.Once pip is installed, or if you believe it is already installed, check your version ofpipby typingpip --versionIt should say something likepip 19.3.1 from ...lib\site-packages\pip (python 3.8)If the version of Python at the end is Python 3.7 or higher, you are good. If it is version 2.7 or lower, typepip3 --versionIf that works and shows Python 3.7 or higher, you are good, but you should typepip3in the subsequent instructions instead ofpip.If it shows Python 3.6, install thedataclasses backport moduleviapip install dataclassesIf it shows Python 3.5 or lower, then you will need to upgrade your Python version (recommended Python 3.7 or higher).downloadAs a simple alternative (in case you run into trouble using pip), you can simply download the scadnano.py file. However, you need to first install two packages that are required by scadnano: Installopenpyxlandtabulateby typing the following at the command line:pip install openpyxl tabulate.Download and place the following files in yourPYTHONPATH(e.g., in the same directory as the scripts you are running).Note:If you are reading this on the PyPI website or anywhere other than GitHub, the links below won't work. They are relative links intended to be read on theGitHub README page.required:scadnano.pyoptional:modifications.py; This contains some common DNA modifications such as biotin and Cy3.optional:origami_rectangle.py; This can help create origami rectangles, but it is not necessary to use scadnano.To download them, right-click on "Raw" near the top and select (in Chrome or Firefox) "Save link as...":The scadnano package uses the Python packagexlwtto write Excel files, so xlwt must be installed in order to call the methodDesign.write_idt_plate_excel_file()to export an Excel file with DNA sequences. To install xlwt, typepip install xlwtat the command line. (If you instead use pip to install the scadnano package, xlwt will be automatically installed.)ExampleConsider the following design:The following Python script produces this design.importscadnanoasscimportmodificationsasmoddefcreate_design()->sc.Design:# heliceshelices=[sc.Helix(max_offset=48),sc.Helix(max_offset=48)]# left staplestap_left_domain1=sc.Domain(helix=1,forward=True,start=8,end=24)stap_left_domain0=sc.Domain(helix=0,forward=False,start=8,end=24)stap_left=sc.Strand(domains=[stap_left_domain1,stap_left_domain0])# right staplestap_right_domain0=sc.Domain(helix=0,forward=False,start=24,end=40)stap_right_domain1=sc.Domain(helix=1,forward=True,start=24,end=40)stap_right=sc.Strand(domains=[stap_right_domain0,stap_right_domain1])stap_right.set_modification_5p(mod.biotin_5p)# scaffoldscaf_domain1_left=sc.Domain(helix=1,forward=False,start=8,end=24)scaf_domain0=sc.Domain(helix=0,forward=True,start=8,end=40)loopout=sc.Loopout(length=3)scaf_domain1_right=sc.Domain(helix=1,forward=False,start=24,end=40)scaf=sc.Strand(domains=[scaf_domain1_left,scaf_domain0,loopout,scaf_domain1_right],is_scaffold=True)# whole designdesign=sc.Design(helices=helices,strands=[scaf,stap_left,stap_right],grid=sc.square)# deletions and insertions added to design are added to both strands on a helixdesign.add_deletion(helix=1,offset=20)design.add_insertion(helix=0,offset=14,length=1)design.add_insertion(helix=0,offset=26,length=2)# also assigns complement to strands other than scaf bound to itdesign.assign_dna(scaf,'AACGT'*18)returndesignif__name__=='__main__':design=create_design()design.write_scadnano_file(directory='output_designs')Running the code above produces a.scfile that, if loaded into scadnano, should appear as in the screenshot above. Theweb interface READMEexplains many of the terms used in the code (domain, helix, loopout, insertion, etc.).Abbreviated syntax with chained methodsInstead of explicitly creating variables and objects representing each domain in each strand, there is a shorter syntax using chained method calls. Instead of the above, create only the helices first, then create the Design. Then strands can be added using a shorter syntax, to describe how to draw the strand starting at the 5' end and moving to the 3' end. The following is a modified version of the abovecreate_designfunction using these chained methods:defcreate_design()->sc.Design:# heliceshelices=[sc.Helix(max_offset=48),sc.Helix(max_offset=48)]# whole designdesign=sc.Design(helices=helices,grid=sc.square)# for absolute offsets, call method "to"# left stapledesign.draw_strand(1,8).to(24).cross(0).to(8)# for relative offsets, call method "move"# right stapledesign.draw_strand(0,40).move(-16).cross(1).move(16).with_modification_5p(mod.biotin_5p)# scaffolddesign.draw_strand(1,24).move(-16).cross(0).move(32).loopout(1,3).move(-16).as_scaffold()# deletions and insertions added to design are added to both strands on a helixdesign.add_deletion(helix=1,offset=20)design.add_insertion(helix=0,offset=14,length=1)design.add_insertion(helix=0,offset=26,length=2)# also assigns complement to strands other than scaf bound to itdesign.assign_dna(design.scaffold,'AACGT'*18)returndesignDocumentation is available in theAPI docs.StrandBuilder object for iteratively building up strands with many domainsThe methodDesign.draw_strand, as well as all those that follow it in a chained method call (e.g.,move,cross, etc.) all return an instance of the classStrandBuilder.
Above, thatStrandBuilderinstance is anonymous, i.e., never assigned to a variable.
Some long strands may be easier to specify with loops, for example an M13 scaffold strand for an origami.
If so, then to use the above methods, assign theStrandBuilderobject to a variable, and call the relevant methods on that object to build up the strand in each iteration of the loop.
For example, the following modification of the abovecreate_designfunction creates a linear scaffold strand that zig-zags back and forth across 32 helices:defcreate_design()->sc.Design:num_helices=32helices=[sc.Helix(max_offset=200)for_inrange(num_helices)]design=sc.Design(helices=helices,grid=sc.square)strand_builder=design.draw_strand(0,0)forhelixinrange(num_helices):# move forward if on an even helix, otherwise move in reversemove_distance=200ifhelix%2==0else-200strand_builder.move(move_distance)ifhelix<31:# crossover to next helix, unless it's the last helixstrand_builder.cross(helix+1)strand_builder.as_scaffold()returndesignAPI DocumentationOnline documentation of the package API (which classes, methods, functions, and constants are provided by the package) is located here:https://scadnano-python-package.readthedocs.ioTutorialAtutorialshows how to create a "standard" 24-helix DNA origami rectangle using the scadnano Python package.Other examplesNote:If you are reading this on the PyPI website, the links below won't work. They are relative links intended to be read on theGitHub README page.Several example scripts are located in theexamples/subfolder.
Their output is contained in theexamples/output_designs/subfolder.ContributingIf you wish to contribute to scadnano, please see theCONTRIBUTING documentto contribute to the scadnano Python package. There is also aCONTRIBUTING documentfor the web interface.