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 6, 2018
1 parent 45db100 commit 299ce04
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 30 deletions.
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
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
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 @@ -64,6 +66,7 @@ const consolidate = (data: ConsolidateFormData): CompoundCommandCreator => (prev
volume: data.volume,
labware: data.sourceLabware,
well: sourceWell,
'flow-rate': aspirateFlowRateUlSec,
offsetFromBottomMm: aspirateOffsetFromBottomMm,
}),
...touchTipAfterAspirateCommand,
Expand Down Expand Up @@ -96,7 +99,9 @@ const consolidate = (data: ConsolidateFormData): CompoundCommandCreator => (prev
data.mixFirstAspirate.volume,
data.mixFirstAspirate.times,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
)
: []

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

Expand Down Expand Up @@ -144,6 +151,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
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 @@ -141,7 +144,9 @@ const distribute = (data: DistributeFormData): CompoundCommandCreator => (prevRo
data.mixBeforeAspirate.volume,
data.mixBeforeAspirate.times,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec
)
: []

Expand All @@ -153,6 +158,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
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ import type {MixFormData, RobotState, CommandCreator, CompoundCommandCreator} fr
import {aspirate, dispense, replaceTip, touchTip} from '../atomic'

/** 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 @@ -43,6 +46,8 @@ const mix = (data: MixFormData): CompoundCommandCreator => (prevRobotState: Robo
changeTip,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
} = data

// Errors
Expand Down Expand Up @@ -99,7 +104,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 @@ -40,6 +40,8 @@ const transfer = (data: TransferFormData): CompoundCommandCreator => (prevRobotS
}

const {
aspirateFlowRateUlSec,
dispenseFlowRateUlSec,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm,
} = data
Expand Down Expand Up @@ -79,7 +81,9 @@ const transfer = (data: TransferFormData): CompoundCommandCreator => (prevRobotS
Math.max(subTransferVol),
1,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec
)
: []

Expand All @@ -91,7 +95,9 @@ const transfer = (data: TransferFormData): CompoundCommandCreator => (prevRobotS
data.mixBeforeAspirate.volume,
data.mixBeforeAspirate.times,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec
)
: []

Expand Down Expand Up @@ -121,7 +127,9 @@ const transfer = (data: TransferFormData): CompoundCommandCreator => (prevRobotS
data.mixInDestination.volume,
data.mixInDestination.times,
aspirateOffsetFromBottomMm,
dispenseOffsetFromBottomMm
dispenseOffsetFromBottomMm,
aspirateFlowRateUlSec,
dispenseFlowRateUlSec
)
: []

Expand All @@ -143,6 +151,7 @@ const transfer = (data: TransferFormData): CompoundCommandCreator => (prevRobotS
volume: subTransferVol,
labware: data.sourceLabware,
well: sourceWell,
'flow-rate': aspirateFlowRateUlSec,
offsetFromBottomMm: aspirateOffsetFromBottomMm,
}),
...touchTipAfterAspirateCommands,
Expand All @@ -151,6 +160,7 @@ const transfer = (data: TransferFormData): CompoundCommandCreator => (prevRobotS
volume: subTransferVol,
labware: data.destLabware,
well: destWell,
'flow-rate': dispenseFlowRateUlSec,
offsetFromBottomMm: dispenseOffsetFromBottomMm,
}),
...touchTipAfterDispenseCommands,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,55 @@ describe('aspirate', () => {
})
})

describe('aspirate 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 = 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 : {}),
},
}])
})
})
})

test('aspirate with volume > tip max volume should throw error', () => {
robotStateWithTip.instruments['p300SingleId'].tiprackModel = 'tiprack-200ul'
const result = aspirateWithErrors({
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 299ce04

Please sign in to comment.