Exemple #1
0
        private void ValidateQpcrModel(QpcrModel model)
        {
            if (!PlateSizeIsValid(model.PlateSize))
            {
                throw new Exception("Plate size is valid");
            }

            if (!AllReagentsNamesAreUnique(model.NamesOfReagents))
            {
                throw new Exception("All reagents names are not unique");
            }

            //  if (model.listOfIntegers.Length != model.NamesOfReagents.Length)
            //    throw new Exception("List of integer can not cover reagents length");
        }
Exemple #2
0
        public Cell[,] GenerateQpcr(QpcrModel model)
        {
            ValidateQpcrModel(model);

            int sumListOfIntegers = model.listOfIntegers.AsQueryable().Sum();

            //combine all reagents in single list
            var reAgentList = new List <string>();

            for (int i = 0; i < model.NamesOfReagents.Rank; i++)
            {
                for (int j = 0; j <= model.NamesOfReagents.GetLength(i); j++)
                {
                    try
                    {
                        reAgentList.Add(model.NamesOfReagents[i, j]);
                    }
                    catch
                    {
                    }
                }
            }


            var cellItems = new List <CellItem>();

            Cell[,] cells = new Cell[model.Names.GetLength(0) + 1, sumListOfIntegers];

            //Get dimension count from Names array
            for (int dimensionIndex = 0; dimensionIndex < model.Names.Rank; dimensionIndex++)
            {
                //Get each element count from given dimension
                for (int itemIndex = 0; itemIndex < model.Names.GetLength(dimensionIndex); itemIndex++)
                {
                    //this variable iterates from  zero to sum(listOfInteger.values)
                    int listOfIntegerCounter = 0;

                    for (int listOfIntegerLen = 0; listOfIntegerLen < model.listOfIntegers.Length; listOfIntegerLen++)
                    {
                        for (int listOfIntegerItem = 0;
                             listOfIntegerItem < model.listOfIntegers[listOfIntegerLen];
                             listOfIntegerItem++)
                        {
                            //if maximum number of plates not exceeded
                            //if (model.MaximumNumberOfPlates == 0 || cellItems.Count > model.MaximumNumberOfPlates)
                            //{
                            cellItems.Add(new CellItem()
                            {
                                Name      = model.Names[dimensionIndex, itemIndex],
                                ReAgent   = reAgentList[listOfIntegerLen],
                                Row_Coord = itemIndex,
                                Col_Coord = listOfIntegerCounter
                            });

                            cells[itemIndex, listOfIntegerCounter] = new Cell()
                            {
                                Name    = model.Names[dimensionIndex, itemIndex],
                                ReAgent = reAgentList[listOfIntegerLen]
                            };

                            ++listOfIntegerCounter;
                        }

                        // }
                    }
                }
            }

            var boardSize = GetBoardSize(model.PlateSize);

            GenerateVisualizeTable(cellItems, boardSize.Item1, boardSize.Item2);

            return(cells);
        }