NanoBricks provides several tools for automating repetitive tasks:
In each case, you enter some CoffeeScript code into a textbox; that code will be decorated by NanoBricks with some extra variable definitions, then compiled and executed. Your code should return a function, which will be executed once for each
Allows you to add or remove voxels according to a function; the function is passed X, Y, and Z positions on the lattice and must return true or false. There are 3 modes:
Examples:
5x7x5 cuboid, centered at 10, 10, 10:
cuboid(5, 5, 5, 10, 10, 10)
# you could pass true as the last argument to make a hollow cuboid
Stripes in the Z direction with periodicity 4 and height 7:
(x, y, z) ->
y < 7 and (x % 4) is 0
PowerEdit (or Select/Transform) lets you choose voxels (or strands) according to an arbitrary function, then modify those objects according to another function.
Examples:
Color all voxels on one side of the canvas purple:
Select:
(x,y,z,voxel) -> x > lattice.width / 2
Transform:
(x,y,z,voxel) -> voxel.set 'color', 'purple'
Displace all voxels by +5 voxels in the X directions
Select:
(x,y,z,voxel) -> yes
Transform:
(x,y,z,voxel) -> voxel.move +5, 0, 0
Extend the 3' end of all Y strands with a specific sequence (e.g. for a PAINT docking site):
Select:
(strand) -> strand.get('plane') is 'Y'
Transform:
(strand) ->
strand.extend 'ATTACAGACT'
# note that
# strand.extend 'ATTACAGACT', -1
# would extend the 3' end
Add a 10 nt loop at position 5 on a specific strand
Select:
(strand) ->
eq strand.get5p(), [5, 10, 4, 3]
# `eq` is a NanoBricks built-in function which lets you compare arrays element-wise
# get5p() returns a 4-element array giving the
# [X helix position, Y helix position, Z (voxel) position, base #]
# for a particular strand.
Transform:
(strand) -> strand.insert 10, 5
For convenience, NanoBricks introduces a number of functions into the local namespace within scripting environments. Add functions from the following classes are available as local variables (e.g. instead of vox.shapes.cuboid, you can just write cuboid):
vox.lit: Convenience functions for doing elementwise operations on arraysvox.shapes: Functions for generating shapesvox.compilers.utils: has, enclosedNanoBricks also defines some variables for you:
lattice: Reference to the current Lattice; you can use this to get the shape of the current latticestrands: Reference to the current Strand controller; you can use this to add, remove, and modify strandsvoxels: Reference ot the current Voxel controller; you can use this to add, remove, and modify voxelsIn addition, you may have access to one or more of these:
strand: Reference to the current strand; you can access properties of the strand set by the translation scheme (plane, align, etc.), determine the 5' (get5p()) or 3' (get3p) end of the strand, make modifications (extend, insert, truncate, delete), and change properties of the strand (e.g. color).voxel: Reference to the current voxel; you can get the voxel's position (position), move the voxel (move, moveTo), and change the voxel's color.