Esempio n. 1
0
def add_scaffold_nicks(design: sc.Design, seam_locations):
    """Adds nicks to the precursor scaffold"""
    for helix in range(len(seam_locations)):
        if seam_locations[helix] == 'no seam':
            continue
        else:
            nick_offsets = seam_locations[helix]
            for nick_offset in nick_offsets:
                if nick_offset != 'no seam':
                    forward = sc_general.forward_strand(helix, 'scaffold')
                    design.add_nick(helix = helix, offset = nick_offset, forward = forward)
def add_nicks(design: sc.Design) -> None:
    design.add_nick(helix=5, offset=399, forward=False)  # scaffold
    for offset in range(56, 1246, 42):
        design.add_nick(helix=0, offset=offset, forward=False)
        design.add_nick(helix=3, offset=offset, forward=True)
    for offset in range(70, 1246, 42):
        design.add_nick(helix=1, offset=offset, forward=True)
        design.add_nick(helix=4, offset=offset, forward=False)
    for offset in range(84, 1246, 42):
        design.add_nick(helix=2, offset=offset, forward=False)
        design.add_nick(helix=5, offset=offset, forward=True)
Esempio n. 3
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)
Esempio n. 4
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)
def add_scaffold_nicks(design: sc.Design):
    for helix in range(1, 24):
        design.add_nick(helix=helix, offset=152, forward=helix % 2 == 0)
def add_staple_nicks(design: sc.Design):
    for helix in range(24):
        start_offset = 32 if helix % 2 == 0 else 48
        for offset in range(start_offset, 280, 32):
            design.add_nick(helix, offset, forward=helix % 2 == 1)
def add_staple_nicks(design: sc.Design) -> None:
    for helix in range(24):
        start_offset = 24 if helix % 2 == 0 else 40
        for offset in range(start_offset, 272, 32):
            design.add_nick(helix, offset, forward=helix % 2 == 1)
Esempio n. 8
0
def add_staple_nicks(design: sc.Design, nick_locations):
    """Adds nicks ot the precursor staple strands"""
    for helix in range(len(nick_locations)):
        forward = sc_general.forward_strand(helix, 'staple')
        for nick in nick_locations[helix]:
            design.add_nick(helix = helix, offset = nick, forward = forward)
Esempio n. 9
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)