Ejemplo n.º 1
0
def timeprogression(time, numsteps):
    stepsize = round(time / numsteps, 2)
    for i in range(1, numsteps + 1):
        pause(stepsize)
        print(" " + str(round(i * stepsize * 100 / time)) +
              "% of time has elapsed (" + str(round(i * stepsize / 60, 1)) +
              " min)")
Ejemplo n.º 2
0
def autoshutoffkymo(): #both force and photon counts
    greenphoton = timeline["Photon count"]["Green"]
    confocal.start_scan("RPA Kymo")
    
    f1=trap2.current_force
    print("initial force: " + str(round(f1,2)))

    n=0; photonbin=20
    while 1:
        pause(1/78125)
        n+=1
        photonbin += greenphoton.latest_value
        if n%(3000) == 0:
            f2 = trap2.current_force
            print("periodic check #"+str(round(n/3000)))
            print("  photon count: " + str(photonbin))
            print("  force: " + str(round(f2,2)))
            if (photonbin < greencutoff) or (f2 < 0.5*f1):
                pause(7)
                break
            else: 
                photonbin=0
    confocal.abort_scan()
    excitation_lasers.green = 0
    print("!!!!!!!!! IT'S DONE !!!!!!!!!")
Ejemplo n.º 3
0
def pingpong(distance_delta_um, period_ms, speed):
    while True:
        trap1.move_by(dx=+distance_delta_um, speed=speed)
        pause(period_ms / 1000 / 2)
        log("ping")
        trap1.move_by(dx=-distance_delta_um, speed=speed)
        pause(period_ms / 1000 / 2)
        log("pong")
Ejemplo n.º 4
0
def pressurecycle():
    while fluidics.pressure < .6:
        fluidics.increase_pressure()
        pause(pt)  #important!
    while fluidics.pressure > 0.22:
        fluidics.decrease_pressure()
        pause(pt)  #important!
    print("pressure cycled")
def setpressure(pres):
    curpres = fluidics.pressure
    if curpres < pres:
        while fluidics.pressure < pres:
            fluidics.increase_pressure()
            pause(0.1)  #important!
    else:
        while fluidics.pressure > pres:
            fluidics.decrease_pressure()
            pause(0.1)  #important!
Ejemplo n.º 6
0
def pingpong(distance_delta_um, period_ms, speed):
    """This will pingpong infinitely and must be stopped using the `Stop` button in the UI"""
    while True:
        trap1.move_by(dx=+distance_delta_um, speed=speed)
        pause(period_ms / 1000 /
              2)  # pause time is given in seconds, convert from milliseconds
        print("ping")
        # reset_force() # optionally reset the force
        trap1.move_by(dx=-distance_delta_um, speed=speed)
        pause(period_ms / 1000 / 2)
        print("pong")
Ejemplo n.º 7
0
def gogetprotein(hangouttime,flowon,initforce):
    print("getting protein for " + str(hangouttime) + " sec")
    trap = Trap("1", "XY")
    trap.move_to(waypoint="measure point",speed=4)
    stage.move_to("J1")
    stage.move_to("Ch1")
    setpressure(0.12)
    if flowon:
        fluidics.open(1,2,3,4,6)
    pause(hangouttime)
    
    fluidics.close(1,2,3,4,6)
    stage.move_to("J1")
    stage.move_to("buffer")
def bead_DNA_complex_setup():
    fluidics.open(1, 2, 3, 6)
    fluidics.close(4, 5)
    pause(5)  # wait for flow to start
    stage.move_to("beads")
    print("Moved to Beads channel")
    catch_beads(80)
    print("Beads are trapped")
    # stage.move_to("DNA")
    # print("Moved to DNA channel")
    # pause(5) ## DEFINITELY have to play with this based on DNA concentration/flow rate
    # print('till here')
    stage.move_to("buffer")
    print("Moved to Buffer channel")
Ejemplo n.º 9
0
def stretchitout(stretchtime):
    print("pre stretch time: "+ str(stretchtime) + " sec")
    f1=trap2.current_force
    print(" initial force: " + str(round(f1,2)))
    trap = Trap("1", "XY")
    trap.move_to(waypoint="more streatch",speed=4)
    pause(stretchtime)
    trap.move_to(waypoint="measure point",speed=4)
    pause(2)
    f2=trap2.current_force
    print(" final force: " + str(round(f2,2)))
    if f2<(0.5*f1) and f1 > 1:
        print("it broke")
        return 0
    return 1
Ejemplo n.º 10
0
def false_positive():  #1 if it was ok, 0 if false positive
    fluidics.close(1, 2, 3, 4, 5, 6)
    gohome()
    pause(0.8)
    reset_force()
    trap.move_by(dx=5, speed=6)
    f1 = trap2.current_force
    trap.move_by(dx=5.5, speed=6)
    f2 = trap2.current_force
    trap.move_by(dx=-10.5, speed=6)
    print("  -FP" + str(round(f1, 2)) + " to " + str(round(f2, 2)))
    if f2 > (4 * f1):
        return 1
    else:
        return 0
def catch_beads(min_score=30):
    target_traps = traps[:2]

    # option 2
    target_traps[1].clear()
    target_traps[0].clear()
    bead1 = timeline['Tracking Match Score']['Bead 1']
    bead2 = timeline['Tracking Match Score']['Bead 2']
    bead_scores = [bead1, bead2]
    while any(bead.latest_value < min_score for bead in bead_scores):
        if any(0 < bead.latest_value < min_score for bead in bead_scores):
            for trap in target_traps:
                trap.clear()  # bad beads
                print('bad beads')
            pause(1)
Ejemplo n.º 12
0
def catch_beads(min_score=30):  #from Zsombor
    stage.move_to("beads")
    target_traps = traps[:2]

    target_traps[1].clear()
    target_traps[0].clear()
    bead1 = timeline['Tracking Match Score']['Bead 1']
    bead2 = timeline['Tracking Match Score']['Bead 2']
    bead_scores = [bead1, bead2]

    while any(bead.latest_value < min_score for bead in bead_scores):
        if any(0 < bead.latest_value < min_score for bead in bead_scores):
            for trap in target_traps:
                trap.clear()  # bad beads
                print('bad beads')
            pause(1)
    print("beads should be caught")
Ejemplo n.º 13
0
def fish_for_dna(min_distance_um, max_distance_um, force_threshold_pN):
    """Oscillate between min and max distance while the force is under the threshold value"""
    stage.move_to("DNA")
    goto_distance(min_distance_um)
    fluidics.open(1, 2, 3, 6)
    pause(1)

    reset_force()
    goto_distance(max_distance_um)
    while trap2.current_force < force_threshold_pN:
        goto_distance(min_distance_um)
        reset_force()
        goto_distance(max_distance_um)

    fluidics.close(1, 2, 3, 6)
    stage.move_to("buffer")
    goto_distance(min_distance_um)
    reset_force()
def goto_distance(target_distance, move_speed=8, force_limit=10000):
    trap1, trap2 = traps[:2]
    distance = timeline["Distance"]["Distance 1"]
    dx = distance.latest_value - target_distance

    while abs(dx) > 0.2:
        if trap2.current_force > force_limit:
            break

        if dx <= 0:
            trap1.move_by(dx=+abs(dx) * 0.8,
                          speed=move_speed)  # MAYBE play around with this
        else:
            trap1.move_by(dx=-abs(dx) * 0.8, speed=move_speed)
        dx = distance.latest_value - target_distance
        # print(dx)
    # print("till here")
    pause(1)
Ejemplo n.º 15
0
def themainloop(
):  #will return 1 if caught, 0 if attempted 60 times and failed
    #check for beads first
    bt = beadtest()
    fluidics.close(1, 2, 3, 4, 5, 6)
    if bt == 0:
        setpressure(0.3)
        fluidics.open(1, 2, 3, 6)
        stage.move_to("beads")
        catch_beads(86)
    else:
        #turn on fluidics
        fluidics.open(1, 2, 3, 6)

    # set up the pressure
    stage.move_to("buffer")
    setpressure(0.4)

    #set traps at initial position and reset force
    gohome()
    reset_force()
    print("initialized position")
    caught = pingpongforce2()
    attempts = 1

    #moving into dna channel and starting pingpong
    while caught != 1:
        print(" we've attempted " + str(attempts) + " times")
        #print("    new force ="+str(round(pforce,2)))
        stage.move_to("DNA")
        pause(dnadwell)
        stage.move_to("buffer")
        pause(dnadwell)
        caught = pingpongforce2()
        if attempts == 15:
            return 0
        if (attempts % 10) == 0:
            pressurecycle()
            attempts += 1
        else:
            attempts += 1

    print("hopefully we finished")
    return 1
Ejemplo n.º 16
0
def catch_2_beads():
    "Just like `abc2.py`"
    target_traps = [trap1, trap2]
    match_scores = [match_score1, match_score2]

    for trap in target_traps:
        trap.clear()  # to get rid of any existing beads

    stage.move_to("beads")  # must match the label in the UI
    fluidics.open(1, 2, 3, 6)  # list of valves to open matching the UI

    match_threshold = 80  # % minimal match score
    while any(m.latest_value < match_threshold for m in match_scores):
        if any(0 < m.latest_value < match_threshold for m in match_scores):
            for trap in target_traps:
                trap.clear()  # bad beads
            pause(1)

    stage.move_to("buffer")
    fluidics.close(1, 2, 3, 6)
