Skip to content

Commit

Permalink
fix(protocol-designer): finish implementing flow rate in PD
Browse files Browse the repository at this point in the history
Closes #2773
  • Loading branch information
IanLondon committed Dec 5, 2018
1 parent 4271425 commit a78ad7b
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 48 deletions.
4 changes: 4 additions & 0 deletions protocol-designer/src/step-generation/aspirate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {RobotState, CommandCreator, CommandCreatorError, AspirateDispenseAr
/** Aspirate with given args. Requires tip. */
const aspirate = (args: AspirateDispenseArgs): CommandCreator => (prevRobotState: RobotState) => {
const {pipette, volume, labware, well, offsetFromBottomMm} = args
const flowRateUlSec = args['flow-rate']

const actionName = 'aspirate'
let errors: Array<CommandCreatorError> = []
Expand Down Expand Up @@ -48,6 +49,9 @@ const aspirate = (args: AspirateDispenseArgs): CommandCreator => (prevRobotState
offsetFromBottomMm: offsetFromBottomMm == null
? undefined
: offsetFromBottomMm,
'flow-rate': flowRateUlSec == null
? undefined
: flowRateUlSec,
},
}]

Expand Down
12 changes: 10 additions & 2 deletions protocol-designer/src/step-generation/consolidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const consolidate = (data: ConsolidateFormData): CompoundCommandCreator => (prev
}

const {
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm,
} = data
Expand Down Expand Up @@ -71,6 +73,7 @@ const consolidate = (data: ConsolidateFormData): CompoundCommandCreator => (prev
volume: data.volume + (isFirstWellInChunk ? disposalVolume : 0),
labware: data.sourceLabware,
well: sourceWell,
'flow-rate': aspirateFlowRateUlSec,
offsetFromBottomMm: aspirateOffsetFromBottomMm,
}),
...touchTipAfterAspirateCommand,
Expand Down Expand Up @@ -113,7 +116,9 @@ const consolidate = (data: ConsolidateFormData): CompoundCommandCreator => (prev
data.mixFirstAspirate.volume,
data.mixFirstAspirate.times,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
)
: []

Expand All @@ -126,7 +131,9 @@ const consolidate = (data: ConsolidateFormData): CompoundCommandCreator => (prev
data.volume,
1,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
)
: []

Expand Down Expand Up @@ -162,6 +169,7 @@ const consolidate = (data: ConsolidateFormData): CompoundCommandCreator => (prev
volume: data.volume * sourceWellChunk.length,
labware: data.destLabware,
well: data.destWell,
'flow-rate': dispenseFlowRateUlSec,
offsetFromBottomMm: dispenseOffsetFromBottomMm,
}),
...touchTipAfterDispenseCommands,
Expand Down
4 changes: 4 additions & 0 deletions protocol-designer/src/step-generation/dispense.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {RobotState, CommandCreator, CommandCreatorError, AspirateDispenseAr
/** Dispense with given args. Requires tip. */
const dispense = (args: AspirateDispenseArgs): CommandCreator => (prevRobotState: RobotState) => {
const {pipette, volume, labware, well, offsetFromBottomMm} = args
const flowRateUlSec = args['flow-rate']

const actionName = 'dispense'
let errors: Array<CommandCreatorError> = []
Expand All @@ -32,6 +33,9 @@ const dispense = (args: AspirateDispenseArgs): CommandCreator => (prevRobotState
offsetFromBottomMm: offsetFromBottomMm == null
? undefined
: offsetFromBottomMm,
'flow-rate': flowRateUlSec == null
? undefined
: flowRateUlSec,
},
}]

Expand Down
8 changes: 7 additions & 1 deletion protocol-designer/src/step-generation/distribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const distribute = (data: DistributeFormData): CompoundCommandCreator => (prevRo
}

const {
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm,
} = data
Expand Down Expand Up @@ -96,6 +98,7 @@ const distribute = (data: DistributeFormData): CompoundCommandCreator => (prevRo
volume: data.volume,
labware: data.destLabware,
well: destWell,
'flow-rate': dispenseFlowRateUlSec,
offsetFromBottomMm: dispenseOffsetFromBottomMm,
}),
...touchTipAfterDispenseCommand,
Expand Down Expand Up @@ -140,7 +143,9 @@ const distribute = (data: DistributeFormData): CompoundCommandCreator => (prevRo
data.mixBeforeAspirate.volume,
data.mixBeforeAspirate.times,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec
)
: []

Expand All @@ -152,6 +157,7 @@ const distribute = (data: DistributeFormData): CompoundCommandCreator => (prevRo
volume: data.volume * destWellChunk.length + disposalVolume,
labware: data.sourceLabware,
well: data.sourceWell,
'flow-rate': aspirateFlowRateUlSec,
offsetFromBottomMm: aspirateOffsetFromBottomMm,
}),
...touchTipAfterAspirateCommand,
Expand Down
15 changes: 11 additions & 4 deletions protocol-designer/src/step-generation/mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ import * as errorCreators from './errorCreators'
import type {MixFormData, RobotState, CommandCreator, CompoundCommandCreator} from './'

