Skip to content

allow chained commands for less verbose way to add Strands to DNADesign #85

@dave-doty

Description

@dave-doty

codenano allows "chained commands" for a less verbose way to create strands. For example see here: https://docs.rs/codenano/0.5.1/codenano/

design.strand(0, 0).to(31)
    .cross(1).to(10)
    .cross(2).to(21);
// Now its reverse complement:
design.strand(2, 21).to(10)
   .cross(1).to(31)
   .cross(0).to(0);

This is equivalent to the more verbose Python code:

domain_11 = sc.Domain(0, True, 0, 31)
domain_12 = sc.Domain(1, False, 10, 31)
domain_13 = sc.Domain(2, True, 10, 21)
strand1 = sc.Strand([domain_11, domain_12, domain_13])
domain_21 = sc.Domain(2, False, 10, 21)
domain_22 = sc.Domain(1, True, 10, 31)
domain_23 = sc.Domain(0, False, 0, 31)
strand1 = sc.Strand([domain_11, domain_12, domain_13])

or the slightly less verbose

strand1 = sc.Strand([
    sc.Domain(0, True, 0, 31),
    sc.Domain(1, False, 10, 31),
    sc.Domain(2, True, 10, 21),
])
strand1 = sc.Strand([
    sc.Domain(2, False, 10, 21),
    sc.Domain(1, True, 10, 31),
    sc.Domain(0, False, 0, 31),
])

Note that this requires crossovers to be "vertical", i.e., they have the same offset on the from Helix and the to Helix. Perhaps that can be overridden with an optional second parameter to cross. But since the most common crossover is vertical, the less verbose method is superior, since it reduces the amount of redundant information that needs to be specified.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthigh prioritySomething cruicial to get working soon.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions