Skip to main content

dsdobjects: an object library for DSD programming

GitHub tag (latest by date) GitHub release (latest by date including pre-releases) PyPI version PyPI - License Build Status Codecov branch

A library of base classes for domain-level strand displacement (DSD) programming. If you are starting a new project that requires domains, complexes, secondary structures, nucleotide sequences, reactions, etc. then you might find this module useful. Note that this is the in-house library of the nuskell compiler framework; it handels the parsing of supported input file formats (mainly *.PIL) and their translation into the respective DSD objects.

All objects provided here are singletons. In other words, once you intialize a Domain d1 = DomainS(name = 'a', length = 15), you will not be allowed to initialize a new domain with the same name but different length, unless you delete (all references to) the variable d1 first. If you try to initialize the same domain a second time, then the new object is d1. Generally, each (DomainS, ComplexS, MacrostateS, ReactionS) must be initialized with parameters that define their canonical form and (optionally) a name. If both are given, the library checks that there are no conflicts with existing objects, if the name is not provided, the library tries to initialize a new object with an automatic name, but raises a SingletonError which holds a reference to the existing object. If only the name is given, the existing object is returned.

This library is expected to evolve further, potentially breaking backward compatibility as new challenges are waiting in the nuskell compiler framework. Don't hesitate to contact the authors with questions about future plans. Inheritance from the provided objects is fully supported and encouraged.

Installation

To install this library use pip:

$ pip install dsdobjects

or the following command in the root directory:

$ python ./setup.py install

Quick Start

from dsdobjects import DomainS, ComplexS

# Define a few toy domains:
a = DomainS('a', length = 15)
b = DomainS('b', length = 9)
c = DomainS('c', length = 6)

# DomainS objects have exactly one complement, it can be initialized 
# and/or accessed using the __invert__ operator. The singleton type
# ensures that there is only one object for each domain.
assert (a is ~(~a))

# Use the Domains to define a Complex ...
foo = ComplexS([a, b, c, ~b, '+', ~a], list('((.)+)'), name = 'foo')

# ... and test some of the built-in complex properties:
foo.kernel_string
foo.canonical_form
foo.size
foo.pair_table
for (se, ss) in foo.rotate():
    print(se, ss)

# If you initialize a disconnected complex ... 
bar = ComplexS([a, b, c, ~b, '+', ~a], list('.(.)+.'), name = 'bar')
assert bar.is_connected is False
# ... use split to get all indiviudal complexes:
cx1, cx2 = bar.split()

Quick Start from PIL files

Initialize prototype objects by loading a system (or a single line) of *.PIL file format:

from dsdobjects import DomainS
from dsdobjects.objectio import set_io_objects, clear_io_objects, read_pil, read_pil_line

# Use the builtin singleton obects form the dsdobjects library.
set_io_objects()

# The following dictionary contains references to all objects.
outdict = read_pil('filename', is_file = True)

# The following let's you quickly initialize single objects.
d5 = read_pil_line("length d5 = 7")
assert isinstance(d5, DomainS)

d6 = read_pil_line("sequence d6 = NNNNN")
assert isinstance(d6, DomainS)
assert d6.sequence == 'NNNNN'

Version

0.8 -- requires Python<=3.7

  • complete rewrite of the library to use singleton objects with weakref

Author

Stefan Badelt

Contributors

This library contains adapted code from various related Python packages coded in the DNA and Natural Algorithms Group, Caltech:

  • "DNAObjects" coded by Joseph Berleant and Joseph Schaeffer
  • peppercornenumerator coded by Kathrik Sarma, Casey Grun and Erik Winfree
  • nuskell coded by Seung Woo Shin

Projects depending on dsdobjects

License

MIT

Metadata

Release files for dsdobjects 0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsdobjects 0.8
File Size Uploaded
dsdobjects-0.8.tar.gz 39.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dsdobjects 0.8
File Interpreter ABI Platform
dsdobjects-0.8-py3-none-any.whl Python 3 none any Details

Total release size: 85.9 kB

Release files / dsdobjects-0.8.tar.gz

Download URL dsdobjects-0.8.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
258f729d01d24693e9093cd720577dfc77e0af084558f18c97e5b6400934c9ce
BLAKE2b-256 checksum
How to use checksums
eb2d0711dc3ae6a49d5a71a7e46c6627ac9782f348767aceeaf775ca87c53432
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / dsdobjects-0.8-py3-none-any.whl

Download URL dsdobjects-0.8-py3-none-any.whl
Size 46.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e1f66ec536a800116faac6e02d35359aefae70f61f9a9b53444d29dde40b32a
BLAKE2b-256 checksum
How to use checksums
6c7729cf6ec69d72edef08083e4242d8e2e12bafdfcacebe22780c6825187c8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.8 This release

2 release files

0.7.1

2 release files

0.7

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

3 release files

0.6

2 release files

0.5.2

2 release files

0.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page