/** Helper fn to make mix command creators w/ minimal arguments */
// TODO IMMEDIATELY: use named params not ordered args
export function mixUtil (
pipette: string,
labware: string,
well: string,
volume: number,
times: number,
aspirateOffsetFromBottomMm?: ?number,
dispenseOffsetFromBottomMm?: ?number
dispenseOffsetFromBottomMm?: ?number,
aspirateFlowRateUlSec?: ?number,
dispenseFlowRateUlSec?: ?number,
): Array<CommandCreator> {
return repeatArray([
aspirate({pipette, volume, labware, well, offsetFromBottomMm: aspirateOffsetFromBottomMm}),
dispense({pipette, volume, labware, well, offsetFromBottomMm: dispenseOffsetFromBottomMm}),
aspirate({pipette, volume, labware, well, offsetFromBottomMm: aspirateOffsetFromBottomMm, 'flow-rate': aspirateFlowRateUlSec}),
dispense({pipette, volume, labware, well, offsetFromBottomMm: dispenseOffsetFromBottomMm, 'flow-rate': dispenseFlowRateUlSec}),
], times)
}

Expand All @@ -47,6 +50,8 @@ const mix = (data: MixFormData): CompoundCommandCreator => (prevRobotState: Robo
changeTip,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
} = data

// Errors
Expand Down Expand Up @@ -102,7 +107,9 @@ const mix = (data: MixFormData): CompoundCommandCreator => (prevRobotState: Robo
volume,
times,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec
)

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,55 @@ describe('aspirate', () => {
tipracks: [300, 300],
})

test('aspirate with tip', () => {
const result = aspirate({
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
})(robotStateWithTip)

expect(result.commands).toEqual([{
command: 'aspirate',
params: {
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
describe('aspirate normally (with tip)', () => {
const optionalArgsCases = [
{
description: 'no optional args',
expectInParams: false,
args: {},
},
}])

expect(result.robotState).toMatchObject(robotStateWithTipNoLiquidState)
{
description: 'null optional args',
expectInParams: false,
args: {
offsetFromBottomMm: null,
'flow-rate': null,
},
},
{
description: 'all optional args',
expectInParams: true,
args: {
offsetFromBottomMm: 5,
'flow-rate': 6,
},
},
]

optionalArgsCases.forEach(testCase => {
test(testCase.description, () => {
const result = aspirate({
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
...testCase.args,
})(robotStateWithTip)

expect(result.commands).toEqual([{
command: 'aspirate',
params: {
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
...(testCase.expectInParams ? testCase.args : {}),
},
}])

expect(result.robotState).toMatchObject(robotStateWithTipNoLiquidState)
})
})
})

test('aspirate with volume > tip max volume should throw error', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,69 @@ describe('dispense', () => {
})

describe('tip tracking & commands:', () => {
test('dispense with tip', () => {
const result = dispense({
describe('dispense normally (with tip)', () => {
const optionalArgsCases = [
{
description: 'no optional args',
expectInParams: false,
args: {},
},
{
description: 'null optional args',
expectInParams: false,
args: {
offsetFromBottomMm: null,
'flow-rate': null,
},
},
{
description: 'all optional args',
expectInParams: true,
args: {
offsetFromBottomMm: 5,
'flow-rate': 6,
},
},
]
optionalArgsCases.forEach(testCase => {
test(testCase.description, () => {
const result = dispense({
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
...testCase.args,
})(robotStateWithTip)

expect(result.commands).toEqual([{
command: 'dispense',
params: {
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
...(testCase.expectInParams ? testCase.args : {}),
},
}])
})
})
})

test('dispense normally (with tip) and optional args', () => {
const args = {
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
})(robotStateWithTip)
offsetFromBottomMm: 5,
'flow-rate': 6,
}

const result = dispense(args)(robotStateWithTip)

expect(result.commands).toEqual([{
command: 'dispense',
params: {
pipette: 'p300SingleId',
volume: 50,
labware: 'sourcePlateId',
well: 'A1',
},
params: args,
}])
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import {tiprackWellNamesFlat} from '../../data'
import type {Command} from '../../types'
import type {AspirateDispenseArgs, Command} from '../../types'

export const replaceTipCommands = (tip: number | string): Array<Command> => [
dropTip('A1'),
Expand Down Expand Up @@ -49,10 +49,7 @@ export const touchTip = (
export const aspirate = (
well: string,
volume: number,
params?: {|
pipette?: string,
labware?: string,
|}
params?: $Shape<AspirateDispenseArgs>
): Command => ({
command: 'aspirate',
params: {
Expand All @@ -67,10 +64,7 @@ export const aspirate = (
export const dispense = (
well: string,
volume: number,
params?: {|
pipette?: string,
labware?: string,
|}
params?: $Shape<AspirateDispenseArgs>
): Command => ({
command: 'dispense',
params: {
Expand Down
Loading

0 comments on commit a78ad7b

Please sign in to comment.