Example #1
0
        public int AddWellToDataTable(cWell Well, DataTable DataTableToAddedTo, cGlobalInfo GlobalInfo)
        {
            SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection);
            mycommand.CommandText = "SELECT * FROM \"" + Well.SQLTableName + "\"";
            SQLiteDataReader value = mycommand.ExecuteReader();

            DataTable dt = new DataTable();
            dt.Load(value);
            List<string> Names = this.GetDescriptorNames(Well);

            int CurrentClass = Well.GetCurrentClassIdx();

            if (DataTableToAddedTo.Columns.Count == 0)
            {
                foreach (string TmpName in Names)
                {
                    int DescIdx = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(TmpName);
                    if ((DescIdx != -1) && (cGlobalInfo.CurrentScreening.ListDescriptors[DescIdx].IsActive()))
                        DataTableToAddedTo.Columns.Add(new DataColumn(TmpName, typeof(double)));
                }

                //if (IsAddWellClass)
                //    DataTableToAddedTo.Columns.Add(new DataColumn("Well_Class", typeof(int)));
            }

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataTableToAddedTo.Rows.Add();
                int RealIdxCol = 0;
                for (int IdxCol = 0; IdxCol < Names.Count; IdxCol++)
                {
                    int DescIdx = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(Names[IdxCol]);
                    if ((DescIdx != -1) && (cGlobalInfo.CurrentScreening.ListDescriptors[DescIdx].IsActive()))
                    {
                        DataTableToAddedTo.Rows[DataTableToAddedTo.Rows.Count - 1][RealIdxCol++] = dt.Rows[i][IdxCol];
                    }
                }
                //if (IsAddWellClass)
                //    DataTableToAddedTo.Rows[DataTableToAddedTo.Rows.Count - 1][DataTableToAddedTo.Columns.Count - 1] = CurrentClass;
            }

            mycommand.Dispose();
            mycommand = null;
            value.Close();
            value.Dispose();
            value = null;

            return dt.Rows.Count;
        }
Example #2
0
 public FormForStatDesc(cGlobalInfo GlobalInfo)
 {
     this.GlobalInfo = GlobalInfo;
     InitializeComponent();
 }
Example #3
0
 public cWellClassType(Color Colour, string Name, cGlobalInfo GlobalInfo)
 {
     base.ColourForDisplay = Colour;
     base.Name = Name;
     this.GlobalInfo = GlobalInfo;
 }
Example #4
0
 public cMachineLearning(cGlobalInfo GlobalInfo)
 {
     this.GlobalInfo = GlobalInfo;
 }
Example #5
0
 public FormForClassificationTree DisplayTree(cGlobalInfo GlobalInfo, J48 J48Model, bool IsCellular)
 {
     FormForClassificationTree WindowForTree = new FormForClassificationTree();
     string StringForTree = J48Model.graph().Remove(0, J48Model.graph().IndexOf("{") + 2);
     WindowForTree.gViewerForTreeClassif.Graph = cGlobalInfo.WindowHCSAnalyzer.ComputeAndDisplayGraph(StringForTree.Remove(StringForTree.Length - 3, 3), IsCellular);
     return WindowForTree;
 }
        public cFeedBackMessage Run(cGlobalInfo GlobalInfo)
        {
            FormForDisplay WindowToDisplay = new FormForDisplay();
            WindowToDisplay.Text = "2 Classes Selection";
            WindowToDisplay.FormBorderStyle = FormBorderStyle.FixedSingle;

            PanelForClassSelection ClassSelectionPanel1 = new PanelForClassSelection(PanelLeft_IsCheckBoxes, this.ClassType);
            ClassSelectionPanel1.UnSelectAll();
            ClassSelectionPanel1.Select(0);
            ClassSelectionPanel1.Location = new System.Drawing.Point(10, 10);
            ClassSelectionPanel1.Width = 140;
            if(ClassSelectionPanel1.ListCheckBoxes!=null)
                ClassSelectionPanel1.Height = ClassSelectionPanel1.ListCheckBoxes.Count*25;
            else
                ClassSelectionPanel1.Height = ClassSelectionPanel1.ListRadioButtons.Count * 25;
            ClassSelectionPanel1.BorderStyle = BorderStyle.Fixed3D;

            PanelForClassSelection ClassSelectionPanel2 = new PanelForClassSelection( PanelRight_IsCheckBoxes, this.ClassType);
            ClassSelectionPanel2.UnSelectAll();
            ClassSelectionPanel2.Select(1);
            ClassSelectionPanel2.Location = new System.Drawing.Point(10 + ClassSelectionPanel1.Width, 10);
            ClassSelectionPanel2.Width = 140;
            if (ClassSelectionPanel2.ListCheckBoxes != null)
                ClassSelectionPanel2.Height = ClassSelectionPanel2.ListCheckBoxes.Count * 25;
            else
                ClassSelectionPanel2.Height = ClassSelectionPanel2.ListRadioButtons.Count * 25;
            ClassSelectionPanel2.BorderStyle = BorderStyle.Fixed3D;

            Button ReturnButton = new Button();
            ReturnButton.Text = "Ok";
            ReturnButton.DialogResult = DialogResult.OK;
            ReturnButton.Location = new System.Drawing.Point(ClassSelectionPanel1.Location.X, ClassSelectionPanel1.Location.Y + ClassSelectionPanel1.Height + 5);
            WindowToDisplay.Controls.Add(ReturnButton);

            WindowToDisplay.Controls.Add(ClassSelectionPanel1);
            WindowToDisplay.Controls.Add(ClassSelectionPanel2);
            WindowToDisplay.Width = ClassSelectionPanel1.Width + ClassSelectionPanel2.Width + 28;
            WindowToDisplay.Height = ClassSelectionPanel1.Height + ReturnButton.Height+ 48;

            if (WindowToDisplay.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "Selection aborded !";
                return FeedBackMessage;
            }

            List<bool> ListBool1 = ClassSelectionPanel1.GetListSelectedClass();
            List<bool> ListBool2 = ClassSelectionPanel2.GetListSelectedClass();

            int NumSelected = 0;
            this.ListSelectedClass = new cExtendedTable();

            foreach (var item in ListBool1)
            {
                this.ListSelectedClass.Add(new cExtendedList());
                if (item)
                {
                    this.ListSelectedClass[0].Add(1);
                    NumSelected++;
                }
                else
                    this.ListSelectedClass[0].Add(0);
            }
            foreach (var item in ListBool2)
            {
                this.ListSelectedClass.Add(new cExtendedList());
                if (item)
                {
                    this.ListSelectedClass[1].Add(1);
                    NumSelected++;
                }
                else
                    this.ListSelectedClass[1].Add(0);
            }

            return FeedBackMessage;
        }
Example #7
0
 public cViewerScatter3D(cGlobalInfo GlobalInfo)
 {
     Title = "New Viewer Scatter 3D";
     this.GlobalInfo = GlobalInfo;
 }
Example #8
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;
        }
Example #9
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++;
            }
        }
Example #10
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++;
            }
        }