def is_single_tether(max_force=70, min_force=30, backward_speed=1):
    # min_forcce depemds on the rate of flow, especially when you have flow
    # make sure that you don't have bubbles inside the system
    trap1, trap2 = traps[:2]
    distance = timeline["Distance"]["Distance 1"]
    goto_distance(10)
    print("traps are 10 um apart")
    trap1.move_by(dx=-3, speed=backward_speed)  # MAYBE play with this
    reset_force()
    pause(0.5)  # MAYBE play with this
    baseline_force = trap1.current_force
    # print('baseline force')
    # print(baseline_force)
    trap1.move_by(dx=3, speed=5)  # MAYBE play with this
    force_list = []
    ii = 0
    # while distance.latest_value < 26: # MAYBE play with this, not sure how long you can stretch DNA
    while ii < 38:  # MAYBE play with this, not sure how long you can stretch DNA
        ii += 1
        trap1.move_by(dx=0.5, speed=5)
        # print('trap1 force')
        # print(trap1.current_force)
        current_force = abs(baseline_force - trap1.current_force)
        # print(current_force)
        force_list.append(current_force)
        if current_force > max_force:
            print("Multiple tethers found")
            return 2
        # elif distance.latest_value > 16:
        elif ii > 18:
            if current_force > min_force:
                # print('stdev of past 10 forces')
                # print(std(force_list[-10:]))
                if std(force_list[-10:]) < 2:
                    print("Single tether potentially found")
                    trap1.move_by(dx=-16, speed=5)
                    return 1
    print("No tethers found")
    trap1.move_by(dx=-16, speed=5)
    return 0
Ejemplo n.º 18
0
def ssDNAstretch():  #0 if nothing/broke, 1 if good, 2 if unsuccessful pull
    success = 0
    trap.move_to(waypoint="stretched", speed=6)
    trap.move_by(dx=12, speed=1)
    pause(0.5)
    highforce = trap2.current_force
    trap.move_by(dx=-12, speed=1)
    lowforce = trap2.current_force
    print("  -ssDNA: " + str(round(lowforce, 2)) + " to " +
          str(round(highforce, 2)))
    if highforce > 50:
        print("  extension ok")
        success = 1
        if lowforce > 20:
            print("  looks like its still dsDNA")
            success = 2
    if success == 0:
        print("  ssDNA broke ;-;")
        fluidics.open(1, 2, 3, 6)
    if success == 1:
        print("  ssDNA done !!!!")
    return success
