Ejemplo n.º 1
0
        private void MatchingKitsFrm_Load(object sender, EventArgs e)
        {
            lblKit.Text  = kit;
            lblName.Text = GGKUtilLib.queryDatabase("kit_master", new string[] { "name" }, "WHERE kit_no='" + kit + "'").Rows[0].ItemArray[0].ToString();
            DataTable dt = GGKUtilLib.QueryDB("SELECT cmp_id,kit'Kit No',name'Name',at_longest'Autosomal Longest',at_total'Autosomal Total',x_longest'X Longest',x_total'X Total',mrca'MRCA' FROM (SELECT a.cmp_id,a.kit1'kit',b.name,a.at_longest,a.at_total,a.x_longest,a.x_total,a.mrca FROM cmp_status a,kit_master b WHERE a.at_total!=0 AND a.kit1!='" + kit + "' AND a.kit2='" + kit + "' AND a.status_autosomal=1 AND b.kit_no=a.kit1 AND b.disabled=0 UNION SELECT a.cmp_id,a.kit2'kit',b.name,a.at_longest,a.at_total,a.x_longest,a.x_total,a.mrca FROM cmp_status a,kit_master b WHERE a.at_total!=0 AND a.kit2!='" + kit + "' AND a.kit1='" + kit + "' AND a.status_autosomal=1 AND b.kit_no=a.kit2 AND b.disabled=0) ORDER BY at_longest DESC,at_total DESC");

            dgvMatches.Columns.Clear();
            dgvMatches.DataSource         = dt;
            dgvMatches.Columns[0].Visible = false;

            dgvMatches.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvMatches.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvMatches.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvMatches.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvMatches.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvMatches.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgvMatches.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            DataGridViewCellStyle style = new DataGridViewCellStyle();

            style.Format = "N2";

            dgvMatches.Columns[3].DefaultCellStyle = style;
            dgvMatches.Columns[4].DefaultCellStyle = style;
            dgvMatches.Columns[5].DefaultCellStyle = style;
            dgvMatches.Columns[6].DefaultCellStyle = style;
        }
Ejemplo n.º 2
0
 public static void loadSettings()
 {
     if (settings == null)
     {
         settings = new SortedDictionary <string, string[]>();
         DataTable dt_settings = GGKUtilLib.queryDatabase("ggk_settings", new string[] { "key", "value", "description", "readonly", "last_modified" });
         object[]  data        = null;
         foreach (DataRow row in dt_settings.Rows)
         {
             data = row.ItemArray;
             settings.Add(data[0].ToString(), new string[] { data[1].ToString(), data[2].ToString(), data[3].ToString(), data[4].ToString() });
         }
     }
 }
Ejemplo n.º 3
0
        private void bwCompare_DoWork(object sender, DoWorkEventArgs e)
        {
            if (redo_again)
            {
                GGKUtilLib.clearAllComparisions(no_admixture);
            }

            DataTable dt = null;

            if (no_admixture)
            {
                dt = GGKUtilLib.queryDatabase("kit_master", new string[] { "kit_no", "reference", "name" }, "where disabled=0 and reference=0");
            }
            else
            {
                dt = GGKUtilLib.queryDatabase("kit_master", new string[] { "kit_no", "reference", "name" }, "where disabled=0");
            }

            int    progress = 0;
            int    total    = 0;
            string ref1     = "0";
            string ref2     = "0";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = i; j < dt.Rows.Count; j++)
                {
                    if (bwCompare.CancellationPending)
                    {
                        break;
                    }
                    kit1 = dt.Rows[i].ItemArray[0].ToString();
                    kit2 = dt.Rows[j].ItemArray[0].ToString();
                    if (kit1 == kit2)
                    {
                        continue;
                    }
                    ref1 = dt.Rows[i].ItemArray[1].ToString();
                    ref2 = dt.Rows[j].ItemArray[1].ToString();

                    if (ref1 == "1" && ref2 == "1")
                    {
                        continue;
                    }
                    total++;
                }
                if (bwCompare.CancellationPending)
                {
                    break;
                }
            }

            int idx = 0;

            string name1     = "";
            string name2     = "";
            bool   reference = false;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = i; j < dt.Rows.Count; j++)
                {
                    if (bwCompare.CancellationPending)
                    {
                        break;
                    }
                    kit1 = dt.Rows[i].ItemArray[0].ToString();
                    kit2 = dt.Rows[j].ItemArray[0].ToString();
                    if (kit1 == kit2)
                    {
                        continue;
                    }
                    ref1 = dt.Rows[i].ItemArray[1].ToString();
                    ref2 = dt.Rows[j].ItemArray[1].ToString();

                    if (ref1 == "1" && ref2 == "1")
                    {
                        continue;
                    }

                    if (ref1 == "1" || ref2 == "1")
                    {
                        reference = true;
                    }
                    else
                    {
                        reference = false;
                    }

                    name1 = dt.Rows[i].ItemArray[2].ToString();
                    name2 = dt.Rows[j].ItemArray[2].ToString();
                    idx++;

                    this.Invoke(new MethodInvoker(delegate
                    {
                        if (reference)
                        {
                            lblComparing.Text = "Comparing Reference " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + ") ... " + progress.ToString() + "%";
                            tbStatus.Text    += ("Comparing Reference " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + "): ");
                        }
                        else
                        {
                            lblComparing.Text = "Comparing Kits " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + ") ... " + progress.ToString() + "%";
                            tbStatus.Text    += ("Comparing Kits " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + "): ");
                        }
                        tbStatus.Select(tbStatus.Text.Length - 1, 0);
                        tbStatus.ScrollToCaret();
                    }));
                    progress = idx * 100 / total;

                    object[] cmp_results = GGKUtilLib.compareOneToOne(kit1, kit2, bwCompare, reference, true);

                    if (bwCompare.CancellationPending)
                    {
                        break;
                    }

                    segment_idx = (DataTable)cmp_results[0];
                    segments    = (List <DataTable>)cmp_results[1];
                    //if (segment_idx.Rows.Count>0)
                    if (segment_idx.Rows.Count > 0 || redo_again)
                    {
                        if (!this.IsHandleCreated)
                        {
                            break;
                        }

                        this.Invoke(new MethodInvoker(delegate
                        {
                            if (reference)
                            {
                                tbStatus.Text += segment_idx.Rows.Count.ToString() + " compound segments found.\r\n";
                            }
                            else
                            {
                                tbStatus.Text += segment_idx.Rows.Count.ToString() + " matching segments found.\r\n";
                            }
                            tbStatus.Select(tbStatus.Text.Length - 1, 0);
                            tbStatus.ScrollToCaret();
                        }));
                    }
                    else
                    {
                        this.Invoke(new MethodInvoker(delegate
                        {
                            tbStatus.Text += "Earlier comparision exists, Skipping.\r\n";
                            tbStatus.Select(tbStatus.Text.Length - 1, 0);
                            tbStatus.ScrollToCaret();
                        }));
                    }
                    bwCompare.ReportProgress(progress, progress.ToString() + "%");
                }
                if (bwCompare.CancellationPending)
                {
                    break;
                }
                if (!this.IsHandleCreated)
                {
                    break;
                }
            }
            if (!bwCompare.CancellationPending)
            {
                bwCompare.ReportProgress(100, "Done.");
            }
        }