Beispiel #1
0
        /// <summary>
        /// Render the specified table with any specified column marked
        /// </summary>
        /// <param name="mt"></param>
        /// <param name="mc"></param>

        void RenderTable(
            MetaTable mt,
            MetaColumn mc)
        {
            QueryTable qt;

            if (mt == null)             // no query table
            {
                mt = new MetaTable();
                qt = new QueryTable(mt);
            }

            else             // mark selected field in query table to render
            {
                qt = new QueryTable(mt);
                qt.DeselectAll();
                bool selectedField = false;

                if (mc != null)
                {
                    for (int i1 = 0; i1 < qt.QueryColumns.Count; i1++)
                    {
                        QueryColumn qc = qt.QueryColumns[i1];
                        if (qc.MetaColumn == mc)                          // is this the column to select
                        {
                            qc.Selected   = true;
                            selectedField = true;
                        }
                        else
                        {
                            qc.Selected = false;
                        }
                    }
                }

                else if (CheckmarkDefaultColumn && qt.QueryColumns.Count > 1)                 // default to 1st metacolumn past key
                {
                    qt.QueryColumns[1].Selected = true;
                }
            }

            FieldGrid.Render(qt);
            SelectedQt = qt;             // keep qt where selected column will be found
            return;
        }
Beispiel #2
0
/// <summary>
/// Setup Parameters
/// </summary>

        void SetupParameters()
        {
            QueryColumn qc;

            SpotfireViewProps sl = SpotfireViewProps;
            Dictionary <string, SpotfireLinkParameter> p = sl.SpotfireLinkParameters;

            if (p.Count == 0)             // if no parameters then include one for CIDLIST checked
            {
                SpotfireLinkParameter p1 = new SpotfireLinkParameter("COMPOUND_ID", "True");
                p[p1.Name] = p1;
            }

            QueryTable qt = CriteriaCols.QueryTable;

            qt.DeselectAll();

            foreach (SpotfireLinkParameter p0 in sl.SpotfireLinkParameters.Values)
            {
                qc = qt.GetQueryColumnByName(p0.Name);
                if (qc == null)
                {
                    continue;
                }

                bool selected = false;
                bool.TryParse(p0.Value, out selected);
                qc.Selected = selected;
            }

            qc = qt.GetQueryColumnByName("visualization");             // hide visualization col here
            if (qc != null)
            {
                qc.MetaColumn.InitialSelection = ColumnSelectionEnum.Hidden;                 // hide visualization col here
                qc.Selected = false;
            }

            CriteriaCols.TableHeaderLabel.Visible = false;
            CriteriaCols.CanDeselectKeyCol        = true;
            CriteriaCols.Render();
            return;
        }
Beispiel #3
0
/// <summary>
/// Convert a multipivot table into a set of tables where data exists for
/// one or more of the compound identifiers in the list.
/// </summary>
/// <param name="qt">Current form of query table</param>
/// <param name="q">Query to add transformed tables to</param>
/// <param name="ResultKeys">Keys data will be retrieved for</param>

        public override void ExpandToMultipleTables(
            QueryTable qt,
            Query q,
            List <string> resultKeys)
        {
            MetaTable        mt2;
            QueryTable       qt2;
            QueryColumn      qc2;
            HashSet <string> geneDict = new HashSet <string>();
            string           sql;
            string           geneSymbol;

            int t0 = TimeOfDay.Milliseconds();

// Build query & get set of gene symbols

            Query q2 = new Query();

            q2.SingleStepExecution = true;

            q2.KeyCriteria = q2.KeyCriteriaDisplay =              // keylist to return (may want to include all target summary option criteria)
                                                     " in (" + MqlUtil.FormatValueListString(resultKeys, true) + ")";

            qt2 = qt.Clone();
            qt2.SelectKeyOnly();
            qc2          = qt2.GetQueryColumnByNameWithException("gene_symbol");
            qc2.Selected = true;
            q2.AddQueryTable(qt2);

            QueryEngine qe2 = new QueryEngine();

            qe2.ExecuteQuery(q2);
            while (true)
            {
                object[] vo = qe2.NextRow();
                if (vo == null)
                {
                    qe2.Close();
                    break;
                }

                if (qe2.Cancelled)
                {
                    qe2.Close();
                    return;
                }

                geneSymbol = vo[2] as string;
                if (Lex.IsNullOrEmpty(geneSymbol))
                {
                    continue;
                }
                geneDict.Add(geneSymbol.ToUpper());
            }

            string[] sa = new string[geneDict.Count];
            geneDict.CopyTo(sa);
            Array.Sort(sa);

            foreach (string s0 in sa)
            {
                geneSymbol = s0;
                string mt2Name = MultiDbAssayDataNames.BasePivotTablePrefix + geneSymbol;

                //if (QueryEngine.FilterAllDataQueriesByDatabaseContents &&
                //    !MetaTableCollection.IsMetaTableInContents(mtName)) continue; // metatable must be in contents

                mt2 = MetaTableCollection.Get(mt2Name);
                if (mt2 == null)
                {
                    continue;                              // in case can't allocate for some reason
                }
                qt2 = q.GetQueryTableByName(mt2.Name);     // see if already in query
                if (qt2 != null)
                {
                    continue;                              // ignore if already there
                }
                qt2 = new QueryTable(q, mt2);              // allocate new query table & add to query
                qt2.DeselectAll();

                foreach (QueryColumn qc0 in qt.QueryColumns)                 // set selected columns to match those in the source qt
                {
                    if (qc0.Selected && qt2.GetQueryColumnByName(qc0.MetaColumn.Name) != null)
                    {
                        qt2.GetQueryColumnByName(qc0.MetaColumn.Name).Selected = true;
                    }
                }

                if (qt.HeaderBackgroundColor != Color.Empty)
                {
                    qt2.HeaderBackgroundColor = qt.HeaderBackgroundColor;
                }
            }

            t0 = TimeOfDay.Milliseconds() - t0;
            return;
        }