Ejemplo n.º 19
0
   cNo..lKKKKKKKo'';llll;;okKKKl..oNc             
   cNo..lKKKKKKKko;':c:,'lKKKKKo'.oNc             
   cNo..lKKKKKKKKKl.....'dKKKKKxc,l0:             
   .c:'.lKKKKKKKKKk;....lKKKKKKo'.oNc             
     ,:.'oxOKKKKKKKOxxxxOKKKKKKxc,;ol:.           
     ;c..'':oookKKKKKKKKKKKKKKKKKk:.'clc.         
   ,xl'.,oxo;'';oxOKKKKKKKKKKKKKKKOxxl:::;,.      
  .dOc..lKKKkoooookKKKKKKKKKKKKKKKKKKKxl,;ol.     
  cx,';okKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKl..;lc.   
  co..:dddddddddddddddddddddddddddddddddl::',::.  
  co...........................................  """
    print(parrot)



#%% MAIN ========================================
excitation_lasers.green = 0
goodstretch = stretchitout(25)
#goodstretch=1
if goodstretch:
    f1=trap2.current_force
    gogetprotein(10,1,f1) #sec to hang out, 1=flow on, initial force
    pause(1)
    f2 = trap2.current_force
    if f2 > 0.5*f1 or f1 < 2:
        excitation_lasers.green=40
        pause(2)
        autoshutoffkymo()
        parrot()
    else:
        print("something is wrong!!")
Ejemplo n.º 20
0
from bluelake import fluidics, pause

# Open specific valves
fluidics.open(1, 2, 3, 6)
# or
fluidics.open(1, 2)

# And close valves
fluidics.close(1, 2)

# Read the current pressure value
print(fluidics.pressure)

# Pressure control does the same thing as the UI (not really ideal)
fluidics.increase_pressure()
fluidics.decrease_pressure()

while fluidics.pressure < 1:  # bar
    fluidics.increase_pressure()
    pause(1)  # seconds to pause -- important because pressure changes are slow
Ejemplo n.º 21
0
trap = Trap("1", "XY")
pt = 0.1
spd = 35


#functions that may be helpful
def setpressure(pres):
    curpres = fluidics.pressure
    if curpres < pres:
        while fluidics.pressure < pres:
            fluidics.increase_pressure()
            pause(pt)  #important!
    else:
        while fluidics.pressure > pres:
            fluidics.decrease_pressure()
            pause(pt)  #important!


# MAIN-----------------------------------------------------------
print("moving to ch1")
stage.move_to("J1", speed=spd)
stage.move_to("Ch1", speed=spd)

print("waiting...")
pause(10)
print("done waiting, time to move")

stage.move_to("J1", speed=spd)
stage.move_to("buffer", speed=spd)
print("done moving, start imaging!")
Ejemplo n.º 22
0
reset_force()
print("initialized position")

#initialize variables
pforce_old = pingpongforce()
pforce = pforce_old
caught = 0
attempts = 1
print("initialized variables (old=" + str(round(pforce_old, 2)) + ")")

#moving into dna channel and starting pingpong
while caught != 1:
    print(" we've attempted " + str(attempts) + " times")
    #print("    new force ="+str(round(pforce,2)))
    stage.move_to("DNA")
    pause(dnadwell)
    stage.move_to("buffer")
    pforce = pingpongforce()
    print("    new force =" + str(round(pforce, 2)))
    if (pforce_old * 0.77) > pforce or pforce > (pforce_old * 1.23):
        caught = 1
    else:
        pforce_old = pforce
        if (attempts % 15) == 0:
            pressurecycle()
        attempts += 1

print("hopefully we finished")

#hopefully caught something, move to buffer channel and reset all
stage.move_to("buffer")
Ejemplo n.º 23
0
"""Automated bead catching of 1 bead"""
from bluelake import stage, fluidics, pause, trap1, timeline

match_score = timeline["Tracking Match Score"]["Bead 1"]

trap1.clear()  # to get rid of any existing bead
stage.move_to("beads")  # must match the label in the UI
fluidics.open(1, 2, 3, 6)  # list of valves to open matching the UI

match_threshold = 80  # % minimal match score
while match_score.latest_value < match_threshold:
    # We only want to clear the trap if there's a bead there, so > 0% match
    if 0 < match_score.latest_value < match_threshold:
        print("Rejected bead with match score:", match_score.latest_value)
        trap1.clear()  # bad bead, BAD bead
    pause(0.5)  # seconds

stage.move_to("buffer")
fluidics.close(1, 2, 3, 6)
Ejemplo n.º 24
0
def wait_for_scan():
    """Wait for the last confocal scan to finish"""
    pause(1)
    while confocal.is_scanning:
        pause(1)
Ejemplo n.º 25
0
reset_force()
print("initialized position")

#initialize variables
pforce_old=pingpongforce()
pforce=pforce_old
caught=0
attempts=1
print("initialized variables ("+str(round(pforce_old,2)))

#moving into dna channel and starting pingpong
while caught!=1:
    print(" we've attempted "+str(attempts)+" times")
    print("    old force ="+str(round(pforce_old,2)))
    stage.move_to("DNA")
    pause(0.5)
    stage.move_to("buffer")
    pforce=pingpongforce()
    #print("    new force ="+str(round(pforce)))
    if (pforce_old*0.8)>pforce or pforce>(pforce_old*1.2):
          caught=1
    else:
          pforce_old=pforce
          attempts+=1
    if (attempts%15)==0:
        pressurecycle()

print("hopefully we finished")

#hopefully caught something, move to buffer channel and reset all
stage.move_to("buffer")
Ejemplo n.º 26
0
"""Smooth high-frequency trap oscillation

See docs at https://help.lumicks.com/bluelake-api/api.html#bluelake.Trap.start_oscillation
"""
from bluelake import trap1, pause

# Start a 10 Hz oscillation, with amplitude 1 um
trap1.start_oscillation(axis="x", frequency=10, amplitude=1)

# Let it run for 5 seconds, then stop
pause(5.0)
trap1.stop()
Ejemplo n.º 27
0
from bluelake import Trap, stage, fluidics, pause, power, timeline, reset_force, confocal

reset_force()
timeline.mark_begin("FD1")

while Distancebeads.latest_value < 25:
    trap1.move_by(dx=3, speed=8)
    confocal.start_scan()  # start the active configuration

    # wait for scan to finish
    pause(1)
    while confocal.is_scanning:
        pause(1)

timeline.mark_end()

print("Done!")
    catch_beads(80)
    print("Beads are trapped")
    # stage.move_to("DNA")
    # print("Moved to DNA channel")
    # pause(5) ## DEFINITELY have to play with this based on DNA concentration/flow rate
    # print('till here')
    stage.move_to("buffer")
    print("Moved to Buffer channel")


print('start executing script')

# set up the pressure
while fluidics.pressure < .20:
    fluidics.increase_pressure()
    pause(1)  #important!
pause(5)

single_tether_count = 0
mult_tether_count = 0
number_of_tries = 0

# this is going to be a for loop that can be broken
for jj in range(10):

    # while single_tether_count < 100:

    start = time.time()
    number_of_tries += 1
    bead_DNA_complex_setup()
    end = time.time()