Example #1
0
def add_scaffold_crossovers(design: sc.Design):
    crossovers = []

    # scaffold edges
    for helix in range(len(img)):
        if (1 in img[helix]):
            for dom in range(len(img[helix])):
                if (img[helix][dom] == 1) and (img[helix][dom - 1] == 0):
                    start = block * dom
                if (img[helix][dom] == 0) and (img[helix][dom - 1] == 1):
                    end = block * dom

                    crossovers.append(
                        sc.Crossover(helix=2 * helix,
                                     helix2=2 * helix + 1,
                                     offset=start,
                                     forward=True,
                                     half=True))
                    crossovers.append(
                        sc.Crossover(helix=2 * helix,
                                     helix2=2 * helix + 1,
                                     offset=end - 1,
                                     forward=True,
                                     half=True))

    design.add_crossovers(crossovers)
def add_scaffold_crossovers(design: sc.DNADesign):
    crossovers = []

    # scaffold interior
    for helix in range(1, 23, 2):
        crossovers.append(
            sc.Crossover(helix1=helix,
                         helix2=helix + 1,
                         offset1=152,
                         forward1=False))

    # scaffold edges
    for helix in range(0, 23, 2):
        crossovers.append(
            sc.Crossover(helix1=helix,
                         helix2=helix + 1,
                         offset1=8,
                         forward1=True,
                         half=True))
        crossovers.append(
            sc.Crossover(helix1=helix,
                         helix2=helix + 1,
                         offset1=295,
                         forward1=True,
                         half=True))

    design.add_crossovers(crossovers)
def add_crossovers(design: sc.Design, crossover_list, scaffold_or_staple):
    """Adds crossovers"""
    crossovers = []

    for helix in range(len(crossover_list)):
        if crossover_list[helix] == 'no crossover':
            continue
        else:
            for crossover in crossover_list[helix]:
                helix2 = crossover[1]
                offset = crossover[2]
                offset2 = crossover[3]
                forward = sc_general.forward_strand(helix, scaffold_or_staple)
                forward2 = sc_general.forward_strand(helix2, scaffold_or_staple)
                crossovers.append(sc.Crossover(helix = helix, helix2 = helix2, offset = offset, offset2 = offset2, forward = forward, forward2 = forward2, half = True))
    
    design.add_crossovers(crossovers)
Example #4
0
def add_adaptor_crossovers(design):
    """Given a adaptor design, adds the crossovers"""
    crossovers = []
    croosover_locations = [16, 36, 37]
    for helix in range(1, 12, 2):
        if helix == 11:
            helix2 = 0
        else:
            helix2 = helix + 1
        forward = sc_general.forward_strand(helix, 'staple')
        forward2 = sc_general.forward_strand(helix2, 'staple')
        for offset in croosover_locations:
            crossovers.append(
                sc.Crossover(helix=helix,
                             helix2=helix2,
                             offset=offset,
                             offset2=offset,
                             forward=forward,
                             forward2=forward2,
                             half=True))

    design.add_crossovers(crossovers)
