Пример #1
0
        public async Task CreateOrUpdateCycleStep(CycleStepItemViewModel cycleStepItemViewModel)
        {
            CycleStep cycleStepToInsertOrUpdate;

            if (cycleStepItemViewModel.IsNew)
            {
                cycleStepToInsertOrUpdate = new CycleStep();

                SynthesisCycle synthesisCycle = unitOfWork.GetById <SynthesisCycle>(cycleStepItemViewModel.SynthesisCycleId);
                cycleStepToInsertOrUpdate.SynthesisCycle = synthesisCycle;

                await MapCycleStepItemToCycleStep(cycleStepItemViewModel, cycleStepToInsertOrUpdate);
            }
            else
            {
                cycleStepToInsertOrUpdate = await unitOfWork.GetAll <CycleStep>()
                                            .Include(x => x.SynthesisCycle)
                                            .Include(x => x.HardwareFunction)
                                            .SingleAsync(x => x.Id == cycleStepItemViewModel.CycleStepId);

                await MapCycleStepItemToCycleStep(cycleStepItemViewModel, cycleStepToInsertOrUpdate);
            }

            unitOfWork.InsertOrUpdate(cycleStepToInsertOrUpdate);
            unitOfWork.Commit();

            if (cycleStepItemViewModel.IsNew)
            {
                await UpdateStepNumbersOnInsert(cycleStepItemViewModel, cycleStepToInsertOrUpdate);
            }
        }
Пример #2
0
        public SynthesisCycle CreateSynthesisCycle()
        {
            SynthesisCycle synthesisCycle = new SynthesisCycle();

            synthesisCycle.Name = "test cycle";

            return(GetOrCreate(() => synthesisCycle));
        }
Пример #3
0
        public async Task CreateGeneSynthesisProcess(string geneId)
        {
            Gene gene = await unitOfWork.GetAll <Gene>().Include(x => x.GeneFragments).SingleAsync(x => x.Id == geneId);

            await AssertGeneFragmentsCorrespondsToConfiguredChannels(gene.GeneFragments);

            GeneSynthesisProcess currentGeneSynthesisProcess = await GetCurrentGeneSynthesisProcess();

            if (currentGeneSynthesisProcess != null)
            {
                currentGeneSynthesisProcess.Deleted = true;
            }

            GeneSynthesisProcess newGeneSynthesisProcess = new GeneSynthesisProcess
            {
                Status = SynthesisProcessStatus.NotStarted,
                Gene   = gene,
            };

            unitOfWork.InsertOrUpdate(newGeneSynthesisProcess);

            unitOfWork.Commit();

            // create synthesis activities from gene fragments

            SynthesisCycle defaultSynthesisCycle = await unitOfWork.GetAll <SynthesisCycle>()
                                                   .Include(x => x.CycleSteps)
                                                   .SingleAsync(x => x.UserId == null);

            IList <GeneSynthesisActivity> geneSynthesisActivities = new List <GeneSynthesisActivity>();

            foreach (GeneFragment geneFragment in gene.GeneFragments)
            {
                GeneSynthesisActivity newSynthesisActivity =
                    await CreateSynthesisActivity(geneFragment.OligoSequence, newGeneSynthesisProcess, defaultSynthesisCycle);

                geneSynthesisActivities.Add(newSynthesisActivity);
            }

            await AssignChannelNumbers(geneSynthesisActivities);

            await unitOfWork.InsertAll(geneSynthesisActivities);

            newGeneSynthesisProcess.TotalTime = geneSynthesisActivities.Sum(x => x.TotalTime);

            unitOfWork.Commit();
        }
Пример #4
0
        private async Task <GeneSynthesisActivity> CreateSynthesisActivity(
            string dnaSequence, GeneSynthesisProcess currentGeneSynthesisProcess, SynthesisCycle defaultSynthesisCycle)
        {
            GeneSynthesisActivity geneSynthesisActivity = new GeneSynthesisActivity();

            geneSynthesisActivity.GeneSynthesisProcessId = currentGeneSynthesisProcess.Id;
            geneSynthesisActivity.GeneSynthesisProcess   = currentGeneSynthesisProcess;

            geneSynthesisActivity.SynthesisCycleId = defaultSynthesisCycle.Id;
            geneSynthesisActivity.SynthesisCycle   = defaultSynthesisCycle;

            geneSynthesisActivity.DNASequence = !string.IsNullOrWhiteSpace(dnaSequence) ? dnaSequence.ToUpper() : "A";

            CalcGeneSynthesisActivityTotalTime(geneSynthesisActivity);

            return(geneSynthesisActivity);
        }
