Beispiel #1
0
        public void CreateNewColumn(cDescriptorType NewDescType, cDescriptorType Desc0, eUnaryOperationType OperationType, cGlobalInfo GlobalInfo, ref cListWells ListWell)
        {
            string ColumnName = NewDescType.GetName();

            int NumTableProcessed = 0;
            foreach (var item in GetListTableNames())   // loop over the wells
            {
                // compute the new values
                List<cDescriptorType> LDes = new List<cDescriptorType>();
                LDes.Add(Desc0);
              //  LDes.Add(Desc1);
                cExtendedTable LValues = this.GetWellValues(item, LDes);
                cExtendedList ListResults = new cExtendedList();// LValues[0].Operation(LValues[1], OperationType);

                if (OperationType == eUnaryOperationType.LOG)
                {
                    for (int i = 0; i < LValues[0].Count; i++)
                    {
                        double tmpVal = LValues[0][i];
                        if (tmpVal <= 0) tmpVal = double.Epsilon;
                        ListResults.Add(Math.Log10(tmpVal));
                    }
                }
                else if (OperationType == eUnaryOperationType.SQRT)
                {
                    for (int i = 0; i < LValues[0].Count; i++)
                    {
                        double tmpVal = LValues[0][i];
                        if (tmpVal < 0) tmpVal = 0;
                        ListResults.Add(Math.Sqrt(tmpVal));
                    }
                }
                else if (OperationType == eUnaryOperationType.ABS)
                {
                    for (int i = 0; i < LValues[0].Count; i++)
                    {
                        double tmpVal = LValues[0][i];
                        ListResults.Add(Math.Abs(tmpVal));
                    }
                }
                else if (OperationType == eUnaryOperationType.EXP)
                {
                    for (int i = 0; i < LValues[0].Count; i++)
                    {
                        double tmpVal = LValues[0][i];
                        ListResults.Add(Math.Exp(tmpVal));
                    }
                }

                #region Update the database
                // create new column
                SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection);
                String SQL = "ALTER TABLE \"" + item + "\" ADD COLUMN \"" + ColumnName + "\" REAL DEFAULT 0";
                using (SQLiteCommand Command = new SQLiteCommand(SQL, _SQLiteConnection))
                {
                    Command.ExecuteNonQuery();
                }

                // write data
                using (SQLiteTransaction transaction = _SQLiteConnection.BeginTransaction())
                using (SQLiteDataAdapter sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM \"" + item + "\"", _SQLiteConnection))
                {
                    DataSet DS = new DataSet();
                    sqliteAdapter.Fill(DS);

                    using (sqliteAdapter.InsertCommand = new SQLiteCommandBuilder(sqliteAdapter).GetUpdateCommand())
                    {
                        for (int i = 0; i < DS.Tables[0].Rows.Count; i++)
                            DS.Tables[0].Rows[i][ColumnName] = ListResults[i];

                        sqliteAdapter.Update(DS);
                    }
                    transaction.Commit();
                }
                #endregion

                #region Update the screening data
                cListSignature LDesc = new cListSignature();
                cSignature NewSignature = new cSignature(ListResults, 256, NewDescType, cGlobalInfo.CurrentScreening);
                LDesc.Add(NewSignature);

                string[] Positions = item.Split('x');
                ListWell.GetFirstWell(int.Parse(Positions[1]), int.Parse(Positions[2])).AddSignatures(LDesc);
                #endregion

                NumTableProcessed++;
            }
        }