Example #5
0
def add_crossovers(design: sc.DNADesign):
    # staples interior
    for offset in range(84, 1246, 42):
        design.add_full_crossover(helix=0,
                                  helix2=1,
                                  offset=offset,
                                  forward=False)
        design.add_full_crossover(helix=3,
                                  helix2=4,
                                  offset=offset,
                                  forward=True)
    for offset in range(56, 1246, 42):
        design.add_full_crossover(helix=1,
                                  helix2=2,
                                  offset=offset,
                                  forward=True)
        design.add_full_crossover(helix=4,
                                  helix2=5,
                                  offset=offset,
                                  forward=False)
    for offset in range(70, 1246, 42):
        design.add_full_crossover(helix=2,
                                  helix2=3,
                                  offset=offset,
                                  forward=False)
        design.add_full_crossover(helix=5,
                                  helix2=0,
                                  offset=offset,
                                  forward=True)
    for offset in range(49, 1245,
                        42):  # extra crossovers 5 - 0 for some reason
        design.add_full_crossover(helix=5,
                                  helix2=0,
                                  offset=offset,
                                  forward=True)

    # staples edges
    design.add_half_crossover(helix=0, helix2=1, offset=42, forward=False)
    design.add_half_crossover(helix=3, helix2=4, offset=42, forward=True)
    design.add_half_crossover(helix=0, helix2=5, offset=1245, forward=False)
    design.add_half_crossover(helix=2, helix2=3, offset=1245, forward=False)

    # scaffold interior
    crossovers = []
    for offset in range(58, 1250, 42):
        crossovers.append(
            sc.Crossover(helix=0, helix2=1, offset=offset, forward=True))
    for offset in range(30, 1250, 42):
        crossovers.append(
            sc.Crossover(helix=1, helix2=2, offset=offset, forward=False))
    for offset in range(54, 1250, 42):
        crossovers.append(
            sc.Crossover(helix=2, helix2=3, offset=offset, forward=True))
    for offset in range(26, 1250, 42):
        crossovers.append(
            sc.Crossover(helix=3, helix2=4, offset=offset, forward=False))

    # scaffold edges
    crossovers.append(
        sc.Crossover(helix=0, helix2=1, offset=16, forward=True, half=True))
    crossovers.append(
        sc.Crossover(helix=2, helix2=3, offset=12, forward=True, half=True))
    crossovers.append(
        sc.Crossover(helix=4, helix2=5, offset=19, forward=True, half=True))
    crossovers.append(
        sc.Crossover(helix=0, helix2=1, offset=1275, forward=True, half=True))
    crossovers.append(
        sc.Crossover(helix=2, helix2=3, offset=1271, forward=True, half=True))
    crossovers.append(
        sc.Crossover(helix=4, helix2=5, offset=1278, forward=True, half=True))

    design.add_crossovers(crossovers)
Example #6
0
def add_scaffold_nicks(design: sc.Design):
    crossovers = []

    for helix in range(3, maxhelix, 2):
        if not design.strands_starting_on_helix(helix):
            pass
        else:
            hel1 = helix  #first starting helix
            break

    for helix in range(hel1, maxhelix, 2):

        scafdom1 = design.strands_starting_on_helix(helix)
        scafdom2 = design.strands_starting_on_helix(helix + 1)
        if not (scafdom1
                and scafdom2):  #check for empty helix at the end of the design
            break

        imghelix = int((helix - 1) / 2)
        if (1 in img[imghelix]) and (1 in img[imghelix + 1]):
            interstarts = []
            interends = []
            for dom in range(1, len(img[imghelix])):
                if (bool(img[imghelix][dom] and img[imghelix+1][dom])) and \
                   (not bool(img[imghelix][dom-1] and img[imghelix+1][dom-1])):
                    interstarts.append(dom)
                if (not bool(img[imghelix][dom] and img[imghelix+1][dom])) and \
                   (bool(img[imghelix][dom-1] and img[imghelix+1][dom-1])):
                    interends.append(dom)

            interstarts = [x * block for x in interstarts]
            interends = [x * block for x in interends]

        for i in range(len(interstarts)):

            #finds the scaffold crossover offset position 'nickoff', for the square lattice,
            #closest to the center of the intersection of helices that are crossing over
            closestoff = int((interstarts[i] + interends[i]) / 2) - 2
            closerem = (closestoff) % 32

            if (closerem < 10):
                nickoff = 3 + 32 * int(closestoff / 32)
                if nickoff <= interstarts[i]:
                    nickoff = 3 + 32 * int(closestoff / 32) + 10
                elif nickoff >= interends[i]:
                    nickoff = 3 + 32 * int(closestoff / 32) - 11
            elif (closerem > 10) and (closerem < 21):
                nickoff = 3 + 32 * int(closestoff / 32) + 10
                if nickoff <= interstarts[i]:
                    nickoff = 3 + 32 * int(closestoff / 32) + 21
                elif nickoff >= interends[i]:
                    nickoff = 3 + 32 * int(closestoff / 32)
            elif (closerem > 21) and (closerem < 32):
                nickoff = 3 + 32 * int(closestoff / 32) + 21
                if nickoff <= interstarts[i]:
                    nickoff = 3 + 32 * int(closestoff / 32) + 32
                elif nickoff >= interends[i]:
                    nickoff = 3 + 32 * int(closestoff / 32) + 10
            else:
                nickoff = 3 + 32 * int(closestoff / 32) + closerem

            design.add_nick(helix=helix,
                            offset=nickoff,
                            forward=helix % 2 == 0)

            design.add_nick(helix=helix + 1,
                            offset=nickoff,
                            forward=helix % 2 == 1)
            crossovers.append(
                sc.Crossover(helix=helix,
                             helix2=helix + 1,
                             offset=nickoff,
                             forward=False))

    design.add_nick(helix=helix, offset=nickoff, forward=helix % 2 == 0)
    design.add_crossovers(crossovers)
