func Steps(params Parameters, inputs Inputs) Outputs { var outputs Outputs ctx := execution.GetContext() em := ctx.EquipmentManager rqout := em.MakeDeviceRequest("liquidhandler", "Manual") response := <-rqout // handle response problems if response["status"] == "FAIL" { log.Fatal("Error requesting liquid handler service") } liquidhandler := response["devicequeue"].(*execution.LiquidHandlingService) samples := make([]*wtype.LHComponent, 0) buffersample := mixer.SampleForTotalVolume(inputs.Buffer, params.Reactionvolume) samples = append(samples, buffersample) atpsample := mixer.Sample(inputs.ATP, params.Atpvol) samples = append(samples, atpsample) vectorsample := mixer.SampleForConcentration(inputs.Vector, params.Vectorconc) samples = append(samples, vectorsample) for _, part := range inputs.Parts { partsample := mixer.SampleForConcentration(part, params.Partconc) samples = append(samples, partsample) } resample := mixer.Sample(inputs.RestrictionEnzyme, params.Revol) samples = append(samples, resample) ligsample := mixer.Sample(inputs.Ligase, params.Ligvol) samples = append(samples, ligsample) reaction := mixer.MixInto(inputs.Outplate, samples...) // set the block ID reaction.BlockID = string(params.BlockID) rq2 := liquidhandler.MakeMixRequest(reaction) if rq2 == nil { log.Fatal("Error running liquid handling request") } rq2.Tip_Type = inputs.TipType liquidhandler.Run() // incubate the reaction mixtures incubate(reaction, params.Reactiontemp, params.Reactiontime, false) // inactivate incubate(reaction, params.Inactivationtemp, params.Inactivationtime, false) // all done outputs.Reaction = reaction return outputs }
// Runs a workflow for one sample func (w *Workflow) Run(cf *Config) ([]interface{}, error) { id, err := uuid.NewV4() if err != nil { return nil, err } tid := execute.ThreadID(id.String()) ctx := execution.GetContext() ctx.ConfigService.SetConfig(tid, cf.Config) wr, err := NewWorkflowRun(*id, w, cf) if err != nil { return nil, err } var errors []error go func() { for v := range wr.Errors { if v != nil { errors = append(errors, v) } } }() var messages []interface{} go func() { for v := range wr.Messages { // messages = append(messages, fmt.Sprintf("%v", v.Value)) messages = append(messages, v.Value) } }() <-wr.Done if len(errors) > 0 { return messages, Errors(errors) } return messages, nil }
func main() { eid, _ := uuid.NewV4() em := equipmentManager.NewAnthaEquipmentManager(eid.String()) defer em.Shutdown() eem := equipmentManager.EquipmentManager(em) equipmentManager.SetEquipmentManager(&eem) //manual driver equipment mid, _ := uuid.NewV4() var mde equipment.Equipment var amd manual.AnthaManual amd = *manual.NewAnthaManual(mid.String()) mde = amd em.RegisterEquipment(&mde) //cui logger middleware cmw := middleware.NewLogToCui(&amd.Cui) log_id, _ := uuid.NewV4() l := logger.NewAnthaFileLogger(log_id.String()) l.RegisterMiddleware(cmw) var params Parameters var inputs Inputs // give this thing an arbitrary ID for testing id := execute.ThreadID(fmt.Sprintf("EXPERIMENT_1_%s", string(eid.String()[1:5]))) fmt.Println(id) // set up parameters and inputs params.Reactionvolume = wunit.NewVolume(20, "ul") params.Partconc = wunit.NewConcentration(0.0001, "g/l") params.Vectorconc = wunit.NewConcentration(0.001, "g/l") params.Atpvol = wunit.NewVolume(1, "ul") params.Revol = wunit.NewVolume(1, "ul") params.Ligvol = wunit.NewVolume(1, "ul") params.Reactiontemp = wunit.NewTemperature(25, "C") params.Reactiontime = wunit.NewTime(1800, "s") params.Inactivationtemp = wunit.NewTemperature(40, "C") params.Inactivationtime = wunit.NewTime(60, "s") params.BlockID = id inputs.Parts = make([]*wtype.LHComponent, 4) for i := 0; i < 4; i++ { inputs.Parts[i] = factory.GetComponentByType("dna_part") inputs.Parts[i].CName = inputs.Parts[i].CName + "_" + strconv.Itoa(i+1) } inputs.Vector = factory.GetComponentByType("standard_cloning_vector_mark_1") inputs.RestrictionEnzyme = factory.GetComponentByType("SapI") inputs.Ligase = factory.GetComponentByType("T4Ligase") inputs.Buffer = factory.GetComponentByType("CutsmartBuffer") inputs.ATP = factory.GetComponentByType("ATP") inputs.Outplate = factory.GetPlateByType("pcrplate") inputs.TipType = factory.GetTipboxByType("Gilson50") ctx := execution.GetContext() conf := make(map[string]interface{}) conf["MAX_N_PLATES"] = 1.5 conf["MAX_N_WELLS"] = 12.0 conf["RESIDUAL_VOLUME_WEIGHT"] = 1.0 conf["SQLITE_FILE_IN"] = "/Users/msadowski/synthace/protocol_language/checkout/synthace-antha/anthalib/driver/liquidhandling/pm_driver/default.sqlite" conf["SQLITE_FILE_OUT"] = "/tmp/output_file.sqlite" ctx.ConfigService.SetConfig(id, conf) outputs := Steps(params, inputs) fmt.Println(outputs.Reaction) }