Beispiel #2
0
        public void CreateNewColumnFromExisting(cDescriptorType NewDescType, string DescToBeDuplicated, cGlobalInfo GlobalInfo, ref cListWells ListWell)
        {
            this.CreateNewColumn(NewDescType.GetName(), 0);

            // cExtendedList ListResults = null;

            foreach (var item in GetListTableNames())
            {
                SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection);
                //update tableName set onefield = secondfield;
                string SQL = "UPDATE \"" + item + "\" SET \"" + NewDescType.GetName() + "\" = \"" + DescToBeDuplicated + "\"";
                using (SQLiteCommand Command = new SQLiteCommand(SQL, _SQLiteConnection))
                {
                    Command.ExecuteNonQuery();
                }

                #region Update the screening data
                List<cDescriptorType> LDes = new List<cDescriptorType>();
                LDes.Add(NewDescType);
                cExtendedTable LValues = this.GetWellValues(item, LDes);

                cListSignature LDesc = new cListSignature();
                cSignature NewSignature = new cSignature(LValues[0], NewDescType.GetBinNumber(), NewDescType, cGlobalInfo.CurrentScreening);
                LDesc.Add(NewSignature);

                string[] Positions = item.Split('x');
                ListWell.GetFirstWell(int.Parse(Positions[1]), int.Parse(Positions[2])).AddSignatures(LDesc);
                #endregion
            }

            return;
        }
Beispiel #3
0
        /// <summary>
        /// Create a new column in the database of the current plate
        /// </summary>
        /// <param name="ColumnName">Column name</param>
        /// <param name="DefaultValue">Array of values</param>
        /// <returns>Return the number of table (i.e. wells) processed</returns>
        public void CreateNewColumn(cDescriptorType NewDescType, cDescriptorType Desc0, cDescriptorType Desc1,
                                    cSingleCellOperations SingleCellOperations, 
                                    cGlobalInfo GlobalInfo, ref cListWells ListWell)
        {
            string ColumnName = NewDescType.GetName();

            int NumTableProcessed = 0;
            foreach (var item in GetListTableNames())   // loop over the wells
            {
                // compute the new values
                List<cDescriptorType> LDes = new List<cDescriptorType>();
                LDes.Add(Desc0);
                LDes.Add(Desc1);
                cExtendedTable LValues = this.GetWellValues(item, LDes);
                cExtendedList ListResults = LValues[0].Operation(LValues[1], SingleCellOperations.ListDualOperations[0]);

                if ((SingleCellOperations.PostProcessingOperation != null) && (SingleCellOperations.PostProcessingOperation.Count > 0))
                {
                    switch (SingleCellOperations.PostProcessingOperation[0])
                    {
                        case eBinaryOperationType.ADD:
                            ListResults += SingleCellOperations.PostProcessingValue;
                            break;
                        case eBinaryOperationType.SUBSTRACT:
                            ListResults -= SingleCellOperations.PostProcessingValue;
                            break;
                        case eBinaryOperationType.MULTIPLY:
                            ListResults *= SingleCellOperations.PostProcessingValue;
                            break;
                        case eBinaryOperationType.DIVIDE:
                            ListResults /= SingleCellOperations.PostProcessingValue;
                            break;
                        default:
                            break;
                    }
                }

                #region Update the database
                // create new column
                SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection);
                String SQL = "ALTER TABLE \"" + item + "\" ADD COLUMN \"" + ColumnName + "\" REAL DEFAULT 0";
                using (SQLiteCommand Command = new SQLiteCommand(SQL, _SQLiteConnection))
                {
                    Command.ExecuteNonQuery();
                }

                // write data
                using (SQLiteTransaction transaction = _SQLiteConnection.BeginTransaction())
                using (SQLiteDataAdapter sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM \"" + item + "\"", _SQLiteConnection))
                {
                    DataSet DS = new DataSet();
                    sqliteAdapter.Fill(DS);

                    using (sqliteAdapter.InsertCommand = new SQLiteCommandBuilder(sqliteAdapter).GetUpdateCommand())
                    {
                        for (int i = 0; i < DS.Tables[0].Rows.Count; i++)
                            DS.Tables[0].Rows[i][ColumnName] = ListResults[i];

                        sqliteAdapter.Update(DS);
                    }
                    transaction.Commit();
                }
                #endregion

                #region Update the screening data
                cListSignature LDesc = new cListSignature();
                cSignature NewSignature = new cSignature(ListResults, 256, NewDescType, cGlobalInfo.CurrentScreening);
                LDesc.Add(NewSignature);

                string[] Positions = item.Split('x');

                cWell TmpWell = ListWell.GetFirstWell(int.Parse(Positions[1]), int.Parse(Positions[2]));
                if(TmpWell!=null) TmpWell.AddSignatures(LDesc);
                #endregion

                NumTableProcessed++;
            }
        }