Example #7
0
def add_staple_nicks(design: sc.Design):

    crossovers = []

    for helix in range(3, maxhelix, 2):
        if not design.strands_starting_on_helix(helix):
            pass
        else:
            hel1 = helix  #first starting helix
            break

    for helix in range(hel1, maxhelix, 2):

        scafdom1 = design.strands_starting_on_helix(helix)
        scafdom2 = design.strands_starting_on_helix(helix + 1)
        if not (scafdom1
                and scafdom2):  #check for empty helix at the end of the design
            break

    for helix in range(maxhelix):
        if helix % 2 == 0:
            for offset in range(block * cmax):
                if (offset % 32 == 0) and (design.domains_at(helix, offset)):
                    if domain_end(design, helix,
                                  offset):  #no nick if domain end
                        continue
                    #Prevent very short staples
                    if (design.domains_at(helix, offset-16)) and \
                       (design.domains_at(helix, offset+16)):
                        design.add_nick(helix=helix,
                                        offset=offset,
                                        forward=helix % 2 == 1)
                    if 0<=(offset-8)<=block*cmax and \
                       (design.domains_at(helix, offset-16)) and \
                       (design.domains_at(helix, offset)) and \
                       (design.domains_at(helix+1, offset-8)) and \
                       (design.domains_at(helix+1, offset-9)) and \
                       not domain_end(design, helix, offset-8):
                        crossovers.append(sc.Crossover(helix=helix, helix2=helix + 1, \
                                                   offset=offset-8, forward=helix % 2 == 1))

        else:
            for offset in range(block * cmax):
                if ((offset + 16) % 32 == 0) and (design.domains_at(
                        helix, offset)):
                    if domain_end(design, helix, offset):
                        continue
                    #Prevent very short staples
                    if (design.domains_at(helix, offset-16)) and \
                       (design.domains_at(helix, offset+16)):
                        design.add_nick(helix=helix,
                                        offset=offset,
                                        forward=helix % 2 == 1)
                    if 0<=(offset-8)<=block*cmax and \
                       (design.domains_at(helix, offset-16)) and \
                       (design.domains_at(helix, offset)) and \
                       (design.domains_at(helix+1, offset-8)) and \
                       (design.domains_at(helix+1, offset-9)) and \
                       not domain_end(design, helix, offset-8):

                        crossovers.append(sc.Crossover(helix=helix, helix2=helix + 1, \
                                                   offset=offset-8, forward=helix % 2 == 1))

    design.add_crossovers(crossovers)