Пример #5
0
        public async Task CreateOrUpdateSynthesisCycle(SynthesisCycleItemViewModel synthesisCycleItemViewModel)
        {
            SynthesisCycle synthesisCycle;

            if (string.IsNullOrWhiteSpace(synthesisCycleItemViewModel.Id))
            {
                var  currentPrincipal = identityStorage.GetPrincipal();
                User currentUser      = unitOfWork.GetById <User>(currentPrincipal.UserId);

                synthesisCycle      = new SynthesisCycle();
                synthesisCycle.Name = synthesisCycleItemViewModel.Name;
                synthesisCycle.User = currentUser;

                SynthesisCycle defaultSynthesisCycle = await unitOfWork.GetAll <SynthesisCycle>()
                                                       .Include(x => x.CycleSteps)
                                                       .Include(x => x.CycleSteps.Select(y => y.HardwareFunction))
                                                       .SingleAsync(x => x.UserId == null);

                foreach (CycleStep defaultCycleStep in defaultSynthesisCycle.CycleSteps)
                {
                    CycleStep newCycleStep = new CycleStep();
                    newCycleStep.Number           = defaultCycleStep.Number;
                    newCycleStep.StepTime         = defaultCycleStep.StepTime;
                    newCycleStep.A                = defaultCycleStep.A;
                    newCycleStep.G                = defaultCycleStep.G;
                    newCycleStep.C                = defaultCycleStep.C;
                    newCycleStep.T                = defaultCycleStep.T;
                    newCycleStep.Six              = defaultCycleStep.Six;
                    newCycleStep.Seven            = defaultCycleStep.Seven;
                    newCycleStep.SafeStep         = defaultCycleStep.SafeStep;
                    newCycleStep.HardwareFunction = defaultCycleStep.HardwareFunction;

                    synthesisCycle.CycleSteps.Add(newCycleStep);
                }
            }
            else
            {
                synthesisCycle = await unitOfWork.GetAll <SynthesisCycle>().Include(x => x.User).SingleAsync(x => x.Id == synthesisCycleItemViewModel.Id);

                synthesisCycle.Name = synthesisCycleItemViewModel.Name;
            }

            unitOfWork.InsertOrUpdate(synthesisCycle);
            unitOfWork.Commit();
        }
Пример #6
0
        public async Task CreateOrUpdateSynthesisActivity(SynthesisActivityItemViewModel item)
        {
            GeneSynthesisActivity entity;

            GeneSynthesisProcess currentGeneSynthesisProcess = await GetCurrentGeneSynthesisProcess();

            if (string.IsNullOrWhiteSpace(item.Id))
            {
                entity = new GeneSynthesisActivity();
                entity.GeneSynthesisProcess = currentGeneSynthesisProcess;
            }
            else
            {
                entity = await unitOfWork.GetAll <GeneSynthesisActivity>()
                         .Include(x => x.SynthesisCycle)
                         .Include(x => x.GeneSynthesisProcess)
                         .SingleAsync(x => x.Id == item.Id);
            }

            entity.DNASequence = !string.IsNullOrWhiteSpace(item.DNASequence) ? item.DNASequence.ToUpper() : "A";
            if (item.SynthesisCycle != null && !string.IsNullOrWhiteSpace(item.SynthesisCycle.Id))
            {
                entity.SynthesisCycle = unitOfWork.GetById <SynthesisCycle>(item.SynthesisCycle.Id);
            }
            else
            {
                SynthesisCycle defaultSynthesisCycle = await unitOfWork.GetAll <SynthesisCycle>()
                                                       .SingleAsync(x => x.UserId == null);

                entity.SynthesisCycle = defaultSynthesisCycle;
            }

            await AssignToChannel(entity, currentGeneSynthesisProcess.GeneSynthesisActivities);

            CalcGeneSynthesisActivityTotalTime(entity);

            unitOfWork.InsertOrUpdate(entity);
            unitOfWork.Commit();

            currentGeneSynthesisProcess = await GetCurrentGeneSynthesisProcess();

            CalcGeneSynthesisProcessTotalTime(currentGeneSynthesisProcess);

            unitOfWork.Commit();
        }
Пример #7
0
        public async Task <IEnumerable <CycleStepItemViewModel> > GetCycleStepItems(string synthesisCycleId)
        {
            SynthesisCycle synthesisCycle = await unitOfWork.GetAll <SynthesisCycle>()
                                            .Include(x => x.CycleSteps.Select(y => y.HardwareFunction))
                                            .AsNoTracking()
                                            .SingleAsync(x => x.Id == synthesisCycleId);

            IList <CycleStepItemViewModel> cycleStepItems = new List <CycleStepItemViewModel>();

            foreach (var cycleStep in synthesisCycle.CycleSteps.OrderBy(x => x.Number))
            {
                cycleStepItems.Add(new CycleStepItemViewModel()
                {
                    SynthesisCycleId   = synthesisCycleId,
                    CycleStepId        = cycleStep.Id,
                    HardwareFunctionId = cycleStep.HardwareFunctionId,
                    StepNumber         = cycleStep.Number,
                    FunctionNumber     = cycleStep.HardwareFunction.Number,
                    //FunctionName = cycleStep.HardwareFunction.Name,
                    HardwareFunction = new HardwareFunctionItemViewModel {
                        Id = cycleStep.HardwareFunction.Id, Name = cycleStep.HardwareFunction.Name
                    },
                    StepTime = cycleStep.StepTime,
                    A        = cycleStep.A,
                    G        = cycleStep.G,
                    C        = cycleStep.C,
                    T        = cycleStep.T,
                    Five     = cycleStep.Five,
                    Six      = cycleStep.Six,
                    Seven    = cycleStep.Seven,
                    SafeStep = cycleStep.SafeStep,
                });
            }

            return(cycleStepItems);
        }