Example #8
0
def add_staple_nicks(design: sc.Design):

    crossovers = []
    midgap = 3
    state = 0
    every = -1  #skip every xth crossover

    for helix in range(3, maxhelix, 2):
        if not design.strands_starting_on_helix(helix):
            pass
        else:
            hel1 = helix  #first starting helix
            break

    for helix in range(hel1, maxhelix, 2):

        scafdom1 = design.strands_starting_on_helix(helix)
        scafdom2 = design.strands_starting_on_helix(helix + 1)
        if not (scafdom1
                and scafdom2):  #check for empty helix at the end of the design
            break

    for helix in range(maxhelix):

        if helix % 2 == 0:
            for offset in range(block * cmax):


                if (((offset-3)%32==0) or \
                      ((offset-3)%32==10) or \
                      ((offset-3)%32==21)) and \
                      (design.domains_at(helix, offset+midgap)):

                    state = state + 1
                    if not every == -1:
                        if state % every == 0:
                            # print(str(helix)+' '+str(offset))
                            continue
                    if domain_end(design, helix,
                                  offset + midgap):  #no nick if domain end
                        continue
                    #Prevent very short staples
                    if long_stap_cond(design, helix, offset + midgap) == True:
                        design.add_nick(helix=helix,
                                        offset=offset + midgap,
                                        forward=helix % 2 == 1)
                    if cross_conds(design, helix, offset):
                        crossovers.append(sc.Crossover(helix=helix, helix2=helix + 1, \
                                                    offset=offset, forward=helix % 2 == 1))
                    elif helix == 2:
                        print("not here " + str(offset))

        else:
            for offset in range(block * cmax):

                if (((offset-8)%32==0) or \
                      ((offset-8)%32==11) or \
                      ((offset-8)%32==21)) and \
                      (design.domains_at(helix, offset+midgap)):

                    state = state + 1
                    if not every == -1:
                        if state % every == 0:
                            # print(str(helix)+' '+str(offset))
                            continue
                    if domain_end(design, helix,
                                  offset + midgap):  #no nick if domain end
                        continue
                    # #Prevent very short staples
                    # if long_stap_cond(design, helix, offset+midgap)==True:
                    #     design.add_nick(helix=helix, offset=offset+midgap, forward=helix % 2 == 1)

                    if cross_conds(design, helix, offset):
                        crossovers.append(sc.Crossover(helix=helix, helix2=helix + 1, \
                                                    offset=offset, forward=helix % 2 == 1))

    design.add_crossovers(crossovers)
Example #9
0
def add_hairpins(design, hairpin_locations, hairpin_lattice):
    """Given the design, the hairpin lattice, and the hairpin locations, adds the hairpins to the hairpin lattice and crossovers to the seed"""
    seed_domain = range(len(hairpin_locations))
    hairpin_domain = range(len(hairpin_locations),
                           len(hairpin_locations) + len(hairpin_lattice))
    #creates the hairpins, included the loopout crossover
    for i in range(len(hairpin_domain)):
        helix = hairpin_domain[i]
        for j in range(len(hairpin_locations[helix - len(seed_domain)])):
            left_offset = hairpin_locations[helix - len(seed_domain)][j]
            right_offset = left_offset + 8
            index = 6 * (i - 1) + j
            pin_seq = non_random_hairpin_sequence(index)
            staple = sc.Strand([
                sc.Domain(helix=helix,
                          forward=True,
                          start=left_offset,
                          end=right_offset),
                sc.Loopout(length=4),
                sc.Domain(helix=helix,
                          forward=False,
                          start=left_offset - 2,
                          end=right_offset)
            ],
                               dna_sequence=pin_seq)
            design.add_strand(staple)

    #add nicks on staple strands to be able to connect the hairpins
    for helix in seed_domain:
        forward = sc_general.forward_strand(helix, 'staple')
        for nick in hairpin_locations[helix]:
            design.add_nick(helix=helix, offset=nick, forward=forward)

    #crossovers between the main helices and the hairpins
    crossovers = []
    for helix in seed_domain:
        helix2 = hairpin_domain[helix]
        forward = sc_general.forward_strand(helix, 'staple')
        for pin in hairpin_locations[helix]:
            if forward == True:
                forward_pin_offset = pin - 1
                reverse_pin_offset = pin
            else:
                forward_pin_offset = pin
                reverse_pin_offset = pin - 1
            crossovers.append(
                sc.Crossover(helix=helix,
                             helix2=helix2,
                             offset=forward_pin_offset,
                             offset2=pin,
                             forward=forward,
                             forward2=True,
                             half=True))
            crossovers.append(
                sc.Crossover(helix=helix,
                             helix2=helix2,
                             offset=reverse_pin_offset,
                             offset2=pin - 2,
                             forward=forward,
                             forward2=False,
                             half=True))

    design.add_crossovers